@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,66 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { handleUpload } from "@vercel/blob/client";
3
- import { logger } from "../../core/logging/pino";
4
- import { FileSchema, GetVercelTokenResponse, } from "../../schemas";
5
- class FileService {
6
- constructor(prisma) {
7
- this.prisma = prisma;
8
- }
9
- /**
10
- * Get Vercel token for file upload
11
- */
12
- getVercelToken(body, request) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- const jsonResponse = yield handleUpload({
15
- body: body,
16
- request,
17
- onBeforeGenerateToken: () => __awaiter(this, void 0, void 0, function* () {
18
- if (body.type !== "blob.generate-client-token") {
19
- throw new Error("Invalid type");
20
- }
21
- if (!body.payload.clientPayload) {
22
- throw new Error("clientPayload is required");
23
- }
24
- yield request.auth.getCurrentUser();
25
- return {
26
- addRandomSuffix: true,
27
- allowedContentTypes: ["image/jpeg", "image/png", "image/gif"],
28
- tokenPayload: body.payload.clientPayload,
29
- };
30
- }),
31
- onUploadCompleted: (_a) => __awaiter(this, [_a], void 0, function* ({ blob, tokenPayload }) {
32
- logger.info({ blob, tokenPayload }, "blob upload completed");
33
- if (!tokenPayload) {
34
- throw new Error("tokenPayload is required");
35
- }
36
- const { fileId } = JSON.parse(tokenPayload);
37
- yield this.prisma.file.update({
38
- where: {
39
- id: fileId,
40
- },
41
- data: {
42
- filename: blob.pathname,
43
- url: blob.url,
44
- mimeType: blob.contentType,
45
- status: "completed",
46
- },
47
- });
48
- }),
49
- });
50
- return GetVercelTokenResponse.parse(jsonResponse);
51
- });
52
- }
53
- /**
54
- * Create a temporary file record
55
- */
56
- createTemporaryFile(userId, body) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const file = yield this.prisma.file.create({
59
- data: Object.assign(Object.assign({}, body), { url: "-", createdBy: userId }),
60
- });
61
- return FileSchema.parse(file);
62
- });
63
- }
64
- }
65
- export { FileService };
66
- //# sourceMappingURL=file.service.js.map
1
+ import{__awaiter as i}from"tslib";import{handleUpload as d}from"@vercel/blob/client";import{logger as s}from"../../core/logging/pino";import{FileSchema as p,GetVercelTokenResponse as c}from"../../schemas";class m{constructor(e){this.prisma=e}getVercelToken(e,r){return i(this,void 0,void 0,function*(){const o=yield d({body:e,request:r,onBeforeGenerateToken:()=>i(this,void 0,void 0,function*(){if(e.type!=="blob.generate-client-token")throw new Error("Invalid type");if(!e.payload.clientPayload)throw new Error("clientPayload is required");return yield r.auth.getCurrentUser(),{addRandomSuffix:!0,allowedContentTypes:["image/jpeg","image/png","image/gif"],tokenPayload:e.payload.clientPayload}}),onUploadCompleted:n=>i(this,[n],void 0,function*({blob:t,tokenPayload:a}){if(s.info({blob:t,tokenPayload:a},"blob upload completed"),!a)throw new Error("tokenPayload is required");const{fileId:l}=JSON.parse(a);yield this.prisma.file.update({where:{id:l},data:{filename:t.pathname,url:t.url,mimeType:t.contentType,status:"completed"}})})});return c.parse(o)})}createTemporaryFile(e,r){return i(this,void 0,void 0,function*(){const o=yield this.prisma.file.create({data:Object.assign(Object.assign({},r),{url:"-",createdBy:e})});return p.parse(o)})}}export{m as FileService};
@@ -1,10 +1 @@
1
- import { createApiRouter } from "../../core/hono/hono";
2
- import { healthRoute } from "./health.route";
3
- export const buildHealthHandler = () => {
4
- const app = createApiRouter();
5
- app.openapi(healthRoute.ping, (c) => {
6
- return c.json({ ok: true }, 200);
7
- });
8
- return app;
9
- };
10
- //# sourceMappingURL=health.handler.js.map
1
+ import{createApiRouter as e}from"../../core/hono/hono";import{healthRoute as o}from"./health.route";export const buildHealthHandler=()=>{const r=e();return r.openapi(o.ping,t=>t.json({ok:!0},200)),r};
@@ -1,25 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { createApiRoute } from "../../core/hono/hono";
3
- import { ErrorSchema, HeaderSchema } from "../../schemas";
4
- const pingRoute = createApiRoute({
5
- description: "Pings the relevancy score service to check its availability",
6
- headers: HeaderSchema,
7
- method: "GET",
8
- operationId: "ping",
9
- path: "/ping",
10
- responses: {
11
- 200: z.object({
12
- ok: z.boolean().openapi({
13
- description: "Indicates if the service is available",
14
- example: true,
15
- }),
16
- }),
17
- 500: ErrorSchema,
18
- },
19
- summary: "Ping",
20
- tags: ["Health"],
21
- });
22
- export const healthRoute = {
23
- ping: pingRoute,
24
- };
25
- //# sourceMappingURL=health.route.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{createApiRoute as i}from"../../core/hono/hono";import{ErrorSchema as o,HeaderSchema as t}from"../../schemas";const r=i({description:"Pings the relevancy score service to check its availability",headers:t,method:"GET",operationId:"ping",path:"/ping",responses:{200:e.object({ok:e.boolean().openapi({description:"Indicates if the service is available",example:!0})}),500:o},summary:"Ping",tags:["Health"]});export const healthRoute={ping:r};
@@ -1,3 +1,4 @@
1
+ export { buildAnalyticsHandler } from "./analytics/analytics.handler";
1
2
  export { buildAccessHandler } from "./access/access.handler";
2
3
  export { buildCartHandler } from "./cart/cart.handler";
3
4
  export { buildFileHandler } from "./file/file.handler";
@@ -1,16 +1 @@
1
- export { buildAccessHandler } from "./access/access.handler";
2
- export { buildCartHandler } from "./cart/cart.handler";
3
- export { buildFileHandler } from "./file/file.handler";
4
- export { buildHealthHandler } from "./health/health.handler";
5
- export { buildLocationHandler } from "./location/location.handler";
6
- export { buildManufacturerHandler } from "./manufacturer/manufacturer.handler";
7
- export { buildOrderHandler } from "./order/order.handler";
8
- export { buildOrganizationHandler } from "./organization/organization.handler";
9
- export { buildPaymentHandler } from "./payment/payment.handler";
10
- export { buildProductCategoryHandler } from "./product-category/product-category.handler";
11
- export { buildProductHandler } from "./product/product.handler";
12
- export { buildReservationHandler } from "./reservation/reservation.handler";
13
- export { buildShippingHandler } from "./shipping/shipping.handler";
14
- export { buildShippingMethodHandler } from "./shipping-method/shipping-method.handler";
15
- export { buildWebhookHandler } from "./webhook/webhook.handler";
16
- //# sourceMappingURL=index.js.map
1
+ export{buildAnalyticsHandler}from"./analytics/analytics.handler";export{buildAccessHandler}from"./access/access.handler";export{buildCartHandler}from"./cart/cart.handler";export{buildFileHandler}from"./file/file.handler";export{buildHealthHandler}from"./health/health.handler";export{buildLocationHandler}from"./location/location.handler";export{buildManufacturerHandler}from"./manufacturer/manufacturer.handler";export{buildOrderHandler}from"./order/order.handler";export{buildOrganizationHandler}from"./organization/organization.handler";export{buildPaymentHandler}from"./payment/payment.handler";export{buildProductCategoryHandler}from"./product-category/product-category.handler";export{buildProductHandler}from"./product/product.handler";export{buildReservationHandler}from"./reservation/reservation.handler";export{buildShippingHandler}from"./shipping/shipping.handler";export{buildShippingMethodHandler}from"./shipping-method/shipping-method.handler";export{buildWebhookHandler}from"./webhook/webhook.handler";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1,25 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { createApiRouter } from "../../core/hono/hono";
3
- import { locationRoute } from "./location.route";
4
- import { LocationService } from "./location.service";
5
- export const buildLocationHandler = (options) => {
6
- const app = createApiRouter();
7
- app.openapi(locationRoute.getPredictions, (c) => __awaiter(void 0, void 0, void 0, function* () {
8
- const auth = c.get("auth");
9
- const query = c.req.valid("query");
10
- yield auth.getCurrentUser();
11
- const service = new LocationService(options.google.key);
12
- const predictions = yield service.getPredictions(query.query, query.radius);
13
- return c.json(predictions, 200);
14
- }));
15
- app.openapi(locationRoute.getPlaceDetails, (c) => __awaiter(void 0, void 0, void 0, function* () {
16
- const auth = c.get("auth");
17
- const params = c.req.valid("param");
18
- yield auth.getCurrentUser();
19
- const service = new LocationService(options.google.key);
20
- const placeDetails = yield service.getPlaceDetails(params.placeId);
21
- return c.json(placeDetails, 200);
22
- }));
23
- return app;
24
- };
25
- //# sourceMappingURL=location.handler.js.map
1
+ import{__awaiter as a}from"tslib";import{createApiRouter as l}from"../../core/hono/hono";import{locationRoute as s}from"./location.route";import{LocationService as c}from"./location.service";export const buildLocationHandler=n=>{const o=l();return o.openapi(s.getPredictions,e=>a(void 0,void 0,void 0,function*(){const r=e.get("auth"),t=e.req.valid("query");yield r.getCurrentUser();const i=yield new c(n.google.key).getPredictions(t.query,t.radius);return e.json(i,200)})),o.openapi(s.getPlaceDetails,e=>a(void 0,void 0,void 0,function*(){const r=e.get("auth"),t=e.req.valid("param");yield r.getCurrentUser();const i=yield new c(n.google.key).getPlaceDetails(t.placeId);return e.json(i,200)})),o};
@@ -1,56 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { createApiRoute } from "../../core/hono/hono";
3
- import { ErrorSchema, HeaderSchema, PlaceDetailsSchema, PlaceSchema, } from "../../schemas";
4
- const getPredictionsRoute = createApiRoute({
5
- description: "Returns a list of places for autocompletion based on a search query",
6
- headers: HeaderSchema,
7
- method: "GET",
8
- operationId: "getPredictions",
9
- path: "/places/prediction",
10
- query: z.object({
11
- query: z.string().openapi({
12
- description: "Search query",
13
- example: "123 Main St",
14
- }),
15
- radius: z.coerce.number().default(10000).openapi({
16
- description: "Search radius in meters",
17
- example: 10000,
18
- }),
19
- }),
20
- responses: {
21
- 200: z.array(PlaceSchema),
22
- 400: ErrorSchema,
23
- 401: ErrorSchema,
24
- },
25
- summary: "Get Places Predictions",
26
- tags: ["Location"],
27
- });
28
- const getPlaceDetailsRoute = createApiRoute({
29
- description: "Returns details for a specific place based on its placeId",
30
- headers: HeaderSchema,
31
- method: "GET",
32
- operationId: "getPlaceDetails",
33
- path: "/places/:placeId",
34
- pathParams: z.object({
35
- placeId: z.string().openapi({
36
- description: "The Google Place ID for the address",
37
- example: "ChIJN1t_tKlj4AR4GeTYWZ7frY",
38
- param: {
39
- in: "path",
40
- name: "placeId",
41
- },
42
- }),
43
- }),
44
- responses: {
45
- 200: PlaceDetailsSchema,
46
- 400: ErrorSchema,
47
- 401: ErrorSchema,
48
- },
49
- summary: "Get Place Details",
50
- tags: ["Location"],
51
- });
52
- export const locationRoute = {
53
- getPredictions: getPredictionsRoute,
54
- getPlaceDetails: getPlaceDetailsRoute,
55
- };
56
- //# sourceMappingURL=location.route.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{ErrorSchema as a,HeaderSchema as o,PlaceDetailsSchema as r,PlaceSchema as i}from"../../schemas";const s=t({description:"Returns a list of places for autocompletion based on a search query",headers:o,method:"GET",operationId:"getPredictions",path:"/places/prediction",query:e.object({query:e.string().openapi({description:"Search query",example:"123 Main St"}),radius:e.coerce.number().default(1e4).openapi({description:"Search radius in meters",example:1e4})}),responses:{200:e.array(i),400:a,401:a},summary:"Get Places Predictions",tags:["Location"]}),c=t({description:"Returns details for a specific place based on its placeId",headers:o,method:"GET",operationId:"getPlaceDetails",path:"/places/:placeId",pathParams:e.object({placeId:e.string().openapi({description:"The Google Place ID for the address",example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",param:{in:"path",name:"placeId"}})}),responses:{200:r,400:a,401:a},summary:"Get Place Details",tags:["Location"]});export const locationRoute={getPredictions:s,getPlaceDetails:c};
@@ -1,50 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- export const PlaceSchema = z
3
- .object({
4
- placeId: z.string().openapi({
5
- example: "ChIJN1t_tKlj4AR4GeTYWZ7frY",
6
- description: "The Google Place ID for the address",
7
- }),
8
- text: z.string().openapi({
9
- example: "123 Main Street, New York, USA",
10
- description: "The description of the place",
11
- }),
12
- addressLineOne: z.string().openapi({
13
- example: "123 Main Street",
14
- description: "The first line of the address",
15
- }),
16
- addressLineTwo: z.string().optional().openapi({
17
- example: "Suite 100",
18
- description: "The second line of the address",
19
- }),
20
- latitude: z.number().optional().openapi({
21
- example: 40.712776,
22
- description: "The latitude of the coordinate",
23
- }),
24
- longitude: z.number().optional().openapi({
25
- example: -74.005974,
26
- description: "The longitude of the coordinate",
27
- }),
28
- })
29
- .openapi("Place");
30
- export const PlaceDetailsSchema = z
31
- .object({
32
- addressLineOne: z.string().openapi({
33
- example: "123 Main Street",
34
- description: "The first line of the address",
35
- }),
36
- zipCode: z.string().optional().openapi({
37
- example: "12345",
38
- description: "The postal code of the address",
39
- }),
40
- city: z.string().openapi({
41
- example: "New York",
42
- description: "The city of the address",
43
- }),
44
- country: z.string().openapi({
45
- example: "USA",
46
- description: "The ISO 3166-1 alpha-2 country code",
47
- }),
48
- })
49
- .openapi("PlaceDetails");
50
- //# sourceMappingURL=location.schema.js.map
1
+ import{z as e}from"@hono/zod-openapi";export const PlaceSchema=e.object({placeId:e.string().openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"}),text:e.string().openapi({example:"123 Main Street, New York, USA",description:"The description of the place"}),addressLineOne:e.string().openapi({example:"123 Main Street",description:"The first line of the address"}),addressLineTwo:e.string().optional().openapi({example:"Suite 100",description:"The second line of the address"}),latitude:e.number().optional().openapi({example:40.712776,description:"The latitude of the coordinate"}),longitude:e.number().optional().openapi({example:-74.005974,description:"The longitude of the coordinate"})}).openapi("Place"),PlaceDetailsSchema=e.object({addressLineOne:e.string().openapi({example:"123 Main Street",description:"The first line of the address"}),zipCode:e.string().optional().openapi({example:"12345",description:"The postal code of the address"}),city:e.string().openapi({example:"New York",description:"The city of the address"}),country:e.string().openapi({example:"USA",description:"The ISO 3166-1 alpha-2 country code"})}).openapi("PlaceDetails");
@@ -1,141 +1 @@
1
- import { __awaiter } from "tslib";
2
- import axios, { isAxiosError } from "axios";
3
- import { logger } from "../../core/logging/pino";
4
- class LocationService {
5
- constructor(apiKey) {
6
- this.apiKey = apiKey;
7
- this.client = axios.create({
8
- baseURL: "https://places.googleapis.com/v1",
9
- headers: {
10
- "Content-Type": "application/json",
11
- "X-Goog-Api-Key": apiKey,
12
- },
13
- });
14
- }
15
- /**
16
- * Get a list of places for autocompletion based on a search query
17
- */
18
- getPredictions(query, radius) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b, _c;
21
- if (!query || query.trim() === "" || query.length < 3) {
22
- return [];
23
- }
24
- try {
25
- const { data } = yield this.client.post("/places:autocomplete", {
26
- input: query,
27
- locationBias: {
28
- circle: {
29
- center: {
30
- latitude: 37.7937,
31
- longitude: -122.3965,
32
- },
33
- radius: radius || 100000,
34
- },
35
- },
36
- });
37
- return data.suggestions.map(({ placePrediction }) => ({
38
- placeId: placePrediction.placeId,
39
- text: placePrediction.text.text,
40
- addressLineOne: placePrediction.structuredFormat.mainText.text,
41
- addressLineTwo: placePrediction.structuredFormat.secondaryText.text,
42
- }));
43
- }
44
- catch (error) {
45
- if (isAxiosError(error)) {
46
- logger.error({
47
- status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
48
- statusText: (_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText,
49
- data: (_c = error.response) === null || _c === void 0 ? void 0 : _c.data,
50
- query,
51
- }, "Google Places Autocomplete request failed");
52
- }
53
- else {
54
- logger.error({ err: error, query }, "Unexpected error during Places Autocomplete");
55
- }
56
- throw error;
57
- }
58
- });
59
- }
60
- findDistanceBetweenCoordinates(from, to) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- // Helper function to convert degrees to radians
63
- const toRadians = (degrees) => degrees * (Math.PI / 180);
64
- // Earth's radius in kilometers
65
- const earthRadiusKm = 6371;
66
- // Convert latitude and longitude differences to radians
67
- const dLat = toRadians(to.latitude - from.latitude);
68
- const dLon = toRadians(to.longitude - from.longitude);
69
- // Convert starting coordinates to radians
70
- const lat1 = toRadians(from.latitude);
71
- const lat2 = toRadians(to.latitude);
72
- // Haversine formula
73
- const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
74
- Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
75
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
76
- // Calculate the distance
77
- const distance = earthRadiusKm * c;
78
- return distance;
79
- });
80
- }
81
- getPlaceDetails(placeId) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- var _a, _b, _c;
84
- let data;
85
- try {
86
- const response = yield this.client.get(`/places/${placeId}`, {
87
- headers: {
88
- "X-Goog-FieldMask": "addressComponents,adrFormatAddress,formattedAddress,location,plusCode,postalAddress,shortFormattedAddress,types",
89
- },
90
- });
91
- data = response.data;
92
- }
93
- catch (error) {
94
- if (isAxiosError(error)) {
95
- logger.error({
96
- status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
97
- statusText: (_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText,
98
- data: (_c = error.response) === null || _c === void 0 ? void 0 : _c.data,
99
- placeId,
100
- }, "Google Place Details request failed");
101
- }
102
- else {
103
- logger.error({ err: error, placeId }, "Unexpected error during Place Details");
104
- }
105
- throw error;
106
- }
107
- const result = {
108
- addressLineOne: "",
109
- zipCode: "",
110
- country: "",
111
- city: "",
112
- latitude: data.location.latitude,
113
- longitude: data.location.longitude,
114
- };
115
- if (!data.addressComponents) {
116
- return result;
117
- }
118
- for (const component of data.addressComponents) {
119
- if (component.types.includes("street_number")) {
120
- result.addressLineOne = component.shortText;
121
- }
122
- if (component.types.includes("route")) {
123
- result.addressLineOne =
124
- component.shortText + " " + result.addressLineOne;
125
- }
126
- if (component.types.includes("postal_code")) {
127
- result.zipCode = component.shortText;
128
- }
129
- if (component.types.includes("country")) {
130
- result.country = component.shortText;
131
- }
132
- if (component.types.includes("locality")) {
133
- result.city = component.longText;
134
- }
135
- }
136
- return result;
137
- });
138
- }
139
- }
140
- export { LocationService };
141
- //# sourceMappingURL=location.service.js.map
1
+ import{__awaiter as d}from"tslib";import h,{isAxiosError as c}from"axios";import{logger as n}from"../../core/logging/pino";class m{constructor(s){this.apiKey=s,this.client=h.create({baseURL:"https://places.googleapis.com/v1",headers:{"Content-Type":"application/json","X-Goog-Api-Key":s}})}getPredictions(s,a){return d(this,void 0,void 0,function*(){var o,i,r;if(!s||s.trim()===""||s.length<3)return[];try{const{data:e}=yield this.client.post("/places:autocomplete",{input:s,locationBias:{circle:{center:{latitude:37.7937,longitude:-122.3965},radius:a||1e5}}});return e.suggestions.map(({placePrediction:t})=>({placeId:t.placeId,text:t.text.text,addressLineOne:t.structuredFormat.mainText.text,addressLineTwo:t.structuredFormat.secondaryText.text}))}catch(e){throw c(e)?n.error({status:(o=e.response)===null||o===void 0?void 0:o.status,statusText:(i=e.response)===null||i===void 0?void 0:i.statusText,data:(r=e.response)===null||r===void 0?void 0:r.data,query:s},"Google Places Autocomplete request failed"):n.error({err:e,query:s},"Unexpected error during Places Autocomplete"),e}})}findDistanceBetweenCoordinates(s,a){return d(this,void 0,void 0,function*(){const o=p=>p*(Math.PI/180),r=o(a.latitude-s.latitude),e=o(a.longitude-s.longitude),t=o(s.latitude),u=o(a.latitude),l=Math.sin(r/2)*Math.sin(r/2)+Math.cos(t)*Math.cos(u)*Math.sin(e/2)*Math.sin(e/2);return 6371*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))})}getPlaceDetails(s){return d(this,void 0,void 0,function*(){var a,o,i;let r;try{r=(yield this.client.get(`/places/${s}`,{headers:{"X-Goog-FieldMask":"addressComponents,adrFormatAddress,formattedAddress,location,plusCode,postalAddress,shortFormattedAddress,types"}})).data}catch(t){throw c(t)?n.error({status:(a=t.response)===null||a===void 0?void 0:a.status,statusText:(o=t.response)===null||o===void 0?void 0:o.statusText,data:(i=t.response)===null||i===void 0?void 0:i.data,placeId:s},"Google Place Details request failed"):n.error({err:t,placeId:s},"Unexpected error during Place Details"),t}const e={addressLineOne:"",zipCode:"",country:"",city:"",latitude:r.location.latitude,longitude:r.location.longitude};if(!r.addressComponents)return e;for(const t of r.addressComponents)t.types.includes("street_number")&&(e.addressLineOne=t.shortText),t.types.includes("route")&&(e.addressLineOne=t.shortText+" "+e.addressLineOne),t.types.includes("postal_code")&&(e.zipCode=t.shortText),t.types.includes("country")&&(e.country=t.shortText),t.types.includes("locality")&&(e.city=t.longText);return e})}}export{m as LocationService};
@@ -1,53 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { createApiRouter } from "../../core/hono/hono";
3
- import { manufacturerRoute } from "./manufacturer.route";
4
- import { ManufacturerService } from "./manufacturer.service";
5
- export const buildManufacturerHandler = (prisma) => {
6
- const app = createApiRouter();
7
- app.openapi(manufacturerRoute.createManufacturer, (c) => __awaiter(void 0, void 0, void 0, function* () {
8
- const auth = c.get("auth");
9
- const params = c.req.valid("param");
10
- const body = c.req.valid("json");
11
- const user = yield auth.isGranted("create");
12
- const service = new ManufacturerService(prisma);
13
- const manufacturer = yield service.createManufacturer(params.organizationId, user.id, body);
14
- return c.json(manufacturer, 201);
15
- }));
16
- app.openapi(manufacturerRoute.getManufacturer, (c) => __awaiter(void 0, void 0, void 0, function* () {
17
- const auth = c.get("auth");
18
- const params = c.req.valid("param");
19
- const query = c.req.valid("query");
20
- yield auth.isGranted("read");
21
- const service = new ManufacturerService(prisma);
22
- const manufacturer = yield service.getManufacturer(params.organizationId, params.id, { locale: query.locale || null });
23
- return c.json(manufacturer, 200);
24
- }));
25
- app.openapi(manufacturerRoute.getManufacturers, (c) => __awaiter(void 0, void 0, void 0, function* () {
26
- const auth = c.get("auth");
27
- const params = c.req.valid("param");
28
- const query = c.req.valid("query");
29
- yield auth.isGranted("read");
30
- const service = new ManufacturerService(prisma);
31
- const result = yield service.getManufacturers(params.organizationId, Object.assign(Object.assign({}, query), { locale: query.locale || null }));
32
- return c.json(result, 200);
33
- }));
34
- app.openapi(manufacturerRoute.updateManufacturer, (c) => __awaiter(void 0, void 0, void 0, function* () {
35
- const auth = c.get("auth");
36
- const params = c.req.valid("param");
37
- const body = c.req.valid("json");
38
- const user = yield auth.isGranted("update");
39
- const service = new ManufacturerService(prisma);
40
- const updatedManufacturer = yield service.updateManufacturer(params.organizationId, params.id, user.id, body);
41
- return c.json(updatedManufacturer, 200);
42
- }));
43
- app.openapi(manufacturerRoute.deleteManufacturer, (c) => __awaiter(void 0, void 0, void 0, function* () {
44
- const auth = c.get("auth");
45
- const params = c.req.valid("param");
46
- const user = yield auth.isGranted("delete");
47
- const service = new ManufacturerService(prisma);
48
- yield service.deleteManufacturer(params.organizationId, params.id, user.id);
49
- return c.body(null, 204);
50
- }));
51
- return app;
52
- };
53
- //# sourceMappingURL=manufacturer.handler.js.map
1
+ import{__awaiter as d}from"tslib";import{createApiRouter as v}from"../../core/hono/hono";import{manufacturerRoute as s}from"./manufacturer.route";import{ManufacturerService as c}from"./manufacturer.service";export const buildManufacturerHandler=i=>{const n=v();return n.openapi(s.createManufacturer,e=>d(void 0,void 0,void 0,function*(){const t=e.get("auth"),a=e.req.valid("param"),r=e.req.valid("json"),o=yield t.isGranted("create"),l=yield new c(i).createManufacturer(a.organizationId,o.id,r);return e.json(l,201)})),n.openapi(s.getManufacturer,e=>d(void 0,void 0,void 0,function*(){const t=e.get("auth"),a=e.req.valid("param"),r=e.req.valid("query");yield t.isGranted("read");const u=yield new c(i).getManufacturer(a.organizationId,a.id,{locale:r.locale||null});return e.json(u,200)})),n.openapi(s.getManufacturers,e=>d(void 0,void 0,void 0,function*(){const t=e.get("auth"),a=e.req.valid("param"),r=e.req.valid("query");yield t.isGranted("read");const u=yield new c(i).getManufacturers(a.organizationId,Object.assign(Object.assign({},r),{locale:r.locale||null}));return e.json(u,200)})),n.openapi(s.updateManufacturer,e=>d(void 0,void 0,void 0,function*(){const t=e.get("auth"),a=e.req.valid("param"),r=e.req.valid("json"),o=yield t.isGranted("update"),l=yield new c(i).updateManufacturer(a.organizationId,a.id,o.id,r);return e.json(l,200)})),n.openapi(s.deleteManufacturer,e=>d(void 0,void 0,void 0,function*(){const t=e.get("auth"),a=e.req.valid("param"),r=yield t.isGranted("delete");return yield new c(i).deleteManufacturer(a.organizationId,a.id,r.id),e.body(null,204)})),n};
@@ -1,97 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { createApiRoute } from "../../core/hono/hono";
3
- import { ErrorSchema, HeaderSchema, OrganizationParams, OrganizationWithIdParams, PaginationMetaSchema, PaginationQuerySchema, } from "../../schemas";
4
- import { GetResourceQuerySchema } from "../../schemas/queries.schema";
5
- import { CreateManufacturerSchema, LocalizedManufacturerSchema, ManufacturerSchema, UpdateManufacturerSchema, } from "./manufacturer.schema";
6
- const getManufacturersRoute = createApiRoute({
7
- description: "Fetches a paginated list of manufacturers for a specific organization",
8
- headers: HeaderSchema,
9
- method: "GET",
10
- operationId: "getManufacturers",
11
- path: "/:organizationId/manufacturers",
12
- pathParams: OrganizationParams,
13
- query: PaginationQuerySchema,
14
- responses: {
15
- 200: z.object({
16
- list: z.array(z.union([ManufacturerSchema, LocalizedManufacturerSchema])),
17
- meta: PaginationMetaSchema,
18
- }),
19
- 400: ErrorSchema,
20
- 401: ErrorSchema,
21
- },
22
- summary: "Get Manufacturers",
23
- tags: ["Manufacturer"],
24
- });
25
- const createManufacturerRoute = createApiRoute({
26
- body: CreateManufacturerSchema,
27
- description: "Creates a new manufacturer for a specific organization",
28
- headers: HeaderSchema,
29
- method: "POST",
30
- operationId: "createManufacturer",
31
- path: "/:organizationId/manufacturers",
32
- pathParams: OrganizationParams,
33
- responses: {
34
- 201: ManufacturerSchema,
35
- 400: ErrorSchema,
36
- 401: ErrorSchema,
37
- 404: ErrorSchema,
38
- },
39
- summary: "Create Manufacturer",
40
- tags: ["Manufacturer"],
41
- });
42
- const getManufacturerRoute = createApiRoute({
43
- headers: HeaderSchema,
44
- method: "GET",
45
- operationId: "getManufacturer",
46
- path: "/:organizationId/manufacturers/:id",
47
- pathParams: OrganizationWithIdParams,
48
- query: GetResourceQuerySchema,
49
- responses: {
50
- 200: z.union([ManufacturerSchema, LocalizedManufacturerSchema]),
51
- 401: ErrorSchema,
52
- 404: ErrorSchema,
53
- },
54
- summary: "Get Manufacturer",
55
- tags: ["Manufacturer"],
56
- });
57
- const updateManufacturerRoute = createApiRoute({
58
- body: UpdateManufacturerSchema,
59
- description: "Updates an existing manufacturer",
60
- headers: HeaderSchema,
61
- method: "PUT",
62
- operationId: "updateManufacturer",
63
- path: "/:organizationId/manufacturers/:id",
64
- pathParams: OrganizationWithIdParams,
65
- responses: {
66
- 200: ManufacturerSchema,
67
- 400: ErrorSchema,
68
- 401: ErrorSchema,
69
- 404: ErrorSchema,
70
- },
71
- summary: "Update Manufacturer",
72
- tags: ["Manufacturer"],
73
- });
74
- const deleteManufacturerRoute = createApiRoute({
75
- description: "Soft deletes a manufacturer",
76
- headers: HeaderSchema,
77
- method: "DELETE",
78
- operationId: "deleteManufacturer",
79
- path: "/:organizationId/manufacturers/:id",
80
- pathParams: OrganizationWithIdParams,
81
- responses: {
82
- 204: null,
83
- 400: ErrorSchema,
84
- 401: ErrorSchema,
85
- 404: ErrorSchema,
86
- },
87
- summary: "Delete Manufacturer",
88
- tags: ["Manufacturer"],
89
- });
90
- export const manufacturerRoute = {
91
- getManufacturers: getManufacturersRoute,
92
- createManufacturer: createManufacturerRoute,
93
- getManufacturer: getManufacturerRoute,
94
- updateManufacturer: updateManufacturerRoute,
95
- deleteManufacturer: deleteManufacturerRoute,
96
- };
97
- //# sourceMappingURL=manufacturer.route.js.map
1
+ import{z as t}from"@hono/zod-openapi";import{createApiRoute as e}from"../../core/hono/hono";import{ErrorSchema as a,HeaderSchema as r,OrganizationParams as o,OrganizationWithIdParams as n,PaginationMetaSchema as s,PaginationQuerySchema as i}from"../../schemas";import{GetResourceQuerySchema as m}from"../../schemas/queries.schema";import{CreateManufacturerSchema as f,LocalizedManufacturerSchema as c,ManufacturerSchema as u,UpdateManufacturerSchema as d}from"./manufacturer.schema";const p=e({description:"Fetches a paginated list of manufacturers for a specific organization",headers:r,method:"GET",operationId:"getManufacturers",path:"/:organizationId/manufacturers",pathParams:o,query:i,responses:{200:t.object({list:t.array(t.union([u,c])),meta:s}),400:a,401:a},summary:"Get Manufacturers",tags:["Manufacturer"]}),h=e({body:f,description:"Creates a new manufacturer for a specific organization",headers:r,method:"POST",operationId:"createManufacturer",path:"/:organizationId/manufacturers",pathParams:o,responses:{201:u,400:a,401:a,404:a},summary:"Create Manufacturer",tags:["Manufacturer"]}),M=e({headers:r,method:"GET",operationId:"getManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,query:m,responses:{200:t.union([u,c]),401:a,404:a},summary:"Get Manufacturer",tags:["Manufacturer"]}),g=e({body:d,description:"Updates an existing manufacturer",headers:r,method:"PUT",operationId:"updateManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,responses:{200:u,400:a,401:a,404:a},summary:"Update Manufacturer",tags:["Manufacturer"]}),y=e({description:"Soft deletes a manufacturer",headers:r,method:"DELETE",operationId:"deleteManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,responses:{204:null,400:a,401:a,404:a},summary:"Delete Manufacturer",tags:["Manufacturer"]});export const manufacturerRoute={getManufacturers:p,createManufacturer:h,getManufacturer:M,updateManufacturer:g,deleteManufacturer:y};