@shophost/rest-api 2.0.34 → 2.0.36

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 (220) hide show
  1. package/LICENSE +17 -13
  2. package/README.md +76 -66
  3. package/package.json +2 -2
  4. package/scripts/minify-dist.mjs +45 -0
  5. package/src/app.js +1 -53
  6. package/src/app.js.map +1 -1
  7. package/src/core/auth/auth.schema.js +1 -41
  8. package/src/core/auth/auth.util.js +1 -44
  9. package/src/core/auth/better-auth.lib.js +1 -100
  10. package/src/core/auth/generate-password-hash.util.js +1 -30
  11. package/src/core/auth/headers.schema.js +1 -22
  12. package/src/core/auth/user.schema.js +1 -30
  13. package/src/core/db/__generated__/client/browser.js +1 -18
  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.js +769 -55
  18. package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +2 -2
  19. package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
  20. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
  21. package/src/core/db/__generated__/client/models/Account.d.ts +0 -5
  22. package/src/core/db/__generated__/client/models/Account.js +1 -2
  23. package/src/core/db/__generated__/client/models/Address.d.ts +0 -5
  24. package/src/core/db/__generated__/client/models/Address.js +1 -2
  25. package/src/core/db/__generated__/client/models/Campaign.d.ts +0 -5
  26. package/src/core/db/__generated__/client/models/Campaign.js +1 -2
  27. package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +0 -5
  28. package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
  29. package/src/core/db/__generated__/client/models/File.d.ts +0 -5
  30. package/src/core/db/__generated__/client/models/File.js +1 -2
  31. package/src/core/db/__generated__/client/models/Invitation.d.ts +0 -5
  32. package/src/core/db/__generated__/client/models/Invitation.js +1 -2
  33. package/src/core/db/__generated__/client/models/LegalEntity.d.ts +0 -5
  34. package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
  35. package/src/core/db/__generated__/client/models/Manufacturer.d.ts +0 -5
  36. package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
  37. package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +0 -5
  38. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
  39. package/src/core/db/__generated__/client/models/Member.d.ts +0 -5
  40. package/src/core/db/__generated__/client/models/Member.js +1 -2
  41. package/src/core/db/__generated__/client/models/Modifier.d.ts +0 -5
  42. package/src/core/db/__generated__/client/models/Modifier.js +1 -2
  43. package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +0 -5
  44. package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
  45. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +0 -5
  46. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
  47. package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +0 -5
  48. package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
  49. package/src/core/db/__generated__/client/models/Order.d.ts +0 -5
  50. package/src/core/db/__generated__/client/models/Order.js +1 -2
  51. package/src/core/db/__generated__/client/models/OrderItem.d.ts +0 -5
  52. package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
  53. package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +0 -5
  54. package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
  55. package/src/core/db/__generated__/client/models/Organization.d.ts +0 -5
  56. package/src/core/db/__generated__/client/models/Organization.js +1 -2
  57. package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +0 -5
  58. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
  59. package/src/core/db/__generated__/client/models/Payment.d.ts +0 -5
  60. package/src/core/db/__generated__/client/models/Payment.js +1 -2
  61. package/src/core/db/__generated__/client/models/PaymentSession.d.ts +0 -5
  62. package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
  63. package/src/core/db/__generated__/client/models/Product.d.ts +0 -5
  64. package/src/core/db/__generated__/client/models/Product.js +1 -2
  65. package/src/core/db/__generated__/client/models/ProductCategory.d.ts +0 -5
  66. package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
  67. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +0 -5
  68. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
  69. package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +0 -5
  70. package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
  71. package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +0 -5
  72. package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
  73. package/src/core/db/__generated__/client/models/Reservation.d.ts +0 -5
  74. package/src/core/db/__generated__/client/models/Reservation.js +1 -2
  75. package/src/core/db/__generated__/client/models/Session.d.ts +0 -5
  76. package/src/core/db/__generated__/client/models/Session.js +1 -2
  77. package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +0 -5
  78. package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
  79. package/src/core/db/__generated__/client/models/ShippingZone.d.ts +0 -5
  80. package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
  81. package/src/core/db/__generated__/client/models/User.d.ts +0 -5
  82. package/src/core/db/__generated__/client/models/User.js +1 -2
  83. package/src/core/db/__generated__/client/models/Verification.d.ts +0 -5
  84. package/src/core/db/__generated__/client/models/Verification.js +1 -2
  85. package/src/core/db/__generated__/client/models.js +1 -2
  86. package/src/core/db/index.js +1 -2
  87. package/src/core/email/components.d.ts +16 -0
  88. package/src/core/email/components.js +1 -0
  89. package/src/core/email/components.js.map +1 -0
  90. package/src/core/exceptions/http-exception.js +1 -9
  91. package/src/core/hono/hono.js +1 -123
  92. package/src/core/lib/prisma.d.ts +8 -8
  93. package/src/core/lib/prisma.js +1 -11
  94. package/src/core/logging/pino.js +1 -5
  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.js +1 -39
  101. package/src/core/utils/translations.util.js +0 -1
  102. package/src/core/utils/zod.util.js +1 -85
  103. package/src/db.js +1 -3
  104. package/src/features/access/access.handler.js +1 -91
  105. package/src/features/access/access.route.js +1 -220
  106. package/src/features/access/access.schema.js +1 -108
  107. package/src/features/access/access.service.js +1 -294
  108. package/src/features/analytics/analytics.handler.d.ts +2 -0
  109. package/src/features/analytics/analytics.handler.js +1 -0
  110. package/src/features/analytics/analytics.handler.js.map +1 -0
  111. package/src/features/analytics/analytics.route.d.ts +3 -0
  112. package/src/features/analytics/analytics.route.js +1 -0
  113. package/src/features/analytics/analytics.route.js.map +1 -0
  114. package/src/features/analytics/analytics.schema.d.ts +86 -0
  115. package/src/features/analytics/analytics.schema.js +1 -0
  116. package/src/features/analytics/analytics.schema.js.map +1 -0
  117. package/src/features/analytics/analytics.service.d.ts +45 -0
  118. package/src/features/analytics/analytics.service.js +1 -0
  119. package/src/features/analytics/analytics.service.js.map +1 -0
  120. package/src/features/cart/cart.handler.js +1 -17
  121. package/src/features/cart/cart.route.js +1 -32
  122. package/src/features/cart/cart.schema.d.ts +1 -1
  123. package/src/features/cart/cart.schema.js +1 -39
  124. package/src/features/cart/cart.service.d.ts +1 -1
  125. package/src/features/cart/cart.service.js +1 -97
  126. package/src/features/cart/cart.util.js +1 -76
  127. package/src/features/file/file.handler.js +1 -23
  128. package/src/features/file/file.route.js +1 -34
  129. package/src/features/file/file.schema.js +1 -77
  130. package/src/features/file/file.service.js +1 -66
  131. package/src/features/health/health.handler.js +1 -10
  132. package/src/features/health/health.route.js +1 -25
  133. package/src/features/index.d.ts +1 -0
  134. package/src/features/index.js +1 -16
  135. package/src/features/index.js.map +1 -1
  136. package/src/features/location/location.handler.js +1 -25
  137. package/src/features/location/location.route.js +1 -56
  138. package/src/features/location/location.schema.js +1 -50
  139. package/src/features/location/location.service.js +1 -141
  140. package/src/features/manufacturer/manufacturer.handler.js +1 -53
  141. package/src/features/manufacturer/manufacturer.route.js +1 -97
  142. package/src/features/manufacturer/manufacturer.schema.js +1 -125
  143. package/src/features/manufacturer/manufacturer.service.js +1 -190
  144. package/src/features/order/emails/order-confirmation.email.js +1 -229
  145. package/src/features/order/emails/order-confirmation.email.js.map +1 -1
  146. package/src/features/order/emails/order-notification.email.js +1 -229
  147. package/src/features/order/emails/order-notification.email.js.map +1 -1
  148. package/src/features/order/fulfilment.schema.js +1 -3
  149. package/src/features/order/order.handler.js +1 -54
  150. package/src/features/order/order.route.js +1 -111
  151. package/src/features/order/order.schema.d.ts +4 -4
  152. package/src/features/order/order.schema.js +1 -158
  153. package/src/features/order/order.service.d.ts +4 -4
  154. package/src/features/order/order.service.js +1 -306
  155. package/src/features/order/recipient.schema.js +1 -38
  156. package/src/features/organization/legal-entity.schema.js +1 -83
  157. package/src/features/organization/organization-configuration.schema.js +1 -115
  158. package/src/features/organization/organization.handler.js +1 -48
  159. package/src/features/organization/organization.route.js +1 -84
  160. package/src/features/organization/organization.schema.js +1 -64
  161. package/src/features/organization/organization.service.js +1 -334
  162. package/src/features/payment/payment.handler.js +1 -16
  163. package/src/features/payment/payment.route.js +1 -22
  164. package/src/features/payment/payment.schema.d.ts +3 -3
  165. package/src/features/payment/payment.schema.js +1 -46
  166. package/src/features/payment/payment.service.d.ts +1 -1
  167. package/src/features/payment/payment.service.js +1 -100
  168. package/src/features/payment/stripe.service.js +1 -164
  169. package/src/features/product/product-modifier.schema.js +1 -84
  170. package/src/features/product/product.handler.js +1 -87
  171. package/src/features/product/product.route.js +1 -179
  172. package/src/features/product/product.schema.d.ts +3 -3
  173. package/src/features/product/product.schema.js +1 -143
  174. package/src/features/product/product.service.d.ts +2 -2
  175. package/src/features/product/product.service.js +1 -440
  176. package/src/features/product-category/product-category.handler.js +1 -59
  177. package/src/features/product-category/product-category.route.js +1 -139
  178. package/src/features/product-category/product-category.schema.js +1 -86
  179. package/src/features/product-category/product-category.service.js +1 -220
  180. package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
  181. package/src/features/reservation/emails/reservation-cancellation.email.js.map +1 -1
  182. package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
  183. package/src/features/reservation/emails/reservation-confirmation.email.js.map +1 -1
  184. package/src/features/reservation/emails/reservation-notification.email.js +1 -93
  185. package/src/features/reservation/emails/reservation-notification.email.js.map +1 -1
  186. package/src/features/reservation/reservation.handler.js +1 -65
  187. package/src/features/reservation/reservation.route.js +1 -167
  188. package/src/features/reservation/reservation.schema.d.ts +1 -1
  189. package/src/features/reservation/reservation.schema.js +1 -51
  190. package/src/features/reservation/reservation.service.js +1 -231
  191. package/src/features/shipping/shipping.handler.js +1 -32
  192. package/src/features/shipping/shipping.route.js +1 -51
  193. package/src/features/shipping/shipping.service.js +1 -96
  194. package/src/features/shipping-method/shipping-method.handler.js +1 -60
  195. package/src/features/shipping-method/shipping-method.route.js +1 -144
  196. package/src/features/shipping-method/shipping-method.schema.js +1 -48
  197. package/src/features/shipping-method/shipping-method.service.js +1 -229
  198. package/src/features/shipping-method/shipping-zone.schema.js +1 -31
  199. package/src/features/webhook/webhook.handler.js +1 -50
  200. package/src/features/webhook/webhook.route.js +1 -33
  201. package/src/index.js +1 -6
  202. package/src/integrations/next.js +1 -82
  203. package/src/schemas/address.schema.js +1 -112
  204. package/src/schemas/currency.schema.js +1 -118
  205. package/src/schemas/error.schema.js +1 -12
  206. package/src/schemas/index.d.ts +1 -0
  207. package/src/schemas/index.js +1 -29
  208. package/src/schemas/index.js.map +1 -1
  209. package/src/schemas/locales.schema.js +1 -238
  210. package/src/schemas/number.schema.js +1 -29
  211. package/src/schemas/pagination.schema.js +1 -54
  212. package/src/schemas/params.schema.js +1 -20
  213. package/src/schemas/queries.schema.js +1 -6
  214. package/src/test/global-setup.js +1 -37
  215. package/src/test/integration/api-fixtures.js +1 -160
  216. package/src/test/integration/seed.js +1 -368
  217. package/src/test/integration/test-helpers.d.ts +2 -0
  218. package/src/test/integration/test-helpers.js +1 -154
  219. package/src/test/integration/test-helpers.js.map +1 -1
  220. package/src/test/setup-test-env.js +1 -7
@@ -1,158 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { AddressSchema } from "../../schemas/address.schema";
3
- import { currency } from "../../schemas/currency.schema";
4
- import { locale } from "../../schemas/locales.schema";
5
- import { CartItemSchema, CartSchema } from "../cart/cart.schema";
6
- import { FileSchema } from "../file/file.schema";
7
- import { PaymentMethodSchema, PaymentProviderSchema, PaymentSchema, } from "../payment/payment.schema";
8
- import { ShippingMethodSchema } from "../shipping-method/shipping-method.schema";
9
- import { fulfilmentMethod } from "./fulfilment.schema";
10
- export const OrderStatusSchema = z
11
- .enum([
12
- "draft",
13
- "pending",
14
- "accepted",
15
- "ready-for-dispatch",
16
- "dispatched",
17
- "completed",
18
- "cancelled",
19
- ])
20
- .openapi({
21
- description: "Status of the order",
22
- example: "accepted",
23
- });
24
- export const OrderItemSchema = z
25
- .object({
26
- translations: z
27
- .array(z.object({
28
- locale: locale.openapi({
29
- description: "Locale of the translation",
30
- example: "en-US",
31
- }),
32
- title: z.string().openapi({
33
- description: "Title of the ordered product",
34
- example: "Premium Watch",
35
- }),
36
- subtitle: z.string().openapi({
37
- description: "Additional details about the ordered item, including modifiers",
38
- example: "Color: Silver, Size: Large",
39
- }),
40
- }))
41
- .openapi({
42
- description: "Translations for the order item",
43
- }),
44
- rawData: CartItemSchema,
45
- unitPrice: z.number().min(0).openapi({
46
- description: "Price per unit of the item",
47
- example: 299.99,
48
- }),
49
- image: FileSchema.nullable().optional(),
50
- totalPrice: z.number().min(0).openapi({
51
- description: "Total price for this item (unitPrice × quantity)",
52
- example: 599.98,
53
- }),
54
- quantity: z.number().min(1).openapi({
55
- description: "Number of units ordered",
56
- example: 2,
57
- }),
58
- productSnapshotId: z.string().cuid(),
59
- })
60
- .openapi("OrderItem");
61
- export const OrderSchema = z
62
- .object({
63
- id: z.string().openapi({
64
- description: "Unique identifier for the order",
65
- example: "clj1234567890abcdef",
66
- }),
67
- referenceId: z.string().openapi({
68
- description: "External reference ID for the order",
69
- example: "ORD-12345",
70
- }),
71
- status: OrderStatusSchema.optional(),
72
- token: z.string().openapi({
73
- description: "Security token for order verification",
74
- example: "a1b2c3d4e5f6g7h8i9j0",
75
- }),
76
- expiresAt: z.date().openapi({
77
- description: "Expiration date for the order",
78
- example: "2023-12-31T23:59:59Z",
79
- }),
80
- items: z.array(OrderItemSchema).min(1).openapi({
81
- description: "Array of items in the order",
82
- }),
83
- shippingMethod: ShippingMethodSchema.nullable().openapi({
84
- description: "Shipping method selected for the order",
85
- }),
86
- acceptedAt: z.date().nullable().optional().openapi({
87
- description: "Date when the order was accepted",
88
- example: "2023-06-15T14:30:00Z",
89
- }),
90
- dispatchedAt: z.date().nullable().optional().openapi({
91
- description: "Date when the order was dispatched",
92
- example: "2023-06-16T09:15:00Z",
93
- }),
94
- readyForDispatchAt: z.date().nullable().optional().openapi({
95
- description: "Date when the order was ready for dispatch",
96
- example: "2023-06-16T09:15:00Z",
97
- }),
98
- createdAt: z.date().openapi({
99
- description: "Date when the order was created",
100
- example: "2023-06-15T14:30:00Z",
101
- }),
102
- completedAt: z.date().nullable().optional().openapi({
103
- description: "Date when the order was completed",
104
- example: "2023-06-18T11:45:00Z",
105
- }),
106
- cancelledAt: z.date().nullable().optional().openapi({
107
- description: "Date when the order was cancelled",
108
- example: "2023-06-14T16:20:00Z",
109
- }),
110
- shippingAddress: AddressSchema.nullable().optional(),
111
- fulfilmentMethod: fulfilmentMethod.openapi({
112
- description: "Method of order fulfilment (pickup or delivery)",
113
- example: "delivery",
114
- }),
115
- currency: currency.openapi({
116
- description: "Currency used for the order",
117
- example: "USD",
118
- }),
119
- payment: PaymentSchema,
120
- })
121
- .transform((order) => {
122
- let status;
123
- if (order.cancelledAt) {
124
- status = "cancelled";
125
- }
126
- else if (order.completedAt) {
127
- status = "completed";
128
- }
129
- else if (order.dispatchedAt) {
130
- status = "dispatched";
131
- }
132
- else if (order.readyForDispatchAt) {
133
- status = "ready-for-dispatch";
134
- }
135
- else if (order.acceptedAt) {
136
- status = "accepted";
137
- }
138
- else {
139
- status = "pending";
140
- }
141
- return Object.assign(Object.assign({}, order), { status });
142
- })
143
- .openapi("Order");
144
- export const CreateOrderSchema = CartSchema.extend({
145
- fulfilmentMethod: fulfilmentMethod.default("delivery"),
146
- payment: z.object({
147
- provider: PaymentProviderSchema,
148
- method: PaymentMethodSchema,
149
- }),
150
- checkoutBaseUrl: z.string().url(),
151
- })
152
- .refine((data) => data.fulfilmentMethod !== "delivery" ||
153
- data.shippingMethodId !== undefined, {
154
- message: "shippingMethodId is required when fulfilmentMethod is 'delivery'",
155
- path: ["shippingMethodId"],
156
- })
157
- .openapi("CreateOrder");
158
- //# sourceMappingURL=order.schema.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{AddressSchema as a}from"../../schemas/address.schema";import{currency as o}from"../../schemas/currency.schema";import{locale as p}from"../../schemas/locales.schema";import{CartItemSchema as n,CartSchema as d}from"../cart/cart.schema";import{FileSchema as l}from"../file/file.schema";import{PaymentMethodSchema as c,PaymentProviderSchema as s,PaymentSchema as m}from"../payment/payment.schema";import{ShippingMethodSchema as h}from"../shipping-method/shipping-method.schema";import{fulfilmentMethod as r}from"./fulfilment.schema";export const OrderStatusSchema=e.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),OrderItemSchema=e.object({translations:e.array(e.object({locale:p.openapi({description:"Locale of the translation",example:"en-US"}),title:e.string().openapi({description:"Title of the ordered product",example:"Premium Watch"}),subtitle:e.string().openapi({description:"Additional details about the ordered item, including modifiers",example:"Color: Silver, Size: Large"})})).openapi({description:"Translations for the order item"}),rawData:n,unitPrice:e.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:l.nullable().optional(),totalPrice:e.number().min(0).openapi({description:"Total price for this item (unitPrice \xD7 quantity)",example:599.98}),quantity:e.number().min(1).openapi({description:"Number of units ordered",example:2}),productSnapshotId:e.string().cuid()}).openapi("OrderItem"),OrderSchema=e.object({id:e.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),referenceId:e.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),status:OrderStatusSchema.optional(),token:e.string().openapi({description:"Security token for order verification",example:"a1b2c3d4e5f6g7h8i9j0"}),expiresAt:e.date().openapi({description:"Expiration date for the order",example:"2023-12-31T23:59:59Z"}),items:e.array(OrderItemSchema).min(1).openapi({description:"Array of items in the order"}),shippingMethod:h.nullable().openapi({description:"Shipping method selected for the order"}),acceptedAt:e.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),dispatchedAt:e.date().nullable().optional().openapi({description:"Date when the order was dispatched",example:"2023-06-16T09:15:00Z"}),readyForDispatchAt:e.date().nullable().optional().openapi({description:"Date when the order was ready for dispatch",example:"2023-06-16T09:15:00Z"}),createdAt:e.date().openapi({description:"Date when the order was created",example:"2023-06-15T14:30:00Z"}),completedAt:e.date().nullable().optional().openapi({description:"Date when the order was completed",example:"2023-06-18T11:45:00Z"}),cancelledAt:e.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),shippingAddress:a.nullable().optional(),fulfilmentMethod:r.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:o.openapi({description:"Currency used for the order",example:"USD"}),payment:m}).transform(t=>{let i;return t.cancelledAt?i="cancelled":t.completedAt?i="completed":t.dispatchedAt?i="dispatched":t.readyForDispatchAt?i="ready-for-dispatch":t.acceptedAt?i="accepted":i="pending",Object.assign(Object.assign({},t),{status:i})}).openapi("Order"),CreateOrderSchema=d.extend({fulfilmentMethod:r.default("delivery"),payment:e.object({provider:s,method:c}),checkoutBaseUrl:e.string().url()}).refine(t=>t.fulfilmentMethod!=="delivery"||t.shippingMethodId!==void 0,{message:"shippingMethodId is required when fulfilmentMethod is 'delivery'",path:["shippingMethodId"]}).openapi("CreateOrder");
@@ -83,7 +83,7 @@ declare class OrderService {
83
83
  currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
84
84
  payment: {
85
85
  id: string;
86
- method: "card" | "blik" | "cash_on_delivery" | "paypal";
86
+ method: "card" | "blik" | "paypal" | "cash_on_delivery";
87
87
  provider: "stripe" | "revolut" | "payu" | "not_applicable";
88
88
  status: "pending" | "succeeded" | "refunded" | "failed" | "canceled";
89
89
  shipping: number;
@@ -187,7 +187,7 @@ declare class OrderService {
187
187
  currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
188
188
  payment: {
189
189
  id: string;
190
- method: "card" | "blik" | "cash_on_delivery" | "paypal";
190
+ method: "card" | "blik" | "paypal" | "cash_on_delivery";
191
191
  provider: "stripe" | "revolut" | "payu" | "not_applicable";
192
192
  status: "pending" | "succeeded" | "refunded" | "failed" | "canceled";
193
193
  shipping: number;
@@ -303,7 +303,7 @@ declare class OrderService {
303
303
  currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
304
304
  payment: {
305
305
  id: string;
306
- method: "card" | "blik" | "cash_on_delivery" | "paypal";
306
+ method: "card" | "blik" | "paypal" | "cash_on_delivery";
307
307
  provider: "stripe" | "revolut" | "payu" | "not_applicable";
308
308
  status: "pending" | "succeeded" | "refunded" | "failed" | "canceled";
309
309
  shipping: number;
@@ -411,7 +411,7 @@ declare class OrderService {
411
411
  currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
412
412
  payment: {
413
413
  id: string;
414
- method: "card" | "blik" | "cash_on_delivery" | "paypal";
414
+ method: "card" | "blik" | "paypal" | "cash_on_delivery";
415
415
  provider: "stripe" | "revolut" | "payu" | "not_applicable";
416
416
  status: "pending" | "succeeded" | "refunded" | "failed" | "canceled";
417
417
  shipping: number;
@@ -1,306 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { z } from "@hono/zod-openapi";
3
- import { customAlphabet } from "nanoid";
4
- import { HttpException } from "../../core/exceptions/http-exception";
5
- import { OrderSchema, PaginationMetaSchema, } from "../../schemas";
6
- import { transformCartItemToOrderItem } from "../cart/cart.util";
7
- import { PaymentService, } from "../payment/payment.service";
8
- const nanoid = customAlphabet("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
9
- class OrderService {
10
- constructor(prisma, paymentOptions) {
11
- this.prisma = prisma;
12
- this.paymentOptions = paymentOptions;
13
- this.paymentService = new PaymentService(prisma, paymentOptions);
14
- }
15
- /**
16
- * Create a draft order
17
- */
18
- createOrder(organizationId, user, body) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b, _c, _d, _e;
21
- const organization = yield this.prisma.organization.findFirst({
22
- where: {
23
- id: organizationId,
24
- },
25
- include: {
26
- configuration: true,
27
- },
28
- });
29
- if (!organization) {
30
- throw new HttpException(404, "Organization not found");
31
- }
32
- const shippingAddress = yield this.prisma.address.findFirst({
33
- where: {
34
- users: {
35
- some: {
36
- id: user.id,
37
- },
38
- },
39
- isDefault: true,
40
- },
41
- });
42
- if (body.fulfilmentMethod === "delivery" && !shippingAddress) {
43
- throw new HttpException(400, "This user does not have a default shipping address");
44
- }
45
- const items = yield Promise.all(body.items.map(transformCartItemToOrderItem(this.prisma)));
46
- const shippingMethod = yield this.prisma.shippingMethod.findFirst({
47
- where: {
48
- id: body.shippingMethodId,
49
- },
50
- include: {
51
- shippingZones: true,
52
- },
53
- });
54
- const shipping = (_b = (_a = shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.shippingZones[0]) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
55
- const subtotal = items.reduce((acc, item) => acc + item.totalPrice, 0);
56
- const total = subtotal + shipping;
57
- // Create the order
58
- const order = yield this.prisma.order.create({
59
- data: Object.assign(Object.assign({
60
- // TODO: add guest order flow
61
- token: nanoid(), referenceId: nanoid(), organization: {
62
- connect: {
63
- id: organizationId,
64
- },
65
- }, fulfilmentMethod: body.fulfilmentMethod, shippingMethod: body.shippingMethodId
66
- ? {
67
- connect: {
68
- id: body.shippingMethodId,
69
- },
70
- }
71
- : undefined, currency: organization.configuration.defaultCurrency,
72
- // TODO: add user IP address
73
- sourceIp: "127.0.0.1", items: {
74
- create: items,
75
- } }, (shippingAddress
76
- ? {
77
- shippingAddress: {
78
- create: Object.assign(Object.assign({}, shippingAddress), { id: undefined }),
79
- },
80
- }
81
- : {})), { user: {
82
- connect: {
83
- id: user.id,
84
- },
85
- }, payment: {
86
- create: {
87
- method: body.payment.method,
88
- provider: body.payment.provider,
89
- shipping: (_d = (_c = shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.shippingZones[0]) === null || _c === void 0 ? void 0 : _c.price) !== null && _d !== void 0 ? _d : 0,
90
- subtotal,
91
- total,
92
- discount: 0,
93
- currency: organization.configuration.defaultCurrency,
94
- },
95
- } }),
96
- include: {
97
- items: {
98
- include: {
99
- translations: true,
100
- image: true,
101
- },
102
- },
103
- payment: true,
104
- shippingMethod: {
105
- include: {
106
- shippingZones: true,
107
- },
108
- },
109
- },
110
- });
111
- const formattedOrder = OrderSchema.parse(order);
112
- const session = yield this.paymentService.createCheckoutSession(user, formattedOrder, {
113
- locale: "en",
114
- successUrl: `${body.checkoutBaseUrl}/account/orders/${order.id}?clearCart=true`,
115
- cancelUrl: `${body.checkoutBaseUrl}/checkout/shipping-and-payment`,
116
- });
117
- return {
118
- redirectUrl: (_e = session.redirectUrl) !== null && _e !== void 0 ? _e : undefined,
119
- order: OrderSchema.parse(order),
120
- };
121
- });
122
- }
123
- /**
124
- * Get a specific order by ID
125
- */
126
- getOrder(user, organizationId, orderId) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const order = yield this.prisma.order.findUnique({
129
- where: {
130
- id: orderId,
131
- organizationId: organizationId,
132
- deletedAt: null,
133
- user: {
134
- id: user.id,
135
- },
136
- },
137
- include: {
138
- items: {
139
- include: {
140
- translations: true,
141
- image: true,
142
- },
143
- },
144
- shippingAddress: true,
145
- shippingMethod: {
146
- include: {
147
- shippingZones: true,
148
- },
149
- },
150
- payment: true,
151
- },
152
- });
153
- if (!order) {
154
- throw new HttpException(404, "Order not found");
155
- }
156
- return OrderSchema.parse(order);
157
- });
158
- }
159
- /**
160
- * Get a paginated list of orders
161
- */
162
- getOrders(organizationId, query) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- const { page = 1, limit = 10 } = query;
165
- const [list, meta] = yield this.prisma.order
166
- .paginate({
167
- where: {
168
- organizationId: organizationId,
169
- deletedAt: null,
170
- },
171
- include: {
172
- items: {
173
- include: {
174
- translations: true,
175
- image: true,
176
- },
177
- },
178
- shippingAddress: true,
179
- shippingMethod: {
180
- include: {
181
- shippingZones: true,
182
- },
183
- },
184
- payment: true,
185
- },
186
- orderBy: {
187
- createdAt: "desc",
188
- },
189
- })
190
- .withPages({
191
- page,
192
- limit,
193
- });
194
- return {
195
- meta: PaginationMetaSchema.parse(meta),
196
- list: z.array(OrderSchema).parse(list),
197
- };
198
- });
199
- }
200
- /**
201
- * Delete an order (soft delete)
202
- */
203
- deleteOrder(organizationId, orderId, userId) {
204
- return __awaiter(this, void 0, void 0, function* () {
205
- const order = yield this.prisma.order.findUnique({
206
- where: {
207
- id: orderId,
208
- organizationId: organizationId,
209
- deletedAt: null,
210
- },
211
- });
212
- if (!order) {
213
- throw new HttpException(404, "Order not found");
214
- }
215
- yield this.prisma.order.update({
216
- where: {
217
- id: orderId,
218
- organizationId: organizationId,
219
- deletedAt: null,
220
- },
221
- data: {
222
- deletedAt: new Date(),
223
- deletedBy: userId,
224
- },
225
- });
226
- return;
227
- });
228
- }
229
- /**
230
- * Update order status
231
- */
232
- updateStatus(organizationId, orderId, operation) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- const order = yield this.prisma.order.findUnique({
235
- where: {
236
- id: orderId,
237
- organizationId: organizationId,
238
- deletedAt: null,
239
- },
240
- include: {
241
- items: true,
242
- shippingMethod: {
243
- include: {
244
- shippingZones: true,
245
- },
246
- },
247
- },
248
- });
249
- if (!order) {
250
- throw new HttpException(404, "Order not found");
251
- }
252
- let updateData = {};
253
- switch (operation) {
254
- case "accepted":
255
- updateData = {
256
- acceptedAt: new Date(),
257
- };
258
- break;
259
- case "ready-for-dispatch":
260
- updateData = {
261
- readyForDispatchAt: new Date(),
262
- };
263
- break;
264
- case "dispatched":
265
- updateData = {
266
- dispatchedAt: new Date(),
267
- };
268
- break;
269
- case "completed":
270
- updateData = {
271
- completedAt: new Date(),
272
- };
273
- break;
274
- case "cancelled":
275
- updateData = {
276
- cancelledAt: new Date(),
277
- };
278
- break;
279
- }
280
- const updatedOrder = yield this.prisma.order.update({
281
- where: {
282
- id: orderId,
283
- },
284
- data: updateData,
285
- include: {
286
- items: {
287
- include: {
288
- translations: true,
289
- image: true,
290
- },
291
- },
292
- shippingAddress: true,
293
- shippingMethod: {
294
- include: {
295
- shippingZones: true,
296
- },
297
- },
298
- payment: true,
299
- },
300
- });
301
- return OrderSchema.parse(updatedOrder);
302
- });
303
- }
304
- }
305
- export { OrderService };
306
- //# sourceMappingURL=order.service.js.map
1
+ import{__awaiter as o}from"tslib";import{z as k}from"@hono/zod-openapi";import{customAlphabet as D}from"nanoid";import{HttpException as a}from"../../core/exceptions/http-exception";import{OrderSchema as c,PaginationMetaSchema as U}from"../../schemas";import{transformCartItemToOrderItem as I}from"../cart/cart.util";import{PaymentService as S}from"../payment/payment.service";const v=D("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",6);class Z{constructor(t,i){this.prisma=t,this.paymentOptions=i,this.paymentService=new S(t,i)}createOrder(t,i,e){return o(this,void 0,void 0,function*(){var n,r,d,p,u;const l=yield this.prisma.organization.findFirst({where:{id:t},include:{configuration:!0}});if(!l)throw new a(404,"Organization not found");const h=yield this.prisma.address.findFirst({where:{users:{some:{id:i.id}},isDefault:!0}});if(e.fulfilmentMethod==="delivery"&&!h)throw new a(400,"This user does not have a default shipping address");const g=yield Promise.all(e.items.map(I(this.prisma))),s=yield this.prisma.shippingMethod.findFirst({where:{id:e.shippingMethodId},include:{shippingZones:!0}}),w=(r=(n=s?.shippingZones[0])===null||n===void 0?void 0:n.price)!==null&&r!==void 0?r:0,f=g.reduce((O,M)=>O+M.totalPrice,0),y=f+w,m=yield this.prisma.order.create({data:Object.assign(Object.assign({token:v(),referenceId:v(),organization:{connect:{id:t}},fulfilmentMethod:e.fulfilmentMethod,shippingMethod:e.shippingMethodId?{connect:{id:e.shippingMethodId}}:void 0,currency:l.configuration.defaultCurrency,sourceIp:"127.0.0.1",items:{create:g}},h?{shippingAddress:{create:Object.assign(Object.assign({},h),{id:void 0})}}:{}),{user:{connect:{id:i.id}},payment:{create:{method:e.payment.method,provider:e.payment.provider,shipping:(p=(d=s?.shippingZones[0])===null||d===void 0?void 0:d.price)!==null&&p!==void 0?p:0,subtotal:f,total:y,discount:0,currency:l.configuration.defaultCurrency}}}),include:{items:{include:{translations:!0,image:!0}},payment:!0,shippingMethod:{include:{shippingZones:!0}}}}),A=c.parse(m);return{redirectUrl:(u=(yield this.paymentService.createCheckoutSession(i,A,{locale:"en",successUrl:`${e.checkoutBaseUrl}/account/orders/${m.id}?clearCart=true`,cancelUrl:`${e.checkoutBaseUrl}/checkout/shipping-and-payment`})).redirectUrl)!==null&&u!==void 0?u:void 0,order:c.parse(m)}})}getOrder(t,i,e){return o(this,void 0,void 0,function*(){const n=yield this.prisma.order.findUnique({where:{id:e,organizationId:i,deletedAt:null,user:{id:t.id}},include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0}});if(!n)throw new a(404,"Order not found");return c.parse(n)})}getOrders(t,i){return o(this,void 0,void 0,function*(){const{page:e=1,limit:n=10}=i,[r,d]=yield this.prisma.order.paginate({where:{organizationId:t,deletedAt:null},include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0},orderBy:{createdAt:"desc"}}).withPages({page:e,limit:n});return{meta:U.parse(d),list:k.array(c).parse(r)}})}deleteOrder(t,i,e){return o(this,void 0,void 0,function*(){if(!(yield this.prisma.order.findUnique({where:{id:i,organizationId:t,deletedAt:null}})))throw new a(404,"Order not found");yield this.prisma.order.update({where:{id:i,organizationId:t,deletedAt:null},data:{deletedAt:new Date,deletedBy:e}})})}updateStatus(t,i,e){return o(this,void 0,void 0,function*(){if(!(yield this.prisma.order.findUnique({where:{id:i,organizationId:t,deletedAt:null},include:{items:!0,shippingMethod:{include:{shippingZones:!0}}}})))throw new a(404,"Order not found");let r={};switch(e){case"accepted":r={acceptedAt:new Date};break;case"ready-for-dispatch":r={readyForDispatchAt:new Date};break;case"dispatched":r={dispatchedAt:new Date};break;case"completed":r={completedAt:new Date};break;case"cancelled":r={cancelledAt:new Date};break}const d=yield this.prisma.order.update({where:{id:i},data:r,include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0}});return c.parse(d)})}}export{Z as OrderService};
@@ -1,38 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { AddressSchema, CreateAddressSchema, } from "../../schemas/address.schema";
3
- export const RecipientSchema = z
4
- .object({
5
- id: z.string().openapi({
6
- example: "clf9876543210abcdef",
7
- description: "ID of the customer",
8
- }),
9
- firstname: z.string().nullable().optional().openapi({
10
- example: "John Doe",
11
- description: "Name of the customer",
12
- }),
13
- email: z.string().nullable().optional().openapi({
14
- example: "john.doe@example.com",
15
- description: "Email of the customer",
16
- }),
17
- phone: z.string().nullable().optional().openapi({
18
- example: "+1234567890",
19
- description: "Phone number of the customer",
20
- }),
21
- address: AddressSchema.nullable().optional().openapi({
22
- description: "Address of the customer",
23
- }),
24
- createdAt: z.date(),
25
- updatedAt: z.date(),
26
- })
27
- .openapi("Customer");
28
- export const CreateRecipientSchema = RecipientSchema.pick({
29
- firstname: true,
30
- email: true,
31
- phone: true,
32
- })
33
- .extend({
34
- address: CreateAddressSchema,
35
- })
36
- .openapi("Customer");
37
- export const UpdateCustomerSchema = CreateRecipientSchema.partial().openapi("UpdateCustomer");
38
- //# sourceMappingURL=recipient.schema.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{AddressSchema as t,CreateAddressSchema as o}from"../../schemas/address.schema";export const RecipientSchema=e.object({id:e.string().openapi({example:"clf9876543210abcdef",description:"ID of the customer"}),firstname:e.string().nullable().optional().openapi({example:"John Doe",description:"Name of the customer"}),email:e.string().nullable().optional().openapi({example:"john.doe@example.com",description:"Email of the customer"}),phone:e.string().nullable().optional().openapi({example:"+1234567890",description:"Phone number of the customer"}),address:t.nullable().optional().openapi({description:"Address of the customer"}),createdAt:e.date(),updatedAt:e.date()}).openapi("Customer"),CreateRecipientSchema=RecipientSchema.pick({firstname:!0,email:!0,phone:!0}).extend({address:o}).openapi("Customer"),UpdateCustomerSchema=CreateRecipientSchema.partial().openapi("UpdateCustomer");
@@ -1,83 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { AddressSchema, CreateAddressSchema, UpdateAddressSchema, } from "../../schemas/address.schema";
3
- export const LegalEntitySchema = z
4
- .object({
5
- id: z.string().openapi({
6
- example: "clm1234567890abcdef",
7
- description: "The unique identifier of the legal entity",
8
- }),
9
- name: z.string().openapi({
10
- example: "Acme Corporation",
11
- description: "The name of the legal entity",
12
- }),
13
- taxId: z.string().min(2).max(20).openapi({
14
- example: "PL1234567890",
15
- description: "The TAX ID of the legal entity",
16
- }),
17
- email: z.string().email().nullable().openapi({
18
- example: "contact@acme.com",
19
- description: "The email of the legal entity",
20
- format: "email",
21
- }),
22
- phone: z.string().nullable().openapi({
23
- example: "+48123456789",
24
- description: "The phone number of the legal entity",
25
- }),
26
- createdAt: z.date().openapi({
27
- description: "The date and time when the legal entity was created",
28
- format: "date-time",
29
- }),
30
- address: AddressSchema.required().openapi({
31
- description: "The address of the legal entity",
32
- }),
33
- })
34
- .openapi("LegalEntity");
35
- export const CreateLegalEntitySchema = z
36
- .object({
37
- name: z.string().min(1, "Name is required").openapi({
38
- example: "Acme Corporation",
39
- description: "The name of the legal entity",
40
- }),
41
- taxId: z.string().min(2).max(20).openapi({
42
- example: "PL1234567890",
43
- description: "The TAX ID of the legal entity",
44
- }),
45
- email: z.string().email().optional().openapi({
46
- example: "contact@acme.com",
47
- description: "The email of the legal entity",
48
- format: "email",
49
- }),
50
- phone: z.string().optional().openapi({
51
- example: "+48123456789",
52
- description: "The phone number of the legal entity",
53
- }),
54
- address: CreateAddressSchema.required().openapi({
55
- description: "The address of the legal entity",
56
- }),
57
- })
58
- .openapi("CreateLegalEntity");
59
- export const UpdateLegalEntitySchema = z
60
- .object({
61
- name: z.string().min(1, "Name is required").optional().openapi({
62
- example: "Acme Corporation",
63
- description: "The name of the legal entity",
64
- }),
65
- taxId: z.string().min(2).max(20).openapi({
66
- example: "PL1234567890",
67
- description: "The TAX ID of the legal entity",
68
- }),
69
- email: z.string().email().optional().openapi({
70
- example: "contact@acme.com",
71
- description: "The email of the legal entity",
72
- format: "email",
73
- }),
74
- phone: z.string().optional().openapi({
75
- example: "+48123456789",
76
- description: "The phone number of the legal entity",
77
- }),
78
- address: UpdateAddressSchema.required().openapi({
79
- description: "The address of the legal entity",
80
- }),
81
- })
82
- .openapi("UpdateLegalEntity");
83
- //# sourceMappingURL=legal-entity.schema.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{AddressSchema as t,CreateAddressSchema as i,UpdateAddressSchema as a}from"../../schemas/address.schema";export const LegalEntitySchema=e.object({id:e.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity"}),name:e.string().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:e.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:e.string().email().nullable().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:e.string().nullable().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),createdAt:e.date().openapi({description:"The date and time when the legal entity was created",format:"date-time"}),address:t.required().openapi({description:"The address of the legal entity"})}).openapi("LegalEntity"),CreateLegalEntitySchema=e.object({name:e.string().min(1,"Name is required").openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:e.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:e.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:e.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:i.required().openapi({description:"The address of the legal entity"})}).openapi("CreateLegalEntity"),UpdateLegalEntitySchema=e.object({name:e.string().min(1,"Name is required").optional().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:e.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:e.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:e.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:a.required().openapi({description:"The address of the legal entity"})}).openapi("UpdateLegalEntity");