@shophost/rest-api 2.0.65 → 2.0.68

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 (206) hide show
  1. package/package.json +2 -2
  2. package/scripts/shophost-rest-api.mjs +0 -1
  3. package/src/container.d.ts +2 -2
  4. package/src/container.js +1 -1
  5. package/src/core/lib/prisma.d.ts +24 -24
  6. package/src/core/notifications/email.service.d.ts +1 -1
  7. package/src/core/notifications/email.service.js +1 -1
  8. package/src/features/cart/cart.service.js +1 -1
  9. package/src/features/customer/customer.route.d.ts +4 -4
  10. package/src/features/customer/customer.schema.d.ts +4 -4
  11. package/src/features/customer/customer.service.d.ts +1 -1
  12. package/src/features/integration/integration.service.d.ts +1 -1
  13. package/src/features/integration/integration.service.js +1 -1
  14. package/src/features/order/order-fulfillment.service.js +1 -1
  15. package/src/features/order/order.handler.js +1 -1
  16. package/src/features/order/order.route.d.ts +139 -21
  17. package/src/features/order/order.route.js +1 -1
  18. package/src/features/order/order.schema.d.ts +4 -4
  19. package/src/features/order/order.service.d.ts +13 -7
  20. package/src/features/order/order.service.js +1 -1
  21. package/src/features/order/recipient.schema.d.ts +1 -1
  22. package/src/features/organization/legal-entity.schema.d.ts +1 -1
  23. package/src/features/organization/organization-configuration.schema.d.ts +1 -1
  24. package/src/features/organization/organization.route.d.ts +5 -5
  25. package/src/features/organization/organization.schema.d.ts +2 -2
  26. package/src/features/organization/organization.service.d.ts +4 -4
  27. package/src/features/payment/payment-webhook.service.d.ts +1 -3
  28. package/src/features/payment/payment-webhook.service.js +1 -1
  29. package/src/features/payment/payment.schema.d.ts +1 -1
  30. package/src/features/payment/payment.schema.js +1 -1
  31. package/src/features/payment/payment.service.d.ts +1 -0
  32. package/src/features/payment/stripe.service.d.ts +4 -1
  33. package/src/features/payment/stripe.service.js +1 -1
  34. package/src/features/reservation/emails/reservation-cancellation.email.js +1 -1
  35. package/src/features/reservation/emails/reservation-confirmation.email.js +1 -1
  36. package/src/features/reservation/emails/reservation-notification.email.js +1 -1
  37. package/src/features/shipping/shipping.route.d.ts +4 -4
  38. package/src/features/shipping/shipping.service.d.ts +3 -3
  39. package/src/features/webhook/webhook.handler.js +1 -1
  40. package/src/features/webhook/webhook.route.d.ts +2 -2
  41. package/src/features/webhook/webhook.route.js +1 -1
  42. package/src/schemas/address.schema.d.ts +3 -3
  43. package/src/schemas/address.schema.js +1 -1
  44. package/scripts/minify-dist.mjs +0 -45
  45. package/src/bootstrap.js.map +0 -1
  46. package/src/container.js.map +0 -1
  47. package/src/core/auth/auth.schema.js.map +0 -1
  48. package/src/core/auth/auth.util.js.map +0 -1
  49. package/src/core/auth/better-auth.lib.js.map +0 -1
  50. package/src/core/auth/generate-password-hash.util.js.map +0 -1
  51. package/src/core/auth/headers.schema.js.map +0 -1
  52. package/src/core/auth/user.schema.js.map +0 -1
  53. package/src/core/db/__generated__/client/browser.js.map +0 -1
  54. package/src/core/db/__generated__/client/client.js.map +0 -1
  55. package/src/core/db/__generated__/client/commonInputTypes.js.map +0 -1
  56. package/src/core/db/__generated__/client/enums.js.map +0 -1
  57. package/src/core/db/__generated__/client/internal/class.js.map +0 -1
  58. package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +0 -1
  59. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +0 -1
  60. package/src/core/db/__generated__/client/models/Account.js.map +0 -1
  61. package/src/core/db/__generated__/client/models/Address.js.map +0 -1
  62. package/src/core/db/__generated__/client/models/Campaign.js.map +0 -1
  63. package/src/core/db/__generated__/client/models/ClosingTimes.js.map +0 -1
  64. package/src/core/db/__generated__/client/models/File.js.map +0 -1
  65. package/src/core/db/__generated__/client/models/Integration.js.map +0 -1
  66. package/src/core/db/__generated__/client/models/Invitation.js.map +0 -1
  67. package/src/core/db/__generated__/client/models/LegalEntity.js.map +0 -1
  68. package/src/core/db/__generated__/client/models/Manufacturer.js.map +0 -1
  69. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +0 -1
  70. package/src/core/db/__generated__/client/models/Member.js.map +0 -1
  71. package/src/core/db/__generated__/client/models/Modifier.js.map +0 -1
  72. package/src/core/db/__generated__/client/models/ModifierGroup.js.map +0 -1
  73. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +0 -1
  74. package/src/core/db/__generated__/client/models/OpeningTimes.js.map +0 -1
  75. package/src/core/db/__generated__/client/models/Order.js.map +0 -1
  76. package/src/core/db/__generated__/client/models/OrderItem.js.map +0 -1
  77. package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +0 -1
  78. package/src/core/db/__generated__/client/models/Organization.js.map +0 -1
  79. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +0 -1
  80. package/src/core/db/__generated__/client/models/Payment.js.map +0 -1
  81. package/src/core/db/__generated__/client/models/PaymentSession.js.map +0 -1
  82. package/src/core/db/__generated__/client/models/Product.js.map +0 -1
  83. package/src/core/db/__generated__/client/models/ProductCategory.js.map +0 -1
  84. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +0 -1
  85. package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +0 -1
  86. package/src/core/db/__generated__/client/models/ProductTranslation.js.map +0 -1
  87. package/src/core/db/__generated__/client/models/Reservation.js.map +0 -1
  88. package/src/core/db/__generated__/client/models/Session.js.map +0 -1
  89. package/src/core/db/__generated__/client/models/ShippingMethod.js.map +0 -1
  90. package/src/core/db/__generated__/client/models/ShippingZone.js.map +0 -1
  91. package/src/core/db/__generated__/client/models/User.js.map +0 -1
  92. package/src/core/db/__generated__/client/models/Verification.js.map +0 -1
  93. package/src/core/db/__generated__/client/models.js.map +0 -1
  94. package/src/core/db/index.js.map +0 -1
  95. package/src/core/email/components.js.map +0 -1
  96. package/src/core/exceptions/http-exception.js.map +0 -1
  97. package/src/core/hono/hono.js.map +0 -1
  98. package/src/core/lib/prisma.js.map +0 -1
  99. package/src/core/logging/pino.js.map +0 -1
  100. package/src/core/notifications/email.service.js.map +0 -1
  101. package/src/core/openapi/openapi.lib.js.map +0 -1
  102. package/src/core/types/google-maps.types.js.map +0 -1
  103. package/src/core/utils/currency.util.js.map +0 -1
  104. package/src/core/utils/env.util.js.map +0 -1
  105. package/src/core/utils/object.util.js.map +0 -1
  106. package/src/core/utils/translations.util.js.map +0 -1
  107. package/src/core/utils/zod.util.js.map +0 -1
  108. package/src/db.js.map +0 -1
  109. package/src/features/access/access.handler.js.map +0 -1
  110. package/src/features/access/access.route.js.map +0 -1
  111. package/src/features/access/access.schema.js.map +0 -1
  112. package/src/features/access/access.service.js.map +0 -1
  113. package/src/features/analytics/analytics.handler.js.map +0 -1
  114. package/src/features/analytics/analytics.route.js.map +0 -1
  115. package/src/features/analytics/analytics.schema.js.map +0 -1
  116. package/src/features/analytics/analytics.service.js.map +0 -1
  117. package/src/features/cart/cart.handler.js.map +0 -1
  118. package/src/features/cart/cart.route.js.map +0 -1
  119. package/src/features/cart/cart.schema.js.map +0 -1
  120. package/src/features/cart/cart.service.js.map +0 -1
  121. package/src/features/cart/cart.util.js.map +0 -1
  122. package/src/features/customer/customer.handler.js.map +0 -1
  123. package/src/features/customer/customer.route.js.map +0 -1
  124. package/src/features/customer/customer.schema.js.map +0 -1
  125. package/src/features/customer/customer.service.js.map +0 -1
  126. package/src/features/file/file.handler.js.map +0 -1
  127. package/src/features/file/file.route.js.map +0 -1
  128. package/src/features/file/file.schema.js.map +0 -1
  129. package/src/features/file/file.service.js.map +0 -1
  130. package/src/features/health/health.handler.js.map +0 -1
  131. package/src/features/health/health.route.js.map +0 -1
  132. package/src/features/index.js.map +0 -1
  133. package/src/features/integration/integration-config.js.map +0 -1
  134. package/src/features/integration/integration-registry.js.map +0 -1
  135. package/src/features/integration/integration.handler.js.map +0 -1
  136. package/src/features/integration/integration.route.js.map +0 -1
  137. package/src/features/integration/integration.schema.js.map +0 -1
  138. package/src/features/integration/integration.service.js.map +0 -1
  139. package/src/features/inventory/inventory.service.js.map +0 -1
  140. package/src/features/location/location.handler.js.map +0 -1
  141. package/src/features/location/location.route.js.map +0 -1
  142. package/src/features/location/location.schema.js.map +0 -1
  143. package/src/features/location/location.service.js.map +0 -1
  144. package/src/features/manufacturer/manufacturer.handler.js.map +0 -1
  145. package/src/features/manufacturer/manufacturer.route.js.map +0 -1
  146. package/src/features/manufacturer/manufacturer.schema.js.map +0 -1
  147. package/src/features/manufacturer/manufacturer.service.js.map +0 -1
  148. package/src/features/order/emails/order-confirmation.email.js.map +0 -1
  149. package/src/features/order/emails/order-notification.email.js.map +0 -1
  150. package/src/features/order/fulfilment.schema.js.map +0 -1
  151. package/src/features/order/order-fulfillment.service.js.map +0 -1
  152. package/src/features/order/order.handler.js.map +0 -1
  153. package/src/features/order/order.route.js.map +0 -1
  154. package/src/features/order/order.schema.js.map +0 -1
  155. package/src/features/order/order.service.js.map +0 -1
  156. package/src/features/order/recipient.schema.js.map +0 -1
  157. package/src/features/organization/legal-entity.schema.js.map +0 -1
  158. package/src/features/organization/organization-configuration.schema.js.map +0 -1
  159. package/src/features/organization/organization.handler.js.map +0 -1
  160. package/src/features/organization/organization.route.js.map +0 -1
  161. package/src/features/organization/organization.schema.js.map +0 -1
  162. package/src/features/organization/organization.service.js.map +0 -1
  163. package/src/features/payment/payment-webhook.service.js.map +0 -1
  164. package/src/features/payment/payment.handler.js.map +0 -1
  165. package/src/features/payment/payment.route.js.map +0 -1
  166. package/src/features/payment/payment.schema.js.map +0 -1
  167. package/src/features/payment/payment.service.js.map +0 -1
  168. package/src/features/payment/stripe.service.js.map +0 -1
  169. package/src/features/product/product-modifier.schema.js.map +0 -1
  170. package/src/features/product/product.handler.js.map +0 -1
  171. package/src/features/product/product.route.js.map +0 -1
  172. package/src/features/product/product.schema.js.map +0 -1
  173. package/src/features/product/product.service.js.map +0 -1
  174. package/src/features/product-category/product-category.handler.js.map +0 -1
  175. package/src/features/product-category/product-category.route.js.map +0 -1
  176. package/src/features/product-category/product-category.schema.js.map +0 -1
  177. package/src/features/product-category/product-category.service.js.map +0 -1
  178. package/src/features/reservation/emails/reservation-cancellation.email.js.map +0 -1
  179. package/src/features/reservation/emails/reservation-confirmation.email.js.map +0 -1
  180. package/src/features/reservation/emails/reservation-notification.email.js.map +0 -1
  181. package/src/features/reservation/emails/reservation-updated.email.js.map +0 -1
  182. package/src/features/reservation/reservation.handler.js.map +0 -1
  183. package/src/features/reservation/reservation.route.js.map +0 -1
  184. package/src/features/reservation/reservation.schema.js.map +0 -1
  185. package/src/features/reservation/reservation.service.js.map +0 -1
  186. package/src/features/shipping/shipping.handler.js.map +0 -1
  187. package/src/features/shipping/shipping.route.js.map +0 -1
  188. package/src/features/shipping/shipping.service.js.map +0 -1
  189. package/src/features/shipping-method/shipping-method.handler.js.map +0 -1
  190. package/src/features/shipping-method/shipping-method.route.js.map +0 -1
  191. package/src/features/shipping-method/shipping-method.schema.js.map +0 -1
  192. package/src/features/shipping-method/shipping-method.service.js.map +0 -1
  193. package/src/features/shipping-method/shipping-zone.schema.js.map +0 -1
  194. package/src/features/webhook/webhook.handler.js.map +0 -1
  195. package/src/features/webhook/webhook.route.js.map +0 -1
  196. package/src/index.js.map +0 -1
  197. package/src/integrations/next.js.map +0 -1
  198. package/src/schemas/address.schema.js.map +0 -1
  199. package/src/schemas/currency.schema.js.map +0 -1
  200. package/src/schemas/error.schema.js.map +0 -1
  201. package/src/schemas/index.js.map +0 -1
  202. package/src/schemas/locales.schema.js.map +0 -1
  203. package/src/schemas/number.schema.js.map +0 -1
  204. package/src/schemas/pagination.schema.js.map +0 -1
  205. package/src/schemas/params.schema.js.map +0 -1
  206. package/src/schemas/queries.schema.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shophost/rest-api",
3
- "version": "2.0.65",
3
+ "version": "2.0.68",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "shophost-rest-api": "./scripts/shophost-rest-api.mjs"
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "files": [
43
43
  "src",
44
- "scripts",
44
+ "scripts/shophost-rest-api.mjs",
45
45
  "schema.prisma",
46
46
  "prisma.config.ts",
47
47
  "next.d.ts",
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import dotenv from "dotenv";
3
-
4
3
  import { spawn } from "node:child_process";
5
4
  import { existsSync } from "node:fs";
6
5
  import { createRequire } from "node:module";
@@ -1,5 +1,5 @@
1
- import { EmailService } from "./core/notifications/email.service";
2
1
  import type { PrismaClientType } from "./core/lib/prisma";
2
+ import { EmailService } from "./core/notifications/email.service";
3
3
  import { AccessService } from "./features/access/access.service";
4
4
  import { AnalyticsService } from "./features/analytics/analytics.service";
5
5
  import { CartService } from "./features/cart/cart.service";
@@ -12,8 +12,8 @@ import { LocationService } from "./features/location/location.service";
12
12
  import { ManufacturerService } from "./features/manufacturer/manufacturer.service";
13
13
  import { OrderService } from "./features/order/order.service";
14
14
  import { OrganizationService } from "./features/organization/organization.service";
15
- import { PaymentService, type PaymentServiceOptions } from "./features/payment/payment.service";
16
15
  import { PaymentWebhookService } from "./features/payment/payment-webhook.service";
16
+ import { PaymentService, type PaymentServiceOptions } from "./features/payment/payment.service";
17
17
  import { ProductCategoryService } from "./features/product-category/product-category.service";
18
18
  import { ProductService } from "./features/product/product.service";
19
19
  import { ReservationService } from "./features/reservation/reservation.service";
package/src/container.js CHANGED
@@ -1 +1 @@
1
- import{EmailService as p}from"./core/notifications/email.service";import{AccessService as u}from"./features/access/access.service";import{AnalyticsService as a}from"./features/analytics/analytics.service";import{CartService as d}from"./features/cart/cart.service";import{CustomerService as y}from"./features/customer/customer.service";import{FileService as h}from"./features/file/file.service";import{IntegrationRegistry as s}from"./features/integration/integration-registry";import{IntegrationService as k}from"./features/integration/integration.service";import{InventoryService as C}from"./features/inventory/inventory.service";import{OrderFulfillmentService as P}from"./features/order/order-fulfillment.service";import{LocationService as b}from"./features/location/location.service";import{ManufacturerService as F}from"./features/manufacturer/manufacturer.service";import{OrderService as I}from"./features/order/order.service";import{OrganizationService as M}from"./features/organization/organization.service";import{PaymentService as O}from"./features/payment/payment.service";import{PaymentWebhookService as R}from"./features/payment/payment-webhook.service";import{StripeService as W}from"./features/payment/stripe.service";import{ProductCategoryService as z}from"./features/product-category/product-category.service";import{ProductService as A}from"./features/product/product.service";import{ReservationService as x}from"./features/reservation/reservation.service";import{ShippingMethodService as E}from"./features/shipping-method/shipping-method.service";import{ShippingService as L}from"./features/shipping/shipping.service";const _=({maps:r,payment:i,prisma:e}={})=>{var n;const c=!((n=r?.google)===null||n===void 0)&&n.key?new b(r.google.key):null,v=new C(e),o=new s(e),t=new p(o),m=new W(o),S=new O(e,i??{},m),f=new d(e,v),l=new I(e,S,f,t),w=new P(v,l),g=new R(e,m,w);return{access:new u(e),analytics:new a(e),cart:f,customer:new y(e),email:t,file:new h(e),inventory:v,integration:new k(e,o,t,m),integrationRegistry:o,location:c,manufacturer:new F(e),order:l,organization:new M(e,c),payment:S,product:new A(e),productCategory:new z(e),reservation:new x(e,t),shipping:new L(e,c),shippingMethod:new E(e),paymentWebhook:g}};export{_ as createContainer};
1
+ import{EmailService as p}from"./core/notifications/email.service";import{AccessService as u}from"./features/access/access.service";import{AnalyticsService as a}from"./features/analytics/analytics.service";import{CartService as d}from"./features/cart/cart.service";import{CustomerService as y}from"./features/customer/customer.service";import{FileService as h}from"./features/file/file.service";import{IntegrationRegistry as s}from"./features/integration/integration-registry";import{IntegrationService as k}from"./features/integration/integration.service";import{InventoryService as C}from"./features/inventory/inventory.service";import{LocationService as P}from"./features/location/location.service";import{ManufacturerService as b}from"./features/manufacturer/manufacturer.service";import{OrderFulfillmentService as F}from"./features/order/order-fulfillment.service";import{OrderService as I}from"./features/order/order.service";import{OrganizationService as M}from"./features/organization/organization.service";import{PaymentWebhookService as O}from"./features/payment/payment-webhook.service";import{PaymentService as R}from"./features/payment/payment.service";import{StripeService as W}from"./features/payment/stripe.service";import{ProductCategoryService as z}from"./features/product-category/product-category.service";import{ProductService as A}from"./features/product/product.service";import{ReservationService as x}from"./features/reservation/reservation.service";import{ShippingMethodService as E}from"./features/shipping-method/shipping-method.service";import{ShippingService as L}from"./features/shipping/shipping.service";const _=({maps:r,payment:i,prisma:e}={})=>{var n;const c=!((n=r?.google)===null||n===void 0)&&n.key?new P(r.google.key):null,v=new C(e),o=new s(e),t=new p(o),m=new W(o),S=new R(e,i??{},m),f=new d(e,v),l=new I(e,S,f,t),w=new F(v,l),g=new O(e,m,w);return{access:new u(e),analytics:new a(e),cart:f,customer:new y(e),email:t,file:new h(e),inventory:v,integration:new k(e,o,t,m),integrationRegistry:o,location:c,manufacturer:new b(e),order:l,organization:new M(e,c),payment:S,product:new A(e),productCategory:new z(e),reservation:new x(e,t),shipping:new L(e,c),shippingMethod:new E(e),paymentWebhook:g}};export{_ as createContainer};
@@ -26,18 +26,6 @@ export declare const createPrismaClient: (options: CreatePrismaClientOptions) =>
26
26
  }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
27
27
  };
28
28
  };
29
- file: {
30
- paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
31
- withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
32
- limit?: P["limit"] | undefined;
33
- }) | undefined) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").PageNumberPaginationMeta<TOptions extends {
34
- includePageCount: boolean;
35
- } ? TOptions["includePageCount"] : true>]>;
36
- withCursor: <TOptions extends Omit<P_1, "limit">, P_1 extends import("prisma-extension-pagination").CursorPaginationOptions<import("@prisma/client/runtime/client").Result<T, A, "findMany">[number], NonNullable<import("@prisma/client/runtime/client").Args<T, "findMany">["cursor"]>>>(options: TOptions & {
37
- limit: P_1["limit"];
38
- }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
39
- };
40
- };
41
29
  user: {
42
30
  paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
43
31
  withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
@@ -194,6 +182,18 @@ export declare const createPrismaClient: (options: CreatePrismaClientOptions) =>
194
182
  }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
195
183
  };
196
184
  };
185
+ file: {
186
+ paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
187
+ withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
188
+ limit?: P["limit"] | undefined;
189
+ }) | undefined) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").PageNumberPaginationMeta<TOptions extends {
190
+ includePageCount: boolean;
191
+ } ? TOptions["includePageCount"] : true>]>;
192
+ withCursor: <TOptions extends Omit<P_1, "limit">, P_1 extends import("prisma-extension-pagination").CursorPaginationOptions<import("@prisma/client/runtime/client").Result<T, A, "findMany">[number], NonNullable<import("@prisma/client/runtime/client").Args<T, "findMany">["cursor"]>>>(options: TOptions & {
193
+ limit: P_1["limit"];
194
+ }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
195
+ };
196
+ };
197
197
  manufacturer: {
198
198
  paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
199
199
  withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
@@ -440,18 +440,6 @@ export declare const createPrismaClient: (options: CreatePrismaClientOptions) =>
440
440
  }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
441
441
  };
442
442
  };
443
- file: {
444
- paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
445
- withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
446
- limit?: P["limit"] | undefined;
447
- }) | undefined) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").PageNumberPaginationMeta<TOptions extends {
448
- includePageCount: boolean;
449
- } ? TOptions["includePageCount"] : true>]>;
450
- withCursor: <TOptions extends Omit<P_1, "limit">, P_1 extends import("prisma-extension-pagination").CursorPaginationOptions<import("@prisma/client/runtime/client").Result<T, A, "findMany">[number], NonNullable<import("@prisma/client/runtime/client").Args<T, "findMany">["cursor"]>>>(options: TOptions & {
451
- limit: P_1["limit"];
452
- }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
453
- };
454
- };
455
443
  user: {
456
444
  paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
457
445
  withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
@@ -608,6 +596,18 @@ export declare const createPrismaClient: (options: CreatePrismaClientOptions) =>
608
596
  }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
609
597
  };
610
598
  };
599
+ file: {
600
+ paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
601
+ withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
602
+ limit?: P["limit"] | undefined;
603
+ }) | undefined) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").PageNumberPaginationMeta<TOptions extends {
604
+ includePageCount: boolean;
605
+ } ? TOptions["includePageCount"] : true>]>;
606
+ withCursor: <TOptions extends Omit<P_1, "limit">, P_1 extends import("prisma-extension-pagination").CursorPaginationOptions<import("@prisma/client/runtime/client").Result<T, A, "findMany">[number], NonNullable<import("@prisma/client/runtime/client").Args<T, "findMany">["cursor"]>>>(options: TOptions & {
607
+ limit: P_1["limit"];
608
+ }) => Promise<[import("@prisma/client/runtime/client").Result<T, A, "findMany">, import("prisma-extension-pagination").CursorPaginationMeta]>;
609
+ };
610
+ };
611
611
  manufacturer: {
612
612
  paginate: () => <T, A>(this: T, args?: import("@prisma/client/runtime/client").Exact<A, Omit<import("@prisma/client/runtime/client").Args<T, "findMany">, "cursor" | "take" | "skip">> | undefined) => {
613
613
  withPages: <TOptions extends Omit<P, "limit">, P extends import("prisma-extension-pagination").PageNumberPaginationOptions>(options?: (TOptions & {
@@ -14,7 +14,7 @@ declare class EmailService {
14
14
  /**
15
15
  * Sends an email
16
16
  */
17
- sendEmail(organizationId: string, payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<import("resend").CreateEmailResponseSuccess | null>;
17
+ sendEmail(organizationId: string, payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<import("resend").CreateEmailResponseSuccess | null | undefined>;
18
18
  /**
19
19
  * Sends an order confirmation email
20
20
  */
@@ -1 +1 @@
1
- import{__awaiter as r}from"tslib";import{Resend as d}from"resend";import{getStoredResendConfig as l}from"../../features/integration/integration-config";import{OrderConfirmationEmail as a}from"../../features/order/emails/order-confirmation.email";import u from"../../features/order/emails/order-notification.email";import{ReservationCancellationEmail as c}from"../../features/reservation/emails/reservation-cancellation.email";import{ReservationConfirmationEmail as f}from"../../features/reservation/emails/reservation-confirmation.email";import v from"../../features/reservation/emails/reservation-notification.email";import{ReservationUpdatedEmail as h}from"../../features/reservation/emails/reservation-updated.email";import{logger as m}from"../logging/pino";class g{constructor(o){this.integrationRegistry=o,this.runtimes=new Map}getRuntime(o){return r(this,void 0,void 0,function*(){const e=l(this.integrationRegistry.get(o,"resend")),i=JSON.stringify(e??null),t=this.runtimes.get(o);if(t?.signature===i)return t;const n={fromEmail:e?.fromEmail,resend:e?.apiKey?new d(e.apiKey):void 0,signature:i};return this.runtimes.set(o,n),n})}getFromAddress(o,e){return r(this,void 0,void 0,function*(){var i,t;const s=(t=(i=(yield this.getRuntime(o)).fromEmail)!==null&&i!==void 0?i:e.email)!==null&&t!==void 0?t:"info@shophost.io";return`${e.name} <${s}>`})}sendEmail(o,e,i){return r(this,void 0,void 0,function*(){const t=yield this.getRuntime(o);if(!t.resend)throw m.error({organizationId:o,subject:e.subject,to:e.to},"Resend integration is not configured for email send"),new Error(`Resend integration is not configured for organization ${o}`);m.info({from:e.from,organizationId:o,subject:e.subject,to:e.to},"Sending email with Resend");const{data:n,error:s}=yield t.resend.emails.send(e,i);if(s)throw m.error({resendError:s,from:e.from,subject:e.subject,to:e.to},"Failed to send email with Resend"),new Error(`Resend send failed: ${s.name}: ${s.message}`);return m.info({emailId:n?.id,subject:e.subject,to:e.to},"Email sent with Resend"),n})}sendOrderConfirmationEmail(o,e,i,t){return r(this,void 0,void 0,function*(){console.log(`Sending order confirmation email to ${e.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,i),to:[e.email],subject:`Order Confirmation - Order #${t.referenceId} | ${i.name}`,react:a({user:e,organization:i,order:t})})})}sendOrderNotificationEmail(o,e,i,t,n){return r(this,void 0,void 0,function*(){console.log(`Sending order notification email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`You have received a new order | ${t.name}`,react:u({user:e,organization:t,order:n})})})}sendReservationConfirmationEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation confirmation email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Confirmation - ${t.name}`,react:f({user:i,organization:t,reservation:e})}))})}sendReservationCancellationEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation cancellation email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Cancelled - ${t.name}`,react:c({user:i,organization:t,reservation:e})}))})}sendReservationNotificationEmail(o,e,i){return r(this,void 0,void 0,function*(){const t=i.user,n=i.organization;t&&(console.log(`Sending reservation notification email to ${e.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,n),to:[e.email],subject:`New Reservation Request | ${n.name}`,react:v({user:t,member:e,organization:n,reservation:i})}))})}sendReservationUpdatedEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation updated email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Updated - ${t.name}`,react:h({user:i,organization:t,reservation:e})}))})}}export{g as EmailService};
1
+ import{__awaiter as r}from"tslib";import{Resend as m}from"resend";import{getStoredResendConfig as l}from"../../features/integration/integration-config";import{OrderConfirmationEmail as a}from"../../features/order/emails/order-confirmation.email";import u from"../../features/order/emails/order-notification.email";import{ReservationCancellationEmail as c}from"../../features/reservation/emails/reservation-cancellation.email";import{ReservationConfirmationEmail as f}from"../../features/reservation/emails/reservation-confirmation.email";import v from"../../features/reservation/emails/reservation-notification.email";import{ReservationUpdatedEmail as h}from"../../features/reservation/emails/reservation-updated.email";import{logger as d}from"../logging/pino";class g{constructor(o){this.integrationRegistry=o,this.runtimes=new Map}getRuntime(o){return r(this,void 0,void 0,function*(){const e=l(this.integrationRegistry.get(o,"resend")),i=JSON.stringify(e??null),t=this.runtimes.get(o);if(t?.signature===i)return t;const n={fromEmail:e?.fromEmail,resend:e?.apiKey?new m(e.apiKey):void 0,signature:i};return this.runtimes.set(o,n),n})}getFromAddress(o,e){return r(this,void 0,void 0,function*(){var i,t;const s=(t=(i=(yield this.getRuntime(o)).fromEmail)!==null&&i!==void 0?i:e.email)!==null&&t!==void 0?t:"info@shophost.io";return`${e.name} <${s}>`})}sendEmail(o,e,i){return r(this,void 0,void 0,function*(){const t=yield this.getRuntime(o);if(!t.resend)return;const{data:n,error:s}=yield t.resend.emails.send(e,i);if(s)throw d.error({resendError:s,from:e.from,subject:e.subject,to:e.to},"Failed to send email with Resend"),new Error(`Resend send failed: ${s.name}: ${s.message}`);return d.info({emailId:n?.id,subject:e.subject,to:e.to},"Email sent with Resend"),n})}sendOrderConfirmationEmail(o,e,i,t){return r(this,void 0,void 0,function*(){console.log(`Sending order confirmation email to ${e.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,i),to:[e.email],subject:`Order Confirmation - Order #${t.referenceId} | ${i.name}`,react:a({user:e,organization:i,order:t})})})}sendOrderNotificationEmail(o,e,i,t,n){return r(this,void 0,void 0,function*(){console.log(`Sending order notification email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`You have received a new order | ${t.name}`,react:u({user:e,organization:t,order:n})})})}sendReservationConfirmationEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation confirmation email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Confirmation - ${t.name}`,react:f({user:i,organization:t,reservation:e})}))})}sendReservationCancellationEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation cancellation email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Cancelled - ${t.name}`,react:c({user:i,organization:t,reservation:e})}))})}sendReservationNotificationEmail(o,e,i){return r(this,void 0,void 0,function*(){const t=i.user,n=i.organization;t&&(console.log(`Sending reservation notification email to ${e.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,n),to:[e.email],subject:`New Reservation Request | ${n.name}`,react:v({user:t,member:e,organization:n,reservation:i})}))})}sendReservationUpdatedEmail(o,e){return r(this,void 0,void 0,function*(){const i=e.user,t=e.organization;i?.email&&(console.log(`Sending reservation updated email to ${i.email}`),yield this.sendEmail(o,{from:yield this.getFromAddress(o,t),to:[i.email],subject:`Reservation Updated - ${t.name}`,react:h({user:i,organization:t,reservation:e})}))})}}export{g as EmailService};
@@ -1 +1 @@
1
- import{__awaiter as v}from"tslib";import{flattenTranslationData as g}from"../../core/utils/zod.util";import{CartDataSchema as w,LocalizedProductSchema as y}from"../../schemas";class I{constructor(o,e){this.prisma=o,this.inventoryService=e}calculatePriceBreakdown(o,e,l){return v(this,void 0,void 0,function*(){var r,a;const i=l?yield this.prisma.shippingMethod.findUnique({where:{id:l},include:{shippingZones:!0}}):null,n=o.reduce((d,m)=>{var c,u;const p=e.find(f=>f.id===m.productId);if(!p)return d;const h=(u=(c=p.discountedBasePrice)!==null&&c!==void 0?c:p.basePrice)!==null&&u!==void 0?u:0;return d+h*(m.quantity||1)},0),s=(r=i?.shippingZones[0])===null||r===void 0?void 0:r.price;return{total:n+(s??0),subtotal:n,shipping:(a=i?.shippingZones[0])===null||a===void 0?void 0:a.price}})}getCartData(o,e,l){return v(this,void 0,void 0,function*(){const{locale:r}=l,a=new Set(e.items.map(t=>t.productId)),i=yield this.prisma.product.findMany({where:{id:{in:Array.from(a)},organizationId:o,deletedAt:null,publishedAt:{not:null}},include:{translations:!0,images:!0,categories:{include:{translations:{where:{locale:r}}}},modifierGroups:{include:{translations:{where:{locale:r}},modifiers:!0}}}}),n=this.inventoryService.normalizeCartItems(e.items,i.map(t=>({id:t.id,availableQuantity:t.availableQuantity}))),s=yield this.calculatePriceBreakdown(n.normalizedItems,i,e.shippingMethodId);return w.parse(Object.assign(Object.assign({},s),{adjustments:n.adjustments,invalidProductIds:n.invalidProductIds,normalizedItems:n.normalizedItems,products:i.reduce((t,d)=>(t[d.id]=y.parse(g(d)),t),{})}))})}}export{I as CartService};
1
+ import{__awaiter as v}from"tslib";import{flattenTranslationData as g}from"../../core/utils/zod.util";import{CartDataSchema as w,LocalizedProductSchema as y}from"../../schemas";class I{constructor(o,n){this.prisma=o,this.inventoryService=n}calculatePriceBreakdown(o,n,l){return v(this,void 0,void 0,function*(){var t,a;const i=l?yield this.prisma.shippingMethod.findUnique({where:{id:l},include:{shippingZones:!0}}):null,r=o.reduce((d,m)=>{var c,u;const p=n.find(f=>f.id===m.productId);if(!p)return d;const h=(u=(c=p.discountedBasePrice)!==null&&c!==void 0?c:p.basePrice)!==null&&u!==void 0?u:0;return d+h*(m.quantity||1)},0),s=(t=i?.shippingZones[0])===null||t===void 0?void 0:t.price;return{total:r+(s??0),subtotal:r,shipping:(a=i?.shippingZones[0])===null||a===void 0?void 0:a.price}})}getCartData(o,n,l){return v(this,void 0,void 0,function*(){const{locale:t}=l,a=new Set(n.items.map(e=>e.productId)),i=yield this.prisma.product.findMany({where:{id:{in:Array.from(a)},organizationId:o,deletedAt:null,publishedAt:{not:null}},include:{translations:t?{where:{locale:t}}:!0,images:!0,categories:{include:{translations:{where:{locale:t}}}},modifierGroups:{include:{translations:{where:{locale:t}},modifiers:!0}}}}),r=this.inventoryService.normalizeCartItems(n.items,i.map(e=>({id:e.id,availableQuantity:e.availableQuantity}))),s=yield this.calculatePriceBreakdown(r.normalizedItems,i,n.shippingMethodId);return w.parse(Object.assign(Object.assign({},s),{adjustments:r.adjustments,invalidProductIds:r.invalidProductIds,normalizedItems:r.normalizedItems,products:i.reduce((e,d)=>(e[d.id]=y.parse(g(d)),e),{})}))})}}export{I as CartService};
@@ -245,7 +245,7 @@ export declare const customerRoute: {
245
245
  zipCode: z.ZodOptional<z.ZodString>;
246
246
  city: z.ZodString;
247
247
  country: z.ZodString;
248
- placeId: z.ZodString;
248
+ placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
249
249
  deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
250
250
  }, z.core.$strip>>>;
251
251
  fulfilmentMethod: z.ZodEnum<{
@@ -311,7 +311,7 @@ export declare const customerRoute: {
311
311
  shipping: z.ZodDefault<z.ZodNumber>;
312
312
  subtotal: z.ZodNumber;
313
313
  total: z.ZodNumber;
314
- discount: z.ZodDefault<z.ZodNumber>;
314
+ discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
315
315
  currency: z.ZodEnum<{
316
316
  USD: "USD";
317
317
  EUR: "EUR";
@@ -446,13 +446,13 @@ export declare const customerRoute: {
446
446
  addressLineOne: string;
447
447
  city: string;
448
448
  country: string;
449
- placeId: string;
450
449
  firstname?: string | null | undefined;
451
450
  lastname?: string | null | undefined;
452
451
  phone?: string | null | undefined;
453
452
  doorNumber?: string | null | undefined;
454
453
  addressLineTwo?: string | null | undefined;
455
454
  zipCode?: string | undefined;
455
+ placeId?: string | null | undefined;
456
456
  deliveryInstructions?: string | null | undefined;
457
457
  } | null | undefined;
458
458
  }, {
@@ -553,13 +553,13 @@ export declare const customerRoute: {
553
553
  addressLineOne: string;
554
554
  city: string;
555
555
  country: string;
556
- placeId: string;
557
556
  firstname?: string | null | undefined;
558
557
  lastname?: string | null | undefined;
559
558
  phone?: string | null | undefined;
560
559
  doorNumber?: string | null | undefined;
561
560
  addressLineTwo?: string | null | undefined;
562
561
  zipCode?: string | undefined;
562
+ placeId?: string | null | undefined;
563
563
  deliveryInstructions?: string | null | undefined;
564
564
  } | null | undefined;
565
565
  }>>>;
@@ -240,7 +240,7 @@ export declare const AdminCustomerDetailSchema: z.ZodObject<{
240
240
  zipCode: z.ZodOptional<z.ZodString>;
241
241
  city: z.ZodString;
242
242
  country: z.ZodString;
243
- placeId: z.ZodString;
243
+ placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
244
244
  deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
245
245
  }, z.core.$strip>>>;
246
246
  fulfilmentMethod: z.ZodEnum<{
@@ -306,7 +306,7 @@ export declare const AdminCustomerDetailSchema: z.ZodObject<{
306
306
  shipping: z.ZodDefault<z.ZodNumber>;
307
307
  subtotal: z.ZodNumber;
308
308
  total: z.ZodNumber;
309
- discount: z.ZodDefault<z.ZodNumber>;
309
+ discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
310
310
  currency: z.ZodEnum<{
311
311
  USD: "USD";
312
312
  EUR: "EUR";
@@ -441,13 +441,13 @@ export declare const AdminCustomerDetailSchema: z.ZodObject<{
441
441
  addressLineOne: string;
442
442
  city: string;
443
443
  country: string;
444
- placeId: string;
445
444
  firstname?: string | null | undefined;
446
445
  lastname?: string | null | undefined;
447
446
  phone?: string | null | undefined;
448
447
  doorNumber?: string | null | undefined;
449
448
  addressLineTwo?: string | null | undefined;
450
449
  zipCode?: string | undefined;
450
+ placeId?: string | null | undefined;
451
451
  deliveryInstructions?: string | null | undefined;
452
452
  } | null | undefined;
453
453
  }, {
@@ -548,13 +548,13 @@ export declare const AdminCustomerDetailSchema: z.ZodObject<{
548
548
  addressLineOne: string;
549
549
  city: string;
550
550
  country: string;
551
- placeId: string;
552
551
  firstname?: string | null | undefined;
553
552
  lastname?: string | null | undefined;
554
553
  phone?: string | null | undefined;
555
554
  doorNumber?: string | null | undefined;
556
555
  addressLineTwo?: string | null | undefined;
557
556
  zipCode?: string | undefined;
557
+ placeId?: string | null | undefined;
558
558
  deliveryInstructions?: string | null | undefined;
559
559
  } | null | undefined;
560
560
  }>>>;
@@ -139,13 +139,13 @@ declare class CustomerService {
139
139
  addressLineOne: string;
140
140
  city: string;
141
141
  country: string;
142
- placeId: string;
143
142
  firstname?: string | null | undefined;
144
143
  lastname?: string | null | undefined;
145
144
  phone?: string | null | undefined;
146
145
  doorNumber?: string | null | undefined;
147
146
  addressLineTwo?: string | null | undefined;
148
147
  zipCode?: string | undefined;
148
+ placeId?: string | null | undefined;
149
149
  deliveryInstructions?: string | null | undefined;
150
150
  } | null | undefined;
151
151
  }[];
@@ -2,8 +2,8 @@ import { z } from "@hono/zod-openapi";
2
2
  import { PrismaClientType } from "../../core/lib/prisma";
3
3
  import { EmailService } from "../../core/notifications/email.service";
4
4
  import { StripeService } from "../payment/stripe.service";
5
- import { UpsertIntegrationSchema } from "./integration.schema";
6
5
  import { IntegrationRegistry } from "./integration-registry";
6
+ import { UpsertIntegrationSchema } from "./integration.schema";
7
7
  declare class IntegrationService {
8
8
  private readonly prisma;
9
9
  private readonly integrationRegistry;
@@ -1 +1 @@
1
- import{__awaiter as c}from"tslib";import{HttpException as o}from"../../core/exceptions/http-exception";import{IntegrationSchema as S,ResendIntegrationConfigSchema as E,StripeIntegrationConfigSchema as x,UpsertResendIntegrationConfigSchema as z,UpsertStripeIntegrationConfigSchema as k}from"./integration.schema";import{getStoredResendConfig as R,normalizeEmail as b,normalizeSecret as v,normalizeStripePaymentMethods as C,parseResendStoredConfig as y,parseStripeStoredConfig as w}from"./integration-config";class U{constructor(e,i,n,t){this.prisma=e,this.integrationRegistry=i,this.emailService=n,this.stripeService=t}sanitizeConfig(e,i){var n;switch(e){case"stripe":{const t=w(i);return x.parse({paymentMethods:(n=t?.paymentMethods)!==null&&n!==void 0?n:[],hasSecretKey:!!t?.secretKey,hasWebhookSecret:!!t?.webhookSecret})}case"resend":{const t=y(i);return E.parse({hasApiKey:!!t?.apiKey,fromEmail:t?.fromEmail})}default:return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}}sanitizeIntegration(e){return S.parse(Object.assign(Object.assign({},e),{config:this.sanitizeConfig(e.type,e.config)}))}ensureOrganizationExists(e){return c(this,void 0,void 0,function*(){if(!(yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0}})))throw new o(404,"Organization not found")})}validateConfig(e,i,n){var t,r,a,l,g,f,m,p;switch(e){case"stripe":{const d=k.safeParse(i);if(!d.success)throw new o(400,(r=(t=d.error.issues[0])===null||t===void 0?void 0:t.message)!==null&&r!==void 0?r:"Invalid Stripe configuration");const s=w(n),u=(a=v(d.data.secretKey))!==null&&a!==void 0?a:s?.secretKey,h=(l=v(d.data.webhookSecret))!==null&&l!==void 0?l:s?.webhookSecret;if(!u)throw new o(400,"Stripe API key is required");if(!h)throw new o(400,"Stripe webhook secret is required");return{paymentMethods:C(d.data.paymentMethods),secretKey:u,webhookSecret:h}}case"resend":{const d=z.safeParse(i);if(!d.success)throw new o(400,(f=(g=d.error.issues[0])===null||g===void 0?void 0:g.message)!==null&&f!==void 0?f:"Invalid Resend configuration");const s=y(n),u=(m=v(d.data.apiKey))!==null&&m!==void 0?m:s?.apiKey,h=(p=b(d.data.fromEmail))!==null&&p!==void 0?p:s?.fromEmail;if(!u)throw new o(400,"Resend API key is required");if(!h)throw new o(400,"Resend sender email is required");return{apiKey:u,fromEmail:h}}default:throw new o(400,`Unsupported integration type: ${e}`)}}getIntegrations(e){return c(this,void 0,void 0,function*(){return yield this.ensureOrganizationExists(e),this.integrationRegistry.list(e).map(n=>this.sanitizeIntegration(n))})}upsertIntegration(e,i,n,t){return c(this,void 0,void 0,function*(){yield this.ensureOrganizationExists(e);const r=this.integrationRegistry.get(e,i),a=this.validateConfig(i,t.config,r?.config),l=yield this.prisma.integration.upsert({where:{organizationId_type:{organizationId:e,type:i}},update:{config:a,updatedBy:n},create:{organization:{connect:{id:e}},type:i,config:a,createdBy:n,updatedBy:n}});return this.integrationRegistry.upsert(l),this.sanitizeIntegration(l)})}deleteIntegration(e,i){return c(this,void 0,void 0,function*(){if(yield this.ensureOrganizationExists(e),(yield this.prisma.integration.deleteMany({where:{organizationId:e,type:i}})).count===0)throw new o(404,"Integration not found");this.integrationRegistry.delete(e,i)})}sendTestEmail(e,i){return c(this,void 0,void 0,function*(){const n=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,email:!0}});if(!n)throw new o(404,"Organization not found");const t=this.integrationRegistry.get(e,"resend"),r=R(t);if(!r?.apiKey)throw new o(400,"Resend API key is not configured. Save the integration first.");if(!r.fromEmail)throw new o(400,"Sender email is not configured. Save the integration first.");try{return yield this.emailService.sendEmail(e,{from:`${n.name} <${r.fromEmail}>`,to:[i],subject:`Test Email from ${n.name}`,html:[`<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 560px; margin: 0 auto; padding: 40px 20px;">`,'<h1 style="font-size: 20px; font-weight: 600; color: #111827; margin: 0 0 16px;">Email integration is working</h1>','<p style="font-size: 14px; line-height: 1.6; color: #6b7280; margin: 0 0 24px;">',`This is a test email sent from <strong style="color: #111827;">${n.name}</strong> to verify that your Resend integration is configured correctly.`,"</p>",'<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 24px 0;" />','<p style="font-size: 12px; color: #9ca3af; margin: 0;">',`Sent via Shophost &middot; Sender: ${r.fromEmail}`,"</p>","</div>"].join("")}),{success:!0,message:`Test email sent to ${i}`}}catch(a){const l=a instanceof Error?a.message:"Unknown error";throw new o(500,`Failed to send test email: ${l}`)}})}createStripeTestCheckout(e,i,n){return c(this,void 0,void 0,function*(){const t=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,configuration:{select:{defaultCurrency:!0}}}});if(!t)throw new o(404,"Organization not found");try{const r=yield this.stripeService.createTestCheckoutSession(e,{cancelUrl:n,customerEmail:i,defaultCurrency:t.configuration.defaultCurrency,organizationName:t.name,successUrl:n});if(!r.url)throw new o(500,"Stripe did not return a checkout URL for the test session.");return{redirectUrl:r.url}}catch(r){if(r instanceof o)throw r;const a=r instanceof Error?r.message:"Unknown error";throw new o(500,`Failed to create Stripe test checkout: ${a}`)}})}}export{U as IntegrationService};
1
+ import{__awaiter as c}from"tslib";import{HttpException as o}from"../../core/exceptions/http-exception";import{getStoredResendConfig as S,normalizeEmail as E,normalizeSecret as v,normalizeStripePaymentMethods as x,parseResendStoredConfig as y,parseStripeStoredConfig as w}from"./integration-config";import{IntegrationSchema as z,ResendIntegrationConfigSchema as k,StripeIntegrationConfigSchema as R,UpsertResendIntegrationConfigSchema as b,UpsertStripeIntegrationConfigSchema as C}from"./integration.schema";class U{constructor(e,i,n,t){this.prisma=e,this.integrationRegistry=i,this.emailService=n,this.stripeService=t}sanitizeConfig(e,i){var n;switch(e){case"stripe":{const t=w(i);return R.parse({paymentMethods:(n=t?.paymentMethods)!==null&&n!==void 0?n:[],hasSecretKey:!!t?.secretKey,hasWebhookSecret:!!t?.webhookSecret})}case"resend":{const t=y(i);return k.parse({hasApiKey:!!t?.apiKey,fromEmail:t?.fromEmail})}default:return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}}sanitizeIntegration(e){return z.parse(Object.assign(Object.assign({},e),{config:this.sanitizeConfig(e.type,e.config)}))}ensureOrganizationExists(e){return c(this,void 0,void 0,function*(){if(!(yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0}})))throw new o(404,"Organization not found")})}validateConfig(e,i,n){var t,r,a,l,g,f,m,p;switch(e){case"stripe":{const d=C.safeParse(i);if(!d.success)throw new o(400,(r=(t=d.error.issues[0])===null||t===void 0?void 0:t.message)!==null&&r!==void 0?r:"Invalid Stripe configuration");const s=w(n),u=(a=v(d.data.secretKey))!==null&&a!==void 0?a:s?.secretKey,h=(l=v(d.data.webhookSecret))!==null&&l!==void 0?l:s?.webhookSecret;if(!u)throw new o(400,"Stripe API key is required");if(!h)throw new o(400,"Stripe webhook secret is required");return{paymentMethods:x(d.data.paymentMethods),secretKey:u,webhookSecret:h}}case"resend":{const d=b.safeParse(i);if(!d.success)throw new o(400,(f=(g=d.error.issues[0])===null||g===void 0?void 0:g.message)!==null&&f!==void 0?f:"Invalid Resend configuration");const s=y(n),u=(m=v(d.data.apiKey))!==null&&m!==void 0?m:s?.apiKey,h=(p=E(d.data.fromEmail))!==null&&p!==void 0?p:s?.fromEmail;if(!u)throw new o(400,"Resend API key is required");if(!h)throw new o(400,"Resend sender email is required");return{apiKey:u,fromEmail:h}}default:throw new o(400,`Unsupported integration type: ${e}`)}}getIntegrations(e){return c(this,void 0,void 0,function*(){return yield this.ensureOrganizationExists(e),this.integrationRegistry.list(e).map(n=>this.sanitizeIntegration(n))})}upsertIntegration(e,i,n,t){return c(this,void 0,void 0,function*(){yield this.ensureOrganizationExists(e);const r=this.integrationRegistry.get(e,i),a=this.validateConfig(i,t.config,r?.config),l=yield this.prisma.integration.upsert({where:{organizationId_type:{organizationId:e,type:i}},update:{config:a,updatedBy:n},create:{organization:{connect:{id:e}},type:i,config:a,createdBy:n,updatedBy:n}});return this.integrationRegistry.upsert(l),this.sanitizeIntegration(l)})}deleteIntegration(e,i){return c(this,void 0,void 0,function*(){if(yield this.ensureOrganizationExists(e),(yield this.prisma.integration.deleteMany({where:{organizationId:e,type:i}})).count===0)throw new o(404,"Integration not found");this.integrationRegistry.delete(e,i)})}sendTestEmail(e,i){return c(this,void 0,void 0,function*(){const n=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,email:!0}});if(!n)throw new o(404,"Organization not found");const t=this.integrationRegistry.get(e,"resend"),r=S(t);if(!r?.apiKey)throw new o(400,"Resend API key is not configured. Save the integration first.");if(!r.fromEmail)throw new o(400,"Sender email is not configured. Save the integration first.");try{return yield this.emailService.sendEmail(e,{from:`${n.name} <${r.fromEmail}>`,to:[i],subject:`Test Email from ${n.name}`,html:[`<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 560px; margin: 0 auto; padding: 40px 20px;">`,'<h1 style="font-size: 20px; font-weight: 600; color: #111827; margin: 0 0 16px;">Email integration is working</h1>','<p style="font-size: 14px; line-height: 1.6; color: #6b7280; margin: 0 0 24px;">',`This is a test email sent from <strong style="color: #111827;">${n.name}</strong> to verify that your Resend integration is configured correctly.`,"</p>",'<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 24px 0;" />','<p style="font-size: 12px; color: #9ca3af; margin: 0;">',`Sent via Shophost &middot; Sender: ${r.fromEmail}`,"</p>","</div>"].join("")}),{success:!0,message:`Test email sent to ${i}`}}catch(a){const l=a instanceof Error?a.message:"Unknown error";throw new o(500,`Failed to send test email: ${l}`)}})}createStripeTestCheckout(e,i,n){return c(this,void 0,void 0,function*(){const t=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,configuration:{select:{defaultCurrency:!0}}}});if(!t)throw new o(404,"Organization not found");try{const r=yield this.stripeService.createTestCheckoutSession(e,{cancelUrl:n,customerEmail:i,defaultCurrency:t.configuration.defaultCurrency,organizationName:t.name,successUrl:n});if(!r.url)throw new o(500,"Stripe did not return a checkout URL for the test session.");return{redirectUrl:r.url}}catch(r){if(r instanceof o)throw r;const a=r instanceof Error?r.message:"Unknown error";throw new o(500,`Failed to create Stripe test checkout: ${a}`)}})}}export{U as IntegrationService};
@@ -1 +1 @@
1
- import{__awaiter as l}from"tslib";import{logger as n}from"../../core/logging/pino";class s{constructor(i,e){this.inventoryService=i,this.orderService=e}fulfillPaidOrder(i,e){return l(this,void 0,void 0,function*(){var r,o;n.info({orderId:i,userId:e},"Starting paid order fulfillment");const t=yield this.inventoryService.processPaidOrderInventory(i);return n.info({conflictItems:(o=(r=t.conflictItems)===null||r===void 0?void 0:r.length)!==null&&o!==void 0?o:0,orderId:i,status:t.status},"Processed paid order inventory"),t.status==="conflict"||(n.info({orderId:i,userId:e},"Sending order notifications after payment fulfillment"),yield this.orderService.sendOrderNotifications(i,e),n.info({orderId:i,status:t.status},"Completed paid order fulfillment")),t})}}export{s as OrderFulfillmentService};
1
+ import{__awaiter as t}from"tslib";class n{constructor(e,r){this.inventoryService=e,this.orderService=r}fulfillPaidOrder(e,r){return t(this,void 0,void 0,function*(){const i=yield this.inventoryService.processPaidOrderInventory(e);return i.status!=="deducted"||(yield this.orderService.sendOrderNotifications(e,r)),i})}}export{n as OrderFulfillmentService};
@@ -1 +1 @@
1
- import{__awaiter as s}from"tslib";import{createApiRouter as l}from"../../core/hono/hono";import{orderRoute as u}from"./order.route";import{OrderInventoryConflictError as v}from"./order.service";export const registerOrderHandlers=i=>{const n=l();return n.openapi(u.createOrder,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param"),o=r.req.valid("json"),a=yield e.getCurrentUser();try{const{order:d,redirectUrl:p}=yield i.createOrder(t.organizationId,a,o);return r.json({order:d,redirectUrl:p},201)}catch(d){if(d instanceof v)return r.json(d.payload,409);throw d}})),n.openapi(u.getMyOrders,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param"),o=r.req.valid("query"),a=yield e.getCurrentUser(),d=yield i.getMyOrders(a.id,t.organizationId,o);return r.json(d,200)})),n.openapi(u.getOrder,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param"),o=yield e.getCurrentUser(),a=yield i.getOrder(o,t.organizationId,t.id);return r.json(a,200)})),n.openapi(u.getOrders,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param"),o=r.req.valid("query");yield e.isGranted("read");const a=yield i.getOrders(t.organizationId,o);return r.json(a,200)})),n.openapi(u.updateStatus,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param");yield e.isGranted("update");const o=yield i.updateStatus(t.organizationId,t.id,t.operation);return r.json(o,200)})),n.openapi(u.deleteOrder,r=>s(void 0,void 0,void 0,function*(){const e=r.get("auth"),t=r.req.valid("param"),o=yield e.isGranted("delete");return yield i.deleteOrder(t.organizationId,t.id,o.id),r.body(null,204)})),n};
1
+ import{__awaiter as i}from"tslib";import{createApiRouter as c}from"../../core/hono/hono";import{orderRoute as s}from"./order.route";import{OrderInventoryConflictError as y}from"./order.service";export const registerOrderHandlers=d=>{const a=c();return a.openapi(s.createOrder,r=>i(void 0,void 0,void 0,function*(){var t;const e=r.get("auth"),o=r.req.valid("param"),n=r.req.valid("json"),l=r.req.valid("query"),p=yield e.getCurrentUser(),g=(t=r.req.raw.headers.get("accept-language"))!==null&&t!==void 0?t:void 0;try{const{order:u,redirectUrl:v}=yield d.createOrder(o.organizationId,p,n,{acceptLanguage:g,locale:l.locale||void 0});return r.json({order:u,redirectUrl:v},201)}catch(u){if(u instanceof y)return r.json(u.payload,409);throw u}})),a.openapi(s.getMyOrders,r=>i(void 0,void 0,void 0,function*(){const t=r.get("auth"),e=r.req.valid("param"),o=r.req.valid("query"),n=yield t.getCurrentUser(),l=yield d.getMyOrders(n.id,e.organizationId,o);return r.json(l,200)})),a.openapi(s.getOrder,r=>i(void 0,void 0,void 0,function*(){const t=r.get("auth"),e=r.req.valid("param"),o=yield t.getCurrentUser(),n=yield d.getOrder(o,e.organizationId,e.id);return r.json(n,200)})),a.openapi(s.getOrders,r=>i(void 0,void 0,void 0,function*(){const t=r.get("auth"),e=r.req.valid("param"),o=r.req.valid("query");yield t.isGranted("read");const n=yield d.getOrders(e.organizationId,o);return r.json(n,200)})),a.openapi(s.updateStatus,r=>i(void 0,void 0,void 0,function*(){const t=r.get("auth"),e=r.req.valid("param");yield t.isGranted("update");const o=yield d.updateStatus(e.organizationId,e.id,e.operation);return r.json(o,200)})),a.openapi(s.deleteOrder,r=>i(void 0,void 0,void 0,function*(){const t=r.get("auth"),e=r.req.valid("param"),o=yield t.isGranted("delete");return yield d.deleteOrder(e.organizationId,e.id,o.id),r.body(null,204)})),a};