@shophost/rest-api 2.0.67 → 2.0.69

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 (141) hide show
  1. package/package.json +1 -1
  2. package/schema.prisma +1 -0
  3. package/scripts/shophost-rest-api.mjs +198 -1
  4. package/src/bootstrap.js +1 -1
  5. package/src/container.js +1 -1
  6. package/src/core/auth/auth.schema.js +1 -1
  7. package/src/core/auth/auth.util.js +1 -1
  8. package/src/core/auth/better-auth.lib.js +1 -1
  9. package/src/core/auth/generate-password-hash.util.js +1 -1
  10. package/src/core/auth/headers.schema.js +1 -1
  11. package/src/core/auth/user.schema.js +1 -1
  12. package/src/core/db/__generated__/client/browser.js +1 -1
  13. package/src/core/db/__generated__/client/client.js +1 -1
  14. package/src/core/db/__generated__/client/enums.js +1 -1
  15. package/src/core/db/__generated__/client/internal/class.js +789 -1
  16. package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +1 -0
  17. package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -1
  18. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +1 -0
  19. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -1
  20. package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +41 -1
  21. package/src/core/db/index.js +1 -1
  22. package/src/core/email/components.js +1 -1
  23. package/src/core/exceptions/http-exception.js +1 -1
  24. package/src/core/hono/hono.js +1 -1
  25. package/src/core/lib/prisma.js +1 -1
  26. package/src/core/logging/pino.js +1 -1
  27. package/src/core/notifications/email.service.js +1 -1
  28. package/src/core/openapi/openapi.lib.js +1 -1
  29. package/src/core/utils/currency.util.js +1 -1
  30. package/src/core/utils/env.util.js +1 -1
  31. package/src/core/utils/object.util.js +1 -1
  32. package/src/core/utils/translations.util.js +1 -1
  33. package/src/core/utils/zod.util.js +1 -1
  34. package/src/db.js +1 -1
  35. package/src/features/access/access.handler.js +1 -1
  36. package/src/features/access/access.route.js +1 -1
  37. package/src/features/access/access.schema.js +1 -1
  38. package/src/features/access/access.service.js +1 -1
  39. package/src/features/analytics/analytics.handler.js +1 -1
  40. package/src/features/analytics/analytics.route.js +1 -1
  41. package/src/features/analytics/analytics.schema.js +1 -1
  42. package/src/features/analytics/analytics.service.js +1 -1
  43. package/src/features/cart/cart.handler.js +1 -1
  44. package/src/features/cart/cart.route.js +1 -1
  45. package/src/features/cart/cart.schema.js +1 -1
  46. package/src/features/cart/cart.service.js +1 -1
  47. package/src/features/cart/cart.util.js +1 -1
  48. package/src/features/customer/customer.handler.js +1 -1
  49. package/src/features/customer/customer.route.js +1 -1
  50. package/src/features/customer/customer.schema.js +1 -1
  51. package/src/features/customer/customer.service.js +1 -1
  52. package/src/features/file/file.handler.js +1 -1
  53. package/src/features/file/file.route.js +1 -1
  54. package/src/features/file/file.schema.js +1 -1
  55. package/src/features/file/file.service.js +1 -1
  56. package/src/features/health/health.handler.js +1 -1
  57. package/src/features/health/health.route.js +1 -1
  58. package/src/features/index.js +1 -1
  59. package/src/features/integration/integration-config.js +1 -1
  60. package/src/features/integration/integration-registry.js +1 -1
  61. package/src/features/integration/integration.handler.js +1 -1
  62. package/src/features/integration/integration.route.js +1 -1
  63. package/src/features/integration/integration.schema.js +1 -1
  64. package/src/features/integration/integration.service.js +1 -1
  65. package/src/features/inventory/inventory.service.js +1 -1
  66. package/src/features/location/location.handler.js +1 -1
  67. package/src/features/location/location.route.js +1 -1
  68. package/src/features/location/location.schema.js +1 -1
  69. package/src/features/location/location.service.js +1 -1
  70. package/src/features/manufacturer/manufacturer.handler.js +1 -1
  71. package/src/features/manufacturer/manufacturer.route.js +1 -1
  72. package/src/features/manufacturer/manufacturer.schema.js +1 -1
  73. package/src/features/manufacturer/manufacturer.service.js +1 -1
  74. package/src/features/order/emails/order-confirmation.email.js +1 -1
  75. package/src/features/order/emails/order-notification.email.js +1 -1
  76. package/src/features/order/fulfilment.schema.js +1 -1
  77. package/src/features/order/order-fulfillment.service.js +1 -1
  78. package/src/features/order/order.handler.js +1 -1
  79. package/src/features/order/order.route.js +1 -1
  80. package/src/features/order/order.schema.js +1 -1
  81. package/src/features/order/order.service.js +1 -1
  82. package/src/features/order/recipient.schema.js +1 -1
  83. package/src/features/organization/legal-entity.schema.js +1 -1
  84. package/src/features/organization/organization-configuration.schema.d.ts +2 -0
  85. package/src/features/organization/organization-configuration.schema.js +1 -1
  86. package/src/features/organization/organization.handler.js +1 -1
  87. package/src/features/organization/organization.route.d.ts +5 -0
  88. package/src/features/organization/organization.route.js +1 -1
  89. package/src/features/organization/organization.schema.d.ts +2 -0
  90. package/src/features/organization/organization.schema.js +1 -1
  91. package/src/features/organization/organization.service.d.ts +4 -0
  92. package/src/features/organization/organization.service.js +1 -1
  93. package/src/features/payment/payment-webhook.service.js +1 -1
  94. package/src/features/payment/payment.handler.js +1 -1
  95. package/src/features/payment/payment.route.js +1 -1
  96. package/src/features/payment/payment.schema.js +1 -1
  97. package/src/features/payment/payment.service.js +1 -1
  98. package/src/features/payment/stripe.service.js +1 -1
  99. package/src/features/product/product-modifier.schema.js +1 -1
  100. package/src/features/product/product.handler.js +1 -1
  101. package/src/features/product/product.route.js +1 -1
  102. package/src/features/product/product.schema.js +1 -1
  103. package/src/features/product/product.service.js +1 -1
  104. package/src/features/product-category/product-category.handler.js +1 -1
  105. package/src/features/product-category/product-category.route.js +1 -1
  106. package/src/features/product-category/product-category.schema.js +1 -1
  107. package/src/features/product-category/product-category.service.js +1 -1
  108. package/src/features/reservation/emails/reservation-cancellation.email.js +1 -1
  109. package/src/features/reservation/emails/reservation-confirmation.email.js +1 -1
  110. package/src/features/reservation/emails/reservation-email-date.d.ts +2 -0
  111. package/src/features/reservation/emails/reservation-email-date.js +1 -0
  112. package/src/features/reservation/emails/reservation-notification.email.js +1 -1
  113. package/src/features/reservation/emails/reservation-updated.email.js +1 -1
  114. package/src/features/reservation/reservation.handler.js +1 -1
  115. package/src/features/reservation/reservation.route.js +1 -1
  116. package/src/features/reservation/reservation.schema.js +1 -1
  117. package/src/features/reservation/reservation.service.js +1 -1
  118. package/src/features/shipping/shipping.handler.js +1 -1
  119. package/src/features/shipping/shipping.route.js +1 -1
  120. package/src/features/shipping/shipping.service.js +1 -1
  121. package/src/features/shipping-method/shipping-method.handler.js +1 -1
  122. package/src/features/shipping-method/shipping-method.route.js +1 -1
  123. package/src/features/shipping-method/shipping-method.schema.js +1 -1
  124. package/src/features/shipping-method/shipping-method.service.js +1 -1
  125. package/src/features/shipping-method/shipping-zone.schema.js +1 -1
  126. package/src/features/webhook/webhook.handler.js +1 -1
  127. package/src/features/webhook/webhook.route.js +1 -1
  128. package/src/index.js +1 -1
  129. package/src/integrations/next.js +1 -1
  130. package/src/schemas/address.schema.js +1 -1
  131. package/src/schemas/currency.schema.js +1 -1
  132. package/src/schemas/error.schema.js +1 -1
  133. package/src/schemas/index.d.ts +1 -0
  134. package/src/schemas/index.js +1 -1
  135. package/src/schemas/locales.schema.js +1 -1
  136. package/src/schemas/number.schema.js +1 -1
  137. package/src/schemas/pagination.schema.js +1 -1
  138. package/src/schemas/params.schema.js +1 -1
  139. package/src/schemas/queries.schema.js +1 -1
  140. package/src/schemas/time-zone.schema.d.ts +9 -0
  141. package/src/schemas/time-zone.schema.js +1 -0
@@ -1 +1 @@
1
- const _0x14366f=_0x4b80,_0x4b18ea=_0x4b80;(function(_0xde7f46,_0x58945d){const _0x253e4f=_0x4b80,_0x10353b=_0x4b80,_0x3950ee=_0xde7f46();while(!![]){try{const _0xd16648=-parseInt(_0x253e4f(0x88))/0x1*(-parseInt(_0x10353b(0x97))/0x2)+-parseInt(_0x253e4f(0x8d))/0x3+-parseInt(_0x253e4f(0x9c))/0x4*(-parseInt(_0x10353b(0xaf))/0x5)+parseInt(_0x10353b(0x87))/0x6+-parseInt(_0x10353b(0x8f))/0x7+-parseInt(_0x10353b(0xad))/0x8+-parseInt(_0x10353b(0xb2))/0x9;if(_0xd16648===_0x58945d)break;else _0x3950ee['push'](_0x3950ee['shift']());}catch(_0x47813d){_0x3950ee['push'](_0x3950ee['shift']());}}}(_0x48b9,0xd78c1));import{__awaiter as _0x8adb75}from'tslib';function _0x48b9(){const _0xd05d1d=['ig5VDcbZDxa','mMHhvMrvzq','Avzqv1i','yxnZAwDU','CMLWzunOzwm','zef0','mJq1nJu4ohLmwgTIrW','Bgv0zwq','zMLUzezPCNm','DxnLCKLK','rxzLBNq','A291DenVBxa','B2jQzwn0','Cg9YDgvK','Dhj1zq','AgfUzgXLu3q','z3jHDgLVBG','DxbKyxrL','ugf5BwvUDca','EunVBMzSAwm','zxnZAw9U','C3vJy2vLzgu','zgf0yq','mJK4otm2EK5wChPV','Bwv0ywrHDge','nwnKyvPguG','ChjVDMLKzxi','DgvZDeLUDgu','mJKYmZaZohrcversvW','C2vZC2LVBIa','ChjPC21H','ywLKt3jKzxi','zMLSBg1LBNq','ChjVy2vZC1C','DhLWzq','zNvSzMLSBfa','CNzPy2u','lMnVBxbSzxq','BM90igzVDw4','C3rYAxbLu2u','B3jKzxjgDwW','D1bxzuy','u2vYDMLJzq','zsbPCYbYzxe','t3jKzxiGBM8','Cgf5BwvUDa','mZm1ntGXmNPiEgLxsq','mZeZodK3qKrhsuzo','y2fWDhvYzwq','DfDLyMHVB2S','lNnLC3nPB24','u2LNBMf0Dxi','mJKYotuZzfviqxDL','DwLYzwq','mtaXmJy1nu5nvunyyG','C3rYAxbL','DcbMB3vUza','EurLzhvJDgu','Aw52zw50B3i','y29UC3rYDwm','zwjOB29Rrxy'];_0x48b9=function(){return _0xd05d1d;};return _0x48b9();}import{HttpException as _0x2bb8bb}from'../../core/exceptions/http-exception';function _0x4b80(_0x3c6db4,_0xa9535a){_0x3c6db4=_0x3c6db4-0x7c;const _0x48b97f=_0x48b9();let _0x4b801c=_0x48b97f[_0x3c6db4];if(_0x4b80['FqmhsV']===undefined){var _0x5d6f92=function(_0x154b15){const _0x922f2e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x176086='',_0x37a9c7='';for(let _0x45cf32=0x0,_0x3c3b96,_0x453b38,_0x1eaa24=0x0;_0x453b38=_0x154b15['charAt'](_0x1eaa24++);~_0x453b38&&(_0x3c3b96=_0x45cf32%0x4?_0x3c3b96*0x40+_0x453b38:_0x453b38,_0x45cf32++%0x4)?_0x176086+=String['fromCharCode'](0xff&_0x3c3b96>>(-0x2*_0x45cf32&0x6)):0x0){_0x453b38=_0x922f2e['indexOf'](_0x453b38);}for(let _0x4f0a1e=0x0,_0x554be1=_0x176086['length'];_0x4f0a1e<_0x554be1;_0x4f0a1e++){_0x37a9c7+='%'+('00'+_0x176086['charCodeAt'](_0x4f0a1e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x37a9c7);};_0x4b80['nkPyFB']=_0x5d6f92,_0x4b80['UaLufI']={},_0x4b80['FqmhsV']=!![];}const _0x4fbf23=_0x48b97f[0x0],_0x1acdfa=_0x3c6db4+_0x4fbf23,_0x3c550b=_0x4b80['UaLufI'][_0x1acdfa];return!_0x3c550b?(_0x4b801c=_0x4b80['nkPyFB'](_0x4b801c),_0x4b80['UaLufI'][_0x1acdfa]=_0x4b801c):_0x4b801c=_0x3c550b,_0x4b801c;}class p{constructor(_0x3bc06c,_0x2aab36,_0xdd52f1){const _0x26db0d=_0x4b80,_0x2b26fa=_0x4b80;this[_0x26db0d(0xb4)]=_0x3bc06c,this[_0x26db0d(0x80)+_0x2b26fa(0x7d)]=_0x2aab36,this[_0x2b26fa(0x81)+_0x26db0d(0xb6)+_0x26db0d(0x83)]=_0xdd52f1;}[_0x14366f(0xb7)+_0x14366f(0x95)+'ent'](_0x580986,_0x127e0a,_0x4614f6,_0xe269d1){return _0x8adb75(this,void 0x0,void 0x0,function*(){const _0xe3e6c9=_0x4b80,_0x3c392e=_0x4b80;if(!_0x127e0a)throw new _0x2bb8bb(0x191,_0xe3e6c9(0x8c)+_0x3c392e(0x84)+_0xe3e6c9(0x8e));if(_0x580986===_0xe3e6c9(0x90)){const _0xfefc49=yield this[_0xe3e6c9(0x80)+_0x3c392e(0x7d)][_0x3c392e(0x94)+_0x3c392e(0x8a)+_0xe3e6c9(0xa0)](_0xe269d1,_0x127e0a,_0x4614f6);return _0xfefc49[_0x3c392e(0xb8)]==='checkout'+_0xe3e6c9(0x8b)+_0x3c392e(0x7e)+'ed'?this[_0x3c392e(0xa5)+_0x3c392e(0x9a)+_0x3c392e(0xa1)+_0xe3e6c9(0x9d)](_0xfefc49[_0x3c392e(0xac)][_0x3c392e(0xa2)],_0xe269d1):void 0x0;}else throw new _0x2bb8bb(0x190,_0xe3e6c9(0xa8)+_0xe3e6c9(0xb0)+_0xe3e6c9(0x96)+_0x3c392e(0xa3));});}[_0x4b18ea(0xa5)+_0x4b18ea(0x9a)+'koutComp'+_0x14366f(0x9d)](_0x2ef9be,_0x4479cf){const _0x5b8fa5={'wPWeF':function(_0x51fa61,_0x45624b){return _0x51fa61===_0x45624b;},'iVPWR':function(_0x204e35,_0xa8eb7b){return _0x204e35!==_0xa8eb7b;}};return _0x8adb75(this,void 0x0,void 0x0,function*(){const _0x401252=_0x4b80,_0x55dac0=_0x4b80;var _0x3e6e9b,_0x3fa643,_0x3012de,_0x400860,_0x2ed40c;if(((_0x3e6e9b=_0x2ef9be[_0x401252(0xae)])===null||_0x3e6e9b===void 0x0?void 0x0:_0x3e6e9b[_0x55dac0(0xb1)+_0x55dac0(0xa6)])===_0x401252(0xa4))return;const _0x4168cb=yield this[_0x55dac0(0xb4)]['paymentS'+_0x401252(0xaa)][_0x401252(0x9e)+'t']({'where':Object[_0x401252(0x99)]({'referenceId':_0x2ef9be['id']},_0x4479cf?{'payment':{'order':{'organizationId':_0x4479cf}}}:{}),'include':{'payment':{'include':{'order':!0x0}}}});if(!_0x4168cb)throw new _0x2bb8bb(0x194,_0x55dac0(0xa8)+_0x401252(0xb3)+_0x401252(0x7f)+'d');const _0x3a78f7=(_0x3fa643=_0x4168cb['payment'])===null||_0x5b8fa5[_0x55dac0(0x82)](_0x3fa643,void 0x0)?void 0x0:_0x3fa643['order'];if(!_0x3a78f7)throw new _0x2bb8bb(0x194,_0x55dac0(0x85)+_0x55dac0(0x91));_0x4168cb[_0x401252(0x89)+'At']&&(_0x3a78f7[_0x55dac0(0x93)+_0x55dac0(0x92)+_0x401252(0x9b)]||_0x3a78f7[_0x55dac0(0x93)+_0x401252(0xa9)+'tAt'])||((!_0x4168cb[_0x401252(0x89)+'At']||_0x4168cb[_0x55dac0(0x86)]['status']!==_0x55dac0(0xab)+'d')&&(yield this[_0x55dac0(0xb4)]['paymentS'+'ession'][_0x55dac0(0xa7)]({'where':{'id':_0x4168cb['id']},'data':{'capturedAt':(_0x3012de=_0x4168cb['captured'+'At'])!==null&&_0x5b8fa5['iVPWR'](_0x3012de,void 0x0)?_0x3012de:new Date(),'payment':{'update':{'status':_0x55dac0(0xab)+'d'}}}})),yield this[_0x55dac0(0x81)+'fillment'+_0x401252(0x83)][_0x55dac0(0x7c)+_0x401252(0xb5)](_0x3a78f7['id'],_0x5b8fa5[_0x401252(0x98)](_0x2ed40c=(_0x400860=_0x2ef9be[_0x55dac0(0xae)])===null||_0x400860===void 0x0?void 0x0:_0x400860[_0x55dac0(0x9f)],null)&&_0x2ed40c!==void 0x0?_0x2ed40c:_0x3a78f7[_0x55dac0(0x9f)]));});}}export{p as PaymentWebhookService};
1
+ import{__awaiter as c}from"tslib";import{HttpException as s}from"../../core/exceptions/http-exception";class p{constructor(e,t,r){this.prisma=e,this.stripeService=t,this.orderFulfillmentService=r}processWebhookEvent(e,t,r,d){return c(this,void 0,void 0,function*(){if(!t)throw new s(401,"Signature is required");if(e==="stripe"){const n=yield this.stripeService.constructWebhookEvent(d,t,r);return n.type==="checkout.session.completed"?this.handleStripeCheckoutCompleted(n.data.object,d):void 0}else throw new s(400,"Payment provider not supported")})}handleStripeCheckoutCompleted(e,t){return c(this,void 0,void 0,function*(){var r,d,n,u,a;if(((r=e.metadata)===null||r===void 0?void 0:r.testIntegration)==="true")return;const i=yield this.prisma.paymentSession.findFirst({where:Object.assign({referenceId:e.id},t?{payment:{order:{organizationId:t}}}:{}),include:{payment:{include:{order:!0}}}});if(!i)throw new s(404,"Payment session not found");const o=(d=i.payment)===null||d===void 0?void 0:d.order;if(!o)throw new s(404,"Order not found");i.capturedAt&&(o.inventoryDeductedAt||o.inventoryConflictAt)||((!i.capturedAt||i.payment.status!=="succeeded")&&(yield this.prisma.paymentSession.update({where:{id:i.id},data:{capturedAt:(n=i.capturedAt)!==null&&n!==void 0?n:new Date,payment:{update:{status:"succeeded"}}}})),yield this.orderFulfillmentService.fulfillPaidOrder(o.id,(a=(u=e.metadata)===null||u===void 0?void 0:u.userId)!==null&&a!==void 0?a:o.userId))})}}export{p as PaymentWebhookService};
@@ -1 +1 @@
1
- function _0x247a(){const _0x2d21e4=['B3jNyw5PEMe','B3bLBMfWAq','yxv0Aa','z2v0q3vYCMu','otyXmdm1wLbUtfrb','ywjSzvbHEw0','ou1sCujXAG','nde1mtGWz2PNBeHq','nNbIquL3BW','ndG1mZqYmgzovxfRDq','ANnVBG','zw50twv0Ag8','z2v0ugf5Bwu','z2v0qxzHAwW','nfbvwhzUEa','mZGXnZKXm0LYqLD0qq','ndbhD1j5s2W','BNrvC2vY','mZeWnZK5m0f0Aw1Ara','CMvX','DMfSAwq','mJC0ntG1mNP3whzmEq','mJGWmZC2oeXRvxfTuW'];_0x247a=function(){return _0x2d21e4;};return _0x247a();}(function(_0x203fee,_0x2d465d){const _0x322c8e=_0x3ac5,_0x3b5fc6=_0x3ac5,_0x55e331=_0x203fee();while(!![]){try{const _0x580876=parseInt(_0x322c8e(0x121))/0x1*(parseInt(_0x3b5fc6(0x11a))/0x2)+-parseInt(_0x322c8e(0x12e))/0x3+parseInt(_0x322c8e(0x128))/0x4+parseInt(_0x3b5fc6(0x11c))/0x5+-parseInt(_0x3b5fc6(0x11b))/0x6*(parseInt(_0x322c8e(0x125))/0x7)+parseInt(_0x322c8e(0x129))/0x8*(parseInt(_0x3b5fc6(0x119))/0x9)+parseInt(_0x322c8e(0x123))/0xa*(-parseInt(_0x3b5fc6(0x122))/0xb);if(_0x580876===_0x2d465d)break;else _0x55e331['push'](_0x55e331['shift']());}catch(_0x4be1d9){_0x55e331['push'](_0x55e331['shift']());}}}(_0x247a,0xa74f6));function _0x3ac5(_0x583bcc,_0x9a1847){_0x583bcc=_0x583bcc-0x119;const _0x247a9e=_0x247a();let _0x3ac5b6=_0x247a9e[_0x583bcc];if(_0x3ac5['uGUKeU']===undefined){var _0x45b20e=function(_0x501432){const _0x3b81f6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4ae638='',_0x4c009d='';for(let _0x48f6a3=0x0,_0x4c7117,_0x20db69,_0x13c9bc=0x0;_0x20db69=_0x501432['charAt'](_0x13c9bc++);~_0x20db69&&(_0x4c7117=_0x48f6a3%0x4?_0x4c7117*0x40+_0x20db69:_0x20db69,_0x48f6a3++%0x4)?_0x4ae638+=String['fromCharCode'](0xff&_0x4c7117>>(-0x2*_0x48f6a3&0x6)):0x0){_0x20db69=_0x3b81f6['indexOf'](_0x20db69);}for(let _0x494b79=0x0,_0x2c1d42=_0x4ae638['length'];_0x494b79<_0x2c1d42;_0x494b79++){_0x4c009d+='%'+('00'+_0x4ae638['charCodeAt'](_0x494b79)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4c009d);};_0x3ac5['NcmjbH']=_0x45b20e,_0x3ac5['LVJzBE']={},_0x3ac5['uGUKeU']=!![];}const _0x81d635=_0x247a9e[0x0],_0x1f0578=_0x583bcc+_0x81d635,_0x224047=_0x3ac5['LVJzBE'][_0x1f0578];return!_0x224047?(_0x3ac5b6=_0x3ac5['NcmjbH'](_0x3ac5b6),_0x3ac5['LVJzBE'][_0x1f0578]=_0x3ac5b6):_0x3ac5b6=_0x224047,_0x3ac5b6;}import{__awaiter as _0x54346a}from'tslib';import{createApiRouter as _0xaa226b}from'../../core/hono/hono';import{paymentRoute as _0x2fa0c4}from'./payment.route';export const registerPaymentHandlers=_0x514a02=>{const _0x4f1e2d=_0x3ac5,_0xf02793=_0x3ac5,_0x3f8da4=_0xaa226b();return _0x3f8da4[_0x4f1e2d(0x12b)](_0x2fa0c4[_0x4f1e2d(0x120)+_0xf02793(0x12f)+_0xf02793(0x11e)+'ds'],_0x1e3fa7=>_0x54346a(void 0x0,void 0x0,void 0x0,function*(){const _0x36a600=_0xf02793,_0x5c9536=_0xf02793,_0xf3ad9f=_0x1e3fa7['get'](_0x36a600(0x12c)),_0x47d7c6=_0x1e3fa7[_0x36a600(0x126)][_0x5c9536(0x127)]('param');yield _0xf3ad9f[_0x36a600(0x12d)+_0x5c9536(0x124)]();const _0x521fe3=yield _0x514a02[_0x36a600(0x11f)+'ntMethod'+'s'](_0x47d7c6[_0x5c9536(0x12a)+'tionId']);return _0x1e3fa7[_0x5c9536(0x11d)](_0x521fe3,0xc8);})),_0x3f8da4;};
1
+ import{__awaiter as i}from"tslib";import{createApiRouter as m}from"../../core/hono/hono";import{paymentRoute as p}from"./payment.route";export const registerPaymentHandlers=o=>{const e=m();return e.openapi(p.getAvailablePaymentMethods,t=>i(void 0,void 0,void 0,function*(){const r=t.get("auth"),a=t.req.valid("param");yield r.getCurrentUser();const n=yield o.getPaymentMethods(a.organizationId);return t.json(n,200)})),e};
@@ -1 +1 @@
1
- const _0x1f5fc6=_0x394a,_0x881d05=_0x394a;function _0x2b0b(){const _0x453cc6=['lZPVCMDHBMK','uMv0DxjUCYa','ntqWndi3m25oC2Xlrq','mtu0mtu5nwHiELrktW','z2v0qxzHAwW','DgHVzhm','ywjSzvbHEw0','BML6yxrPB24','mtzVv2zOExy','zw50twv0Ag8','oduXndKYqvbbyMDH','r2v0ief2ywK','BgfIBguGuge','ugf5BwvUDa','r0vu','EMf0Aw9Uswq','mJqWmJu3n0X3tu9YAG','yxjYyxK','nMzUwgTIrW','ysbSAxn0ig8','l3bHEw1LBNq','mJeXmJG0otb4vu5WEMy','l21LDgHVzhm','yMXLihbHEw0','B2rZigzVCIa','nZbYqwjbAwi','Ew1LBNqGtwu','mJeWmJz6swvezKu','zIbHDMfPBge','mtG4mJu2mfLdwNPHwa','zw50ig1LDgG'];_0x2b0b=function(){return _0x453cc6;};return _0x2b0b();}(function(_0x132211,_0x1b1d07){const _0x4d9728=_0x394a,_0x430668=_0x394a,_0x2f2c53=_0x132211();while(!![]){try{const _0x38bf3a=parseInt(_0x4d9728(0xab))/0x1*(-parseInt(_0x430668(0xad))/0x2)+parseInt(_0x430668(0xb4))/0x3+parseInt(_0x4d9728(0xbb))/0x4+-parseInt(_0x4d9728(0xaf))/0x5+parseInt(_0x4d9728(0xc3))/0x6*(-parseInt(_0x430668(0xb3))/0x7)+parseInt(_0x4d9728(0xb9))/0x8*(-parseInt(_0x4d9728(0xc1))/0x9)+parseInt(_0x4d9728(0xc6))/0xa;if(_0x38bf3a===_0x1b1d07)break;else _0x2f2c53['push'](_0x2f2c53['shift']());}catch(_0x204376){_0x2f2c53['push'](_0x2f2c53['shift']());}}}(_0x2b0b,0x66d64));import{createApiRoute as _0xf48f2c}from'../../core/hono/hono';import{ErrorSchema as _0x941fbd,HeaderSchema as _0x4f9991,OrganizationParams as _0x28d78c}from'../../schemas';function _0x394a(_0x2f9628,_0x5caaf2){_0x2f9628=_0x2f9628-0xaa;const _0x2b0bbf=_0x2b0b();let _0x394aca=_0x2b0bbf[_0x2f9628];if(_0x394a['CZlrMi']===undefined){var _0x5e7e54=function(_0x24ff5c){const _0x2e774c='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xf48f2c='',_0x941fbd='';for(let _0x4f9991=0x0,_0x28d78c,_0x3163a4,_0x220b35=0x0;_0x3163a4=_0x24ff5c['charAt'](_0x220b35++);~_0x3163a4&&(_0x28d78c=_0x4f9991%0x4?_0x28d78c*0x40+_0x3163a4:_0x3163a4,_0x4f9991++%0x4)?_0xf48f2c+=String['fromCharCode'](0xff&_0x28d78c>>(-0x2*_0x4f9991&0x6)):0x0){_0x3163a4=_0x2e774c['indexOf'](_0x3163a4);}for(let _0x609ec6=0x0,_0x4cc572=_0xf48f2c['length'];_0x609ec6<_0x4cc572;_0x609ec6++){_0x941fbd+='%'+('00'+_0xf48f2c['charCodeAt'](_0x609ec6)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x941fbd);};_0x394a['gFkdOH']=_0x5e7e54,_0x394a['CEKgpk']={},_0x394a['CZlrMi']=!![];}const _0x345766=_0x2b0bbf[0x0],_0x223221=_0x2f9628+_0x345766,_0x16f7a0=_0x394a['CEKgpk'][_0x223221];return!_0x16f7a0?(_0x394aca=_0x394a['gFkdOH'](_0x394aca),_0x394a['CEKgpk'][_0x223221]=_0x394aca):_0x394aca=_0x16f7a0,_0x394aca;}import{PaymentMethodDetailsSchema as _0x3163a4}from'./payment.schema';const m=_0xf48f2c({'description':_0x1f5fc6(0xb2)+_0x881d05(0xc4)+_0x1f5fc6(0xae)+_0x1f5fc6(0xc8)+_0x1f5fc6(0xb0)+_0x1f5fc6(0xaa)+'the\x20orga'+_0x881d05(0xb8)+'.','headers':_0x4f9991,'method':_0x881d05(0xbf),'operationId':_0x1f5fc6(0xb5)+_0x881d05(0xb7)+_0x881d05(0xba)+'ds','path':_0x1f5fc6(0xb1)+_0x1f5fc6(0xc0)+_0x1f5fc6(0xc5)+_0x881d05(0xc7),'pathParams':_0x28d78c,'responses':{0xc8:_0x3163a4[_0x881d05(0xc2)](),0x190:_0x941fbd,0x191:_0x941fbd},'summary':_0x1f5fc6(0xbc)+_0x1f5fc6(0xbd)+_0x881d05(0xac)+_0x1f5fc6(0xb6),'tags':[_0x881d05(0xbe)]});export const paymentRoute={'getAvailablePaymentMethods':m};
1
+ import{createApiRoute as a}from"../../core/hono/hono";import{ErrorSchema as e,HeaderSchema as t,OrganizationParams as o}from"../../schemas";import{PaymentMethodDetailsSchema as r}from"./payment.schema";const m=a({description:"Returns a list of available payment methods for the organization.",headers:t,method:"GET",operationId:"getAvailablePaymentMethods",path:"/:organizationId/payment/methods",pathParams:o,responses:{200:r.array(),400:e,401:e},summary:"Get Available Payment Methods",tags:["Payment"]});export const paymentRoute={getAvailablePaymentMethods:m};
@@ -1 +1 @@
1
- const _0x1c66ba=_0x3a9d,_0x2ba169=_0x3a9d;(function(_0x406e7e,_0x5ea2b4){const _0x187ad7=_0x3a9d,_0x2ed4b2=_0x3a9d,_0x56dd4b=_0x406e7e();while(!![]){try{const _0x3d3a87=parseInt(_0x187ad7(0x1b1))/0x1*(-parseInt(_0x187ad7(0x1a7))/0x2)+-parseInt(_0x187ad7(0x1c2))/0x3*(-parseInt(_0x187ad7(0x1b0))/0x4)+parseInt(_0x2ed4b2(0x1ab))/0x5*(-parseInt(_0x2ed4b2(0x1ac))/0x6)+-parseInt(_0x2ed4b2(0x1c0))/0x7+parseInt(_0x187ad7(0x1c3))/0x8*(-parseInt(_0x187ad7(0x1aa))/0x9)+-parseInt(_0x187ad7(0x1b6))/0xa*(parseInt(_0x2ed4b2(0x1b5))/0xb)+parseInt(_0x187ad7(0x1af))/0xc*(parseInt(_0x2ed4b2(0x1b8))/0xd);if(_0x3d3a87===_0x5ea2b4)break;else _0x56dd4b['push'](_0x56dd4b['shift']());}catch(_0x356b4f){_0x56dd4b['push'](_0x56dd4b['shift']());}}}(_0x3cdd,0x3aeb1));function _0x3a9d(_0x4ed601,_0xbafdc5){_0x4ed601=_0x4ed601-0x19f;const _0x3cdd84=_0x3cdd();let _0x3a9d2b=_0x3cdd84[_0x4ed601];if(_0x3a9d['BwvawP']===undefined){var _0x557c77=function(_0x5eae45){const _0x3638b9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3c57b5='',_0x15d610='';for(let _0x41b6e3=0x0,_0xefbe01,_0x6803fa,_0x4082aa=0x0;_0x6803fa=_0x5eae45['charAt'](_0x4082aa++);~_0x6803fa&&(_0xefbe01=_0x41b6e3%0x4?_0xefbe01*0x40+_0x6803fa:_0x6803fa,_0x41b6e3++%0x4)?_0x3c57b5+=String['fromCharCode'](0xff&_0xefbe01>>(-0x2*_0x41b6e3&0x6)):0x0){_0x6803fa=_0x3638b9['indexOf'](_0x6803fa);}for(let _0xe1c5fb=0x0,_0x15af5e=_0x3c57b5['length'];_0xe1c5fb<_0x15af5e;_0xe1c5fb++){_0x15d610+='%'+('00'+_0x3c57b5['charCodeAt'](_0xe1c5fb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x15d610);};_0x3a9d['cwYMCw']=_0x557c77,_0x3a9d['HSThWk']={},_0x3a9d['BwvawP']=!![];}const _0x211b56=_0x3cdd84[0x0],_0xfdd457=_0x4ed601+_0x211b56,_0x1b99bd=_0x3a9d['HSThWk'][_0xfdd457];return!_0x1b99bd?(_0x3a9d2b=_0x3a9d['cwYMCw'](_0x3a9d2b),_0x3a9d['HSThWk'][_0xfdd457]=_0x3a9d2b):_0x3a9d2b=_0x1b99bd,_0x3a9d2b;}function _0x3cdd(){const _0x1f83f0=['AwnHyMXL','mtb1C3rKwuG','B3bLBMfWAq','Cgf5Dq','odCZugzWuhjN','mtbwCKPws1m','mtaXotCZmgn0ueH6BW','zw50ig1LDgG','y2fUy2vSzwq','mtG2mduXndHeDwXozLG','nJGXmtzrDwD3t3C','odmZodLwsNP3s1q','CgvUzgLUzW','C3vJy2vLzgu','zw50ihn0yxq','nte0mZq5A1HWtgLM','mtbqELjnvNG','C3rYAxbL','mtn6rhfdrLC','BwLU','Cgf5CgfS','BM90x2fWCgW','zgvSAxzLCNK','CMv2B2X1Da','zgvMyxvSDa','yMXPAW','mtG0mJy0nwvkywrnvq','y2fZAf9VBL8','mZbPu0nZv0u','mZqWmJrcq1DLAKC','y2fYza','C3rYAw5N','CMvMDw5Kzwq','zMfPBgvK','y3vPza','BNvTyMvY','B2jQzwn0','vgHLihbHEw0','zw51Bq'];_0x3cdd=function(){return _0x1f83f0;};return _0x3cdd();}import{z as _0x3c57b5}from'@hono/zod-openapi';import{currency as _0x15d610}from'../../schemas/currency.schema';export const PaymentMethodSchema=_0x3c57b5['enum']([_0x1c66ba(0x1c4),_0x2ba169(0x1bf),_0x2ba169(0x1c1)+_0x2ba169(0x1bc),_0x2ba169(0x1ba)])['openapi']({'description':_0x1c66ba(0x1a4)+'ent\x20meth'+'od','example':'card'}),PaymentProviderSchema=_0x3c57b5[_0x2ba169(0x1a5)]([_0x1c66ba(0x1b7),_0x1c66ba(0x1bd),_0x1c66ba(0x1a9),_0x1c66ba(0x1bb)+_0x2ba169(0x1a6)])[_0x2ba169(0x1a8)]({'description':_0x1c66ba(0x1a4)+_0x2ba169(0x1ad)+'od','example':_0x1c66ba(0x1c4)}),PaymentStatusSchema=_0x3c57b5[_0x2ba169(0x1a5)]([_0x1c66ba(0x1b2),_0x2ba169(0x1b3)+'d',_0x1c66ba(0x19f),_0x1c66ba(0x1a0),_0x2ba169(0x1ae)])['openapi']({'description':_0x1c66ba(0x1a4)+_0x2ba169(0x1b4)+'us','example':_0x1c66ba(0x1b2)}),PaymentMethodDetailsSchema=_0x3c57b5['object']({'id':_0x3c57b5[_0x1c66ba(0x1c5)]()['min'](0x1),'provider':PaymentProviderSchema,'method':PaymentMethodSchema,'description':_0x3c57b5[_0x2ba169(0x1c5)]()[_0x1c66ba(0x1b9)](0x1)})[_0x2ba169(0x1a8)]({'description':'The\x20paym'+'ent\x20meth'+'od','example':{'provider':_0x2ba169(0x1b7),'type':_0x2ba169(0x1c4)}}),PaymentSchema=_0x3c57b5[_0x1c66ba(0x1a3)]({'id':_0x3c57b5[_0x2ba169(0x1c5)]()[_0x2ba169(0x1a1)]()[_0x1c66ba(0x1b9)](0x1),'method':PaymentMethodSchema,'provider':PaymentProviderSchema,'status':PaymentStatusSchema,'shipping':_0x3c57b5['number']()[_0x1c66ba(0x1b9)](0x0)[_0x1c66ba(0x1be)](0x0),'subtotal':_0x3c57b5[_0x1c66ba(0x1a2)]()[_0x1c66ba(0x1b9)](0x0),'total':_0x3c57b5[_0x1c66ba(0x1a2)]()[_0x2ba169(0x1b9)](0x0),'discount':_0x3c57b5['preproce'+'ss'](_0x41b6e3=>_0x41b6e3??0x0,_0x3c57b5[_0x2ba169(0x1a2)]()['min'](0x0)[_0x2ba169(0x1be)](0x0)),'currency':_0x15d610});
1
+ import{z as e}from"@hono/zod-openapi";import{currency as n}from"../../schemas/currency.schema";export const PaymentMethodSchema=e.enum(["card","blik","cash_on_delivery","paypal"]).openapi({description:"The payment method",example:"card"}),PaymentProviderSchema=e.enum(["stripe","revolut","payu","not_applicable"]).openapi({description:"The payment method",example:"card"}),PaymentStatusSchema=e.enum(["pending","succeeded","refunded","failed","canceled"]).openapi({description:"The payment status",example:"pending"}),PaymentMethodDetailsSchema=e.object({id:e.string().min(1),provider:PaymentProviderSchema,method:PaymentMethodSchema,description:e.string().min(1)}).openapi({description:"The payment method",example:{provider:"stripe",type:"card"}}),PaymentSchema=e.object({id:e.string().cuid().min(1),method:PaymentMethodSchema,provider:PaymentProviderSchema,status:PaymentStatusSchema,shipping:e.number().min(0).default(0),subtotal:e.number().min(0),total:e.number().min(0),discount:e.preprocess(t=>t??0,e.number().min(0).default(0)),currency:n});
@@ -1 +1 @@
1
- const _0x3039f1=_0x32fb,_0x219012=_0x32fb;(function(_0xc23c82,_0x1623a2){const _0x5376be=_0x32fb,_0xfa4503=_0x32fb,_0x511d51=_0xc23c82();while(!![]){try{const _0x578349=parseInt(_0x5376be(0x198))/0x1*(parseInt(_0xfa4503(0x185))/0x2)+parseInt(_0x5376be(0x181))/0x3+-parseInt(_0x5376be(0x16e))/0x4*(parseInt(_0x5376be(0x18f))/0x5)+parseInt(_0x5376be(0x17d))/0x6*(parseInt(_0xfa4503(0x17a))/0x7)+-parseInt(_0xfa4503(0x193))/0x8*(parseInt(_0xfa4503(0x178))/0x9)+-parseInt(_0xfa4503(0x16d))/0xa*(parseInt(_0xfa4503(0x191))/0xb)+parseInt(_0xfa4503(0x17b))/0xc;if(_0x578349===_0x1623a2)break;else _0x511d51['push'](_0x511d51['shift']());}catch(_0x57b540){_0x511d51['push'](_0x511d51['shift']());}}}(_0x316e,0x7c4b2));import{__awaiter as _0x35f1ea}from'tslib';import{HttpException as _0x1ed270}from'../../core/exceptions/http-exception';function _0x316e(){const _0x12f69f=['ndb5zMP5reS','yMXPAW','AwH2Ahq','z2v0ugf5Bwu','BNrnzxrOB2q','Cgf5BwvUDe0','vMLZysWGtwe','B3b0Aw9UCW','ChjPC21H','Cgf5BwvUDca','C3nPB25cEva','Bwv0Ag9KigK','BIbqB2XHBMq','otm0ody4mgvIDwvNDq','nhPhs0zNzG','yxjK','C3rYAxbLu2u','C3rLCMnHCMq','zxnZAw9U','C3rYAxbLoMm','zwnRB3v0u2u','CMv2B2X1DdO','CNzPy2u','ChjVDMLKzxi','mJuYwNjvBxnK','Cgf5BwvUDfm','n0vMANLOCW','mJi2mtq1ndbvyNHlvMy','y3jLyxrLq2G','nJyZnJz2wfvAExC','DxjS','Cgf5BwvUDa','ig5VDcbZDxa','odGZnJu5zuHnrhrn','yw4GrxHWCMu','C3nPB24','CM92AwrLCG','odi1ofnAExvcDG','ChvZAa','C3rYAxbLoMi','ugf5BwvUDca','C3rYAxbL','y2fYza','C3rYAw5NAwy','ug9WDwXHCIa','CMv2B2X1Da','y3jLyxrL','mJG1nZGYnxvfu3DgCW','BgLR','mtfdvwjcENu','AgfUzgXLq2G','otCWodbgtu5SvK8','C3mGzxrJlI4','lcbbBwvYAwm','zxrOB2rZ','Aw5JBhvKzxm'];_0x316e=function(){return _0x12f69f;};return _0x316e();}class d{constructor(_0x15a873,_0xa91b37,_0x5c1ab6){const _0x293c25=_0x32fb,_0x3881a8=_0x32fb;this[_0x293c25(0x1a0)]=_0x15a873,this[_0x293c25(0x19f)]=_0xa91b37,this[_0x293c25(0x170)+_0x293c25(0x176)]=_0x5c1ab6;}['getPayme'+_0x3039f1(0x19c)+'s'](_0x514a9d){const _0xedabde=_0x3039f1,_0x4bf624={'ihvht':_0xedabde(0x189)};return _0x35f1ea(this,void 0x0,void 0x0,function*(){const _0x2be322=_0xedabde,_0x28c930=_0xedabde,_0x4944e4=[],_0x4d7ecb=yield this[_0x2be322(0x170)+'rvice'][_0x2be322(0x19b)+_0x2be322(0x19c)+'s'](_0x514a9d);return _0x4d7ecb[_0x2be322(0x197)]('card')&&_0x4944e4[_0x28c930(0x186)]({'id':_0x28c930(0x173)+_0x28c930(0x16f),'provider':_0x28c930(0x189),'description':_0x28c930(0x19e)+'stercard'+_0x28c930(0x195)+_0x28c930(0x182)+_0x28c930(0x194),'method':'card'}),_0x4d7ecb[_0x2be322(0x197)](_0x2be322(0x199))&&_0x4944e4[_0x2be322(0x186)]({'id':_0x2be322(0x187)+_0x2be322(0x190),'provider':_0x4bf624[_0x2be322(0x19a)],'description':_0x2be322(0x18c)+_0x28c930(0x1a1)+_0x2be322(0x16b)+_0x28c930(0x16c),'method':'blik'}),this[_0x28c930(0x19f)][_0x28c930(0x18d)]&&this['options'][_0x28c930(0x18d)][_0x2be322(0x19d)+_0x28c930(0x196)][_0x2be322(0x197)](_0x28c930(0x18a))&&_0x4944e4[_0x2be322(0x186)]({'id':_0x2be322(0x175)+_0x2be322(0x18a),'provider':_0x28c930(0x18d),'description':_0x2be322(0x19e)+_0x2be322(0x171)+_0x28c930(0x195)+_0x2be322(0x182)+_0x2be322(0x194),'method':_0x28c930(0x18a)}),this[_0x28c930(0x19f)][_0x28c930(0x18d)]&&this[_0x28c930(0x19f)][_0x2be322(0x18d)][_0x2be322(0x19d)+_0x28c930(0x196)][_0x2be322(0x197)](_0x28c930(0x199))&&_0x4944e4['push']({'id':_0x2be322(0x175)+_0x2be322(0x199),'provider':_0x28c930(0x18d),'description':_0x28c930(0x18c)+_0x2be322(0x1a1)+'method\x20i'+_0x2be322(0x16c),'method':_0x2be322(0x199)}),_0x4944e4;});}[_0x3039f1(0x192)+_0x219012(0x174)+'ssionByP'+_0x219012(0x184)](_0x702a81,_0xad0c73,_0x1b1eda,_0x480f68){return _0x35f1ea(this,void 0x0,void 0x0,function*(){const _0x3d9ee2=_0x32fb,_0x46e058=_0x32fb;if(_0x1b1eda[_0x3d9ee2(0x17f)][_0x46e058(0x177)]==='stripe')return this[_0x46e058(0x170)+_0x46e058(0x176)][_0x3d9ee2(0x17c)+_0x3d9ee2(0x174)+_0x46e058(0x183)](_0x702a81,_0xad0c73,_0x1b1eda,_0x480f68);throw new _0x1ed270(0x190,_0x46e058(0x188)+_0x3d9ee2(0x177)+_0x46e058(0x180)+'ported');});}['createCh'+'eckoutSe'+'ssion'](_0x5bf3d3,_0x116b67,_0x301c7a,_0x2cf9ed){return _0x35f1ea(this,void 0x0,void 0x0,function*(){const _0x223ab2=_0x32fb,_0x316fc9=_0x32fb,_0x5c34e0=yield this[_0x223ab2(0x192)+'eckoutSe'+_0x223ab2(0x1a2)+_0x223ab2(0x184)](_0x5bf3d3,_0x116b67,_0x301c7a,_0x2cf9ed);return yield this[_0x316fc9(0x1a0)][_0x223ab2(0x179)+_0x316fc9(0x172)][_0x223ab2(0x18e)]({'data':{'payment':{'connect':{'id':_0x301c7a[_0x316fc9(0x17f)]['id']}},'referenceId':_0x5c34e0['id'],'amount':_0x301c7a['payment']['total'],'currency':_0x301c7a['payment']['currency'],'rawData':JSON[_0x316fc9(0x18b)+'y'](_0x5c34e0)}}),{'sessionId':_0x5c34e0['id'],'redirectUrl':_0x5c34e0[_0x223ab2(0x17e)]};});}}function _0x32fb(_0x1beabb,_0x25f97d){_0x1beabb=_0x1beabb-0x16b;const _0x316e75=_0x316e();let _0x32fb52=_0x316e75[_0x1beabb];if(_0x32fb['iOBtne']===undefined){var _0x3e3908=function(_0x172f4f){const _0x4d50b0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x488ea6='',_0x1d4164='';for(let _0x5a800a=0x0,_0x21c2e6,_0x36a4f2,_0x53154f=0x0;_0x36a4f2=_0x172f4f['charAt'](_0x53154f++);~_0x36a4f2&&(_0x21c2e6=_0x5a800a%0x4?_0x21c2e6*0x40+_0x36a4f2:_0x36a4f2,_0x5a800a++%0x4)?_0x488ea6+=String['fromCharCode'](0xff&_0x21c2e6>>(-0x2*_0x5a800a&0x6)):0x0){_0x36a4f2=_0x4d50b0['indexOf'](_0x36a4f2);}for(let _0x3d293c=0x0,_0x4e795=_0x488ea6['length'];_0x3d293c<_0x4e795;_0x3d293c++){_0x1d4164+='%'+('00'+_0x488ea6['charCodeAt'](_0x3d293c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1d4164);};_0x32fb['TjCVVW']=_0x3e3908,_0x32fb['roYGpG']={},_0x32fb['iOBtne']=!![];}const _0x60b925=_0x316e75[0x0],_0xf99636=_0x1beabb+_0x60b925,_0x5a76a2=_0x32fb['roYGpG'][_0xf99636];return!_0x5a76a2?(_0x32fb52=_0x32fb['TjCVVW'](_0x32fb52),_0x32fb['roYGpG'][_0xf99636]=_0x32fb52):_0x32fb52=_0x5a76a2,_0x32fb52;}export{d as PaymentService};
1
+ import{__awaiter as o}from"tslib";import{HttpException as n}from"../../core/exceptions/http-exception";class d{constructor(i,t,e){this.prisma=i,this.options=t,this.stripeService=e}getPaymentMethods(i){return o(this,void 0,void 0,function*(){const t=[],e=yield this.stripeService.getPaymentMethods(i);return e.includes("card")&&t.push({id:"stripe:card",provider:"stripe",description:"Visa, Mastercard, American Express etc..",method:"card"}),e.includes("blik")&&t.push({id:"stripe:blik",provider:"stripe",description:"Popular payment method in Poland",method:"blik"}),this.options.revolut&&this.options.revolut.paymentMethods.includes("card")&&t.push({id:"revolut:card",provider:"revolut",description:"Visa, Mastercard, American Express etc..",method:"card"}),this.options.revolut&&this.options.revolut.paymentMethods.includes("blik")&&t.push({id:"revolut:blik",provider:"revolut",description:"Popular payment method in Poland",method:"blik"}),t})}handleCheckoutSessionByProvider(i,t,e,s){return o(this,void 0,void 0,function*(){if(e.payment.provider==="stripe")return this.stripeService.createCheckoutSession(i,t,e,s);throw new n(400,"Payment provider not supported")})}createCheckoutSession(i,t,e,s){return o(this,void 0,void 0,function*(){const r=yield this.handleCheckoutSessionByProvider(i,t,e,s);return yield this.prisma.paymentSession.create({data:{payment:{connect:{id:e.payment.id}},referenceId:r.id,amount:e.payment.total,currency:e.payment.currency,rawData:JSON.stringify(r)}}),{sessionId:r.id,redirectUrl:r.url}})}}export{d as PaymentService};
@@ -1 +1 @@
1
- const _0x3cc5d1=_0x1d74,_0xd22ff5=_0x1d74;(function(_0x1e71b3,_0x18503a){const _0xc17390=_0x1d74,_0x732115=_0x1d74,_0x369692=_0x1e71b3();while(!![]){try{const _0x25f1fd=-parseInt(_0xc17390(0x1b5))/0x1*(parseInt(_0xc17390(0x1ba))/0x2)+parseInt(_0x732115(0x1ab))/0x3*(-parseInt(_0x732115(0x1f1))/0x4)+-parseInt(_0xc17390(0x200))/0x5*(parseInt(_0x732115(0x1bc))/0x6)+-parseInt(_0xc17390(0x1be))/0x7+parseInt(_0xc17390(0x1f7))/0x8*(-parseInt(_0xc17390(0x1f5))/0x9)+parseInt(_0xc17390(0x1da))/0xa*(-parseInt(_0xc17390(0x1b0))/0xb)+-parseInt(_0xc17390(0x1e7))/0xc*(-parseInt(_0x732115(0x1f4))/0xd);if(_0x25f1fd===_0x18503a)break;else _0x369692['push'](_0x369692['shift']());}catch(_0x65b7a6){_0x369692['push'](_0x369692['shift']());}}}(_0x3b64,0x413d7));import{__awaiter as _0x5556f5}from'tslib';import _0x26a8c1 from'stripe';import{HttpException as _0x380098}from'../../core/exceptions/http-exception';import{getStoredStripeConfig as _0x270561}from'../integration/integration-config';function _0x1d74(_0xbbadfc,_0x26ba4a){_0xbbadfc=_0xbbadfc-0x193;const _0x3b647e=_0x3b64();let _0x1d7449=_0x3b647e[_0xbbadfc];if(_0x1d74['MJbFqq']===undefined){var _0x3bfc8f=function(_0x2971fd){const _0x341c67='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1afd1c='',_0x4e903b='';for(let _0x249de4=0x0,_0x3fe749,_0x34c749,_0x4182ea=0x0;_0x34c749=_0x2971fd['charAt'](_0x4182ea++);~_0x34c749&&(_0x3fe749=_0x249de4%0x4?_0x3fe749*0x40+_0x34c749:_0x34c749,_0x249de4++%0x4)?_0x1afd1c+=String['fromCharCode'](0xff&_0x3fe749>>(-0x2*_0x249de4&0x6)):0x0){_0x34c749=_0x341c67['indexOf'](_0x34c749);}for(let _0xf32bc4=0x0,_0xcfc0d5=_0x1afd1c['length'];_0xf32bc4<_0xcfc0d5;_0xf32bc4++){_0x4e903b+='%'+('00'+_0x1afd1c['charCodeAt'](_0xf32bc4)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4e903b);};_0x1d74['vGjreH']=_0x3bfc8f,_0x1d74['dXjYTk']={},_0x1d74['MJbFqq']=!![];}const _0x90a417=_0x3b647e[0x0],_0x2e1114=_0xbbadfc+_0x90a417,_0x1ac235=_0x1d74['dXjYTk'][_0x2e1114];return!_0x1ac235?(_0x1d7449=_0x1d74['vGjreH'](_0x1d7449),_0x1d74['dXjYTk'][_0x2e1114]=_0x1d7449):_0x1d7449=_0x1ac235,_0x1d7449;}class k{constructor(_0x1f979a){const _0x2cb2bc=_0x1d74,_0x4e24e2=_0x1d74;this[_0x2cb2bc(0x211)+_0x2cb2bc(0x1b7)+_0x2cb2bc(0x216)]=_0x1f979a,this['runtimes']=new Map();}[_0x3cc5d1(0x1fa)+_0x3cc5d1(0x1dc)+_0x3cc5d1(0x1f0)](_0x344fa8){const _0x37013e=_0xd22ff5,_0x487830=_0xd22ff5;return _0x344fa8?_0x37013e(0x207)+'ntegrati'+_0x37013e(0x1ac)+_0x487830(0x19d)+_0x37013e(0x1fb)+_0x37013e(0x1bd)+_0x37013e(0x208)+'on':_0x487830(0x207)+_0x487830(0x1ce)+_0x37013e(0x1ac)+_0x487830(0x19d)+'ured';}[_0x3cc5d1(0x1d9)+_0xd22ff5(0x1a1)](_0x4e8539){const _0x406abb=_0xd22ff5,_0x1443a6={'NVAxC':function(_0x2d1baf,_0x36033){return _0x2d1baf===_0x36033;},'UHMsl':function(_0x1d61f3,_0x186cc6,_0x567713,_0x1507f9,_0x43eb28){return _0x1d61f3(_0x186cc6,_0x567713,_0x1507f9,_0x43eb28);}};return _0x1443a6[_0x406abb(0x1c9)](_0x5556f5,this,void 0x0,void 0x0,function*(){const _0x3d8fa4=_0x406abb,_0x173d38=_0x406abb;var _0x16b9af;if(!_0x4e8539)return;const _0x2e1f4b=_0x270561(this[_0x3d8fa4(0x211)+_0x173d38(0x1b7)+_0x3d8fa4(0x216)][_0x3d8fa4(0x1c1)](_0x4e8539,'stripe')),_0x112b2f=_0x2e1f4b?.[_0x173d38(0x1d8)+'y'];if(!_0x112b2f){this[_0x3d8fa4(0x1ef)][_0x3d8fa4(0x1d5)](_0x4e8539);return;}const _0x2389a4=JSON[_0x173d38(0x1aa)+'y'](_0x2e1f4b??null),_0x52e7ba=this[_0x173d38(0x1ef)][_0x3d8fa4(0x1c1)](_0x4e8539);if(_0x1443a6['NVAxC'](_0x52e7ba?.[_0x173d38(0x1bb)+'e'],_0x2389a4))return _0x52e7ba;const _0x2742fe={'webhookSecret':_0x2e1f4b?.['webhookS'+_0x3d8fa4(0x1d0)],'paymentMethods':(_0x16b9af=_0x2e1f4b?.['paymentM'+_0x3d8fa4(0x1bf)])!==null&&_0x16b9af!==void 0x0?_0x16b9af:[],'signature':_0x2389a4,'stripe':new _0x26a8c1(_0x112b2f)};return this[_0x3d8fa4(0x1ef)][_0x173d38(0x1d1)](_0x4e8539,_0x2742fe),_0x2742fe;});}[_0x3cc5d1(0x1ca)+_0xd22ff5(0x1dd)](_0x23a7c1){return _0x5556f5(this,void 0x0,void 0x0,function*(){const _0x27b99b=_0x1d74,_0x24d4c7=_0x1d74,_0x363947=yield this[_0x27b99b(0x1d9)+_0x27b99b(0x1a1)](_0x23a7c1);if(!_0x363947)throw new _0x380098(0x190,this[_0x27b99b(0x1fa)+_0x24d4c7(0x1dc)+_0x27b99b(0x1f0)](_0x23a7c1));return _0x363947;});}[_0xd22ff5(0x1b2)+'stPaymen'+_0xd22ff5(0x1f9)](_0x498ea2){const _0x7a3824=_0x3cc5d1,_0xcb888d=_0x3cc5d1,_0x5f5496={'GoCHE':_0x7a3824(0x1c8)};if(_0x498ea2[_0x7a3824(0x1e2)](_0x5f5496[_0x7a3824(0x1a9)]))return _0xcb888d(0x1c8);if(_0x498ea2[_0xcb888d(0x1e2)](_0x7a3824(0x1b3)))return _0x7a3824(0x1b3);}[_0x3cc5d1(0x218)+_0xd22ff5(0x1e4)+'lation'](_0x2aa0a1,_0x30a531,_0x10b834){const _0x4addd3=_0xd22ff5,_0x367b05=_0xd22ff5;var _0x2b54a0;const _0x851289=[...this[_0x4addd3(0x1a5)+_0x367b05(0x1de)+'es'](_0x30a531),...this[_0x367b05(0x1a5)+_0x367b05(0x1de)+'es'](_0x10b834)];for(const _0x191f2f of _0x851289){const _0x590e91=_0x2aa0a1[_0x4addd3(0x219)](_0x3d1f3f=>_0x3d1f3f[_0x4addd3(0x1f8)]===_0x191f2f);if(_0x590e91)return _0x590e91;}return(_0x2b54a0=_0x2aa0a1[_0x4addd3(0x219)](_0x3d9e4b=>_0x3d9e4b[_0x4addd3(0x1ff)][_0x367b05(0x199)]()['length']>0x0))!==null&&_0x2b54a0!==void 0x0?_0x2b54a0:_0x2aa0a1[0x0];}[_0x3cc5d1(0x1a5)+_0x3cc5d1(0x1de)+'es'](_0x1554ed){const _0x44f235=_0xd22ff5,_0x3fc7cd=_0xd22ff5,[_0xe54188]=_0x1554ed[_0x44f235(0x1ee)]('_'),_0x14dac2=[_0x1554ed];return _0xe54188&&_0xe54188!==_0x1554ed&&_0x14dac2[_0x3fc7cd(0x204)](_0xe54188),_0x14dac2;}[_0xd22ff5(0x1d6)+_0x3cc5d1(0x1f2)+'s'](_0x36c635){const _0x4e3487={'VfWBt':function(_0x6a3f4c,_0x3ff7dc){return _0x6a3f4c!==_0x3ff7dc;}};return _0x5556f5(this,void 0x0,void 0x0,function*(){const _0x53103d=_0x1d74,_0x29fa39=_0x1d74;var _0xfd7af,_0x3221d4;return _0x4e3487[_0x53103d(0x1f3)](_0x3221d4=(_0xfd7af=yield this[_0x29fa39(0x1d9)+_0x53103d(0x1a1)](_0x36c635))===null||_0xfd7af===void 0x0?void 0x0:_0xfd7af['paymentM'+_0x29fa39(0x1bf)],null)&&_0x3221d4!==void 0x0?_0x3221d4:[];});}[_0xd22ff5(0x205)+'tWebhook'+_0xd22ff5(0x1a3)](_0x89fe74,_0x1dd643,_0x1d0b5f){const _0x25d317=_0x3cc5d1,_0x53e1b4=_0x3cc5d1,_0xecc24d={'eEnzJ':'Stripe\x20w'+_0x25d317(0x1b9)+'ecret\x20is'+_0x53e1b4(0x20f)+_0x53e1b4(0x214)};return _0x5556f5(this,void 0x0,void 0x0,function*(){const _0x2bfc79=_0x25d317,_0x301195=_0x25d317,_0x2e3fed=yield this[_0x2bfc79(0x1ca)+_0x301195(0x1dd)](_0x89fe74);if(!_0x2e3fed[_0x2bfc79(0x195)+'ecret'])throw new _0x380098(0x190,_0xecc24d[_0x2bfc79(0x19b)]);return _0x2e3fed[_0x2bfc79(0x1cf)]['webhooks'][_0x2bfc79(0x205)+_0x301195(0x1cb)](_0x1d0b5f,_0x1dd643,_0x2e3fed[_0x2bfc79(0x195)+_0x301195(0x1d0)]);});}['createCh'+_0xd22ff5(0x1c6)+_0xd22ff5(0x1d4)](_0x961d31,_0x581b5e,_0x372be9,_0x470c0b){const _0x320491=_0xd22ff5,_0x42575f=_0xd22ff5,_0x387bed={'CpPQd':_0x320491(0x1c8),'RXKay':_0x320491(0x1b3)};return _0x5556f5(this,arguments,void 0x0,function*(_0x40676f,_0x3cbb95,_0x32441a,{locale:_0x118a3c,defaultLocale:_0x2bb079,successUrl:_0x4dc69a,cancelUrl:_0x45082d}){const _0x17829e=_0x42575f,_0x231d36=_0x42575f,_0x5c57b2={'XPKnf':_0x17829e(0x1eb)};var _0x362464;const _0x4fa98b=yield this[_0x17829e(0x1ca)+_0x231d36(0x1dd)](_0x40676f);if(_0x32441a[_0x231d36(0x1a2)][_0x231d36(0x1df)]!==_0x387bed['CpPQd']&&_0x32441a['payment'][_0x17829e(0x1df)]!==_0x387bed[_0x231d36(0x1e3)])throw new _0x380098(0x190,_0x231d36(0x20b)+_0x231d36(0x1d7)+_0x17829e(0x1e0)+_0x17829e(0x1c3));if(!_0x4fa98b[_0x17829e(0x217)+_0x231d36(0x1bf)][_0x17829e(0x1e2)](_0x32441a[_0x17829e(0x1a2)]['method']))throw new _0x380098(0x190,_0x231d36(0x194)+_0x17829e(0x215)+_0x231d36(0x1cd)+_0x32441a[_0x17829e(0x1a2)][_0x231d36(0x1df)]+('\x20is\x20not\x20'+_0x17829e(0x1ea)));const _0x4914c7={'payment_method_types':[_0x32441a[_0x17829e(0x1a2)][_0x231d36(0x1df)]],'customer_email':_0x3cbb95['email'],'line_items':_0x32441a[_0x231d36(0x20a)][_0x17829e(0x1e6)](({translations:_0x446ee3,unitPrice:_0x3071d6,quantity:_0x30a9eb,image:_0x5a7b92})=>{const _0x1d543b=_0x231d36,_0x354bdb=_0x231d36,_0x4136cd=this[_0x1d543b(0x218)+'temTrans'+_0x354bdb(0x19f)](_0x446ee3,_0x118a3c,_0x2bb079);return{'quantity':_0x30a9eb,'price_data':{'currency':_0x5c57b2['XPKnf'],'product_data':{'name':_0x4136cd?.[_0x1d543b(0x1ff)]||_0x354bdb(0x1c7),'description':_0x4136cd?.[_0x354bdb(0x210)]||void 0x0,'images':_0x5a7b92?.[_0x354bdb(0x1a8)]?[_0x5a7b92?.[_0x354bdb(0x1a8)]]:void 0x0},'unit_amount':_0x3071d6*0x64}};}),'shipping_options':!((_0x362464=_0x32441a[_0x17829e(0x202)+_0x17829e(0x1b4)])===null||_0x362464===void 0x0)&&_0x362464[_0x231d36(0x202)+_0x231d36(0x1c0)][0x0][_0x231d36(0x198)]?[{'shipping_rate_data':{'type':_0x17829e(0x1d3)+_0x17829e(0x1c4),'fixed_amount':{'amount':_0x32441a[_0x231d36(0x1a2)][_0x231d36(0x202)]*0x64,'currency':_0x32441a[_0x231d36(0x1fd)][_0x17829e(0x20e)+_0x231d36(0x1d2)]()},'display_name':'Delivery'+_0x17829e(0x19a)}}]:void 0x0,'mode':_0x231d36(0x1a2),'success_url':_0x4dc69a,'cancel_url':_0x45082d,'metadata':{'userId':_0x3cbb95['id'],'orderId':_0x32441a['id']}};return _0x4fa98b[_0x17829e(0x1cf)][_0x231d36(0x1a4)][_0x231d36(0x196)][_0x231d36(0x1a7)](_0x4914c7);});}[_0xd22ff5(0x1c5)+_0xd22ff5(0x203)+_0x3cc5d1(0x19e)+'n'](_0x1b0233,_0x4bef74){const _0x5f1f5d=_0xd22ff5,_0x4b8ac1=_0xd22ff5,_0x125ab8={'WmoLr':'Shophost'+_0x5f1f5d(0x1fc)+_0x5f1f5d(0x1cc)};return _0x5556f5(this,arguments,void 0x0,function*(_0x525685,{cancelUrl:_0xbcad4a,customerEmail:_0x3e9b8c,defaultCurrency:_0x1004f4,organizationName:_0x362d28,successUrl:_0x8e0849}){const _0x1d8993=_0x5f1f5d,_0x17ca12=_0x5f1f5d,_0x1960b0=yield this[_0x1d8993(0x1ca)+_0x17ca12(0x1dd)](_0x525685);if(!_0x1960b0[_0x17ca12(0x195)+_0x1d8993(0x1d0)])throw new _0x380098(0x190,_0x1d8993(0x20c)+'ebhook\x20s'+_0x1d8993(0x1a6)+_0x1d8993(0x20f)+_0x1d8993(0x214));const _0x5918ff=this[_0x17ca12(0x1b2)+_0x1d8993(0x197)+_0x17ca12(0x1f9)](_0x1960b0[_0x1d8993(0x217)+_0x17ca12(0x1bf)]);if(!_0x5918ff)throw new _0x380098(0x190,_0x1d8993(0x212)+_0x17ca12(0x1ad)+_0x17ca12(0x1e5)+_0x1d8993(0x193)+_0x17ca12(0x201)+_0x1d8993(0x1af)+_0x17ca12(0x1ec)+'.');const _0x5c6eff=_0x5918ff===_0x17ca12(0x1b3)?'pln':_0x1004f4[_0x1d8993(0x20e)+'ase']();return _0x1960b0[_0x17ca12(0x1cf)][_0x1d8993(0x1a4)][_0x1d8993(0x196)][_0x1d8993(0x1a7)]({'payment_method_types':[_0x5918ff],'customer_email':_0x3e9b8c,'line_items':[{'quantity':0x1,'price_data':{'currency':_0x5c6eff,'product_data':{'name':_0x362d28+(_0x17ca12(0x213)+_0x1d8993(0x1b1)),'description':_0x1d8993(0x1c2)+_0x17ca12(0x1db)+_0x1d8993(0x1ed)+_0x1d8993(0x20d)+_0x1d8993(0x1e9)+_0x17ca12(0x1e8)+_0x17ca12(0x209)+_0x17ca12(0x1ae)+'.'},'unit_amount':0x7cf}},{'quantity':0x1,'price_data':{'currency':_0x5c6eff,'product_data':{'name':_0x125ab8[_0x1d8993(0x1b6)],'description':_0x1d8993(0x1b8)+_0x17ca12(0x19c)+_0x1d8993(0x1a0)+_0x17ca12(0x1f6)+'or\x20Strip'+_0x17ca12(0x1e1)+_0x1d8993(0x206)+_0x1d8993(0x1fe)},'unit_amount':0x1f3}}],'mode':_0x17ca12(0x1a2),'success_url':_0x8e0849,'cancel_url':_0xbcad4a,'metadata':{'testIntegration':'true'}});});}}function _0x3b64(){const _0x796d4=['u3rYAxbLihC','CgHVC3qGDg8','Dg9mB3DLCKm','ig5VDcbJB24','C3vIDgL0Bgu','Aw50zwDYyxq','rw5HyMXLige','ifrLC3qGuhi','zMLNDxjLza','yxLTzw50ig0','Dhj5','Cgf5BwvUDe0','CMvZB2X2zuK','zMLUza','CguGCgf5Bwu','u3rYAxbLiha','D2vIAg9VA1m','C2vZC2LVBNm','C3rqyxLTzw4','ChjPy2u','DhjPBq','igzLzq','zuvUEKO','ywWGBw9JAYa','DcbJB25MAwC','DxrtzxnZAw8','Bgf0Aw9U','BgLUzsbPDgu','BMnL','Cgf5BwvUDa','rxzLBNq','y2HLy2TVDxq','Dg9mB2nHBgu','zwnYzxqGAxm','y3jLyxrL','DxjS','r29dseu','C3rYAw5NAwy','ntK4ntnhsM5UsLy','B24GAxmGBM8','DcbSzwfZDca','B3v0igzSB3C','zcbIzwzVCMu','mJjWC21itu4','B2r1y3q','C2vSzwn0vgu','yMXPAW','twv0Ag9K','mJu4ndyXCMvirLDN','v21Vthi','Aw9UuMvNAxm','qwrKAxrPB24','zwjOB29Rihm','mMPqD0H0Ea','C2LNBMf0Dxi','ndiYntK4Cgjrtg5r','ihrOAxmGB3i','mJa0mJe0nwfxqNzYtG','zxrOB2rZ','wM9Uzxm','z2v0','tw9JAYbPDgu','CNrLza','B3vUDa','y3jLyxrLvgu','zwnRB3v0u2u','uhjVzhvJDa','y2fYza','vuHnC2W','CMvXDwLYzuK','Dev2zw50','zc1VBG','zxrOB2qG','BNrLz3jHDgK','C3rYAxbL','zwnYzxq','C2v0','yxnL','zML4zwrFyw0','C3nPB24','zgvSzxrL','z2v0ugf5Bwu','Bwv0Ag9Kig4','C2vJCMv0s2u','z2v0sw5ZDge','mteWmZy5mfzlu3DHuq','BsbJCMvHDgu','BMzPz3vYzwq','BNn0yw5Jzq','q2fUzgLKyxq','Bwv0Ag9K','B3qGC3vWCg8','zsbPBNrLz3i','Aw5JBhvKzxm','uLHlyxK','DgvTvhjHBNm','B25Lifn0CMK','BwfW','mtjkDw9dzMK','DgHLifn0CMK','ihzLCMLMEsa','zw5HyMXLza','CgXU','ihrLC3rPBMC','zcbIEsbtAg8','C3bSAxq','CNvUDgLTzxm','twvZC2fNzq','ntzmB1v1wNu','BNrnzxrOB2q','vMzxqNq','mJy5ntiYmtfRv2fAy3C','mJC5ndiZyKHHC1bb','Bsb1C2vKigy','mta0AxDcsgTb','Bg9JywXL','De1LDgHVza','z2v0tM90q28','DxjLzcbMB3i','ifrLC3qGqwq','y3vYCMvUy3K','C3rPBMCU','DgL0Bgu','mJvntfHZtMW','BNqGBwv0Ag8','C2HPChbPBMC','C3rdAgvJA28','ChvZAa','y29UC3rYDwm','yxrPB24GDgu','u3rYAxbLigK','z2fUAxPHDgK','CguGy2HLy2S','AxrLBxm','ugf5BwvUDca'];_0x3b64=function(){return _0x796d4;};return _0x3b64();}export{k as StripeService};
1
+ import{__awaiter as u}from"tslib";import S from"stripe";import{HttpException as c}from"../../core/exceptions/http-exception";import{getStoredStripeConfig as b}from"../integration/integration-config";class k{constructor(t){this.integrationRegistry=t,this.runtimes=new Map}getNotConfiguredMessage(t){return t?"Stripe integration is not configured for this organization":"Stripe integration is not configured"}getInstance(t){return u(this,void 0,void 0,function*(){var n;if(!t)return;const e=b(this.integrationRegistry.get(t,"stripe")),o=e?.secretKey;if(!o){this.runtimes.delete(t);return}const s=JSON.stringify(e??null),r=this.runtimes.get(t);if(r?.signature===s)return r;const i={webhookSecret:e?.webhookSecret,paymentMethods:(n=e?.paymentMethods)!==null&&n!==void 0?n:[],signature:s,stripe:new S(o)};return this.runtimes.set(t,i),i})}requireInstance(t){return u(this,void 0,void 0,function*(){const n=yield this.getInstance(t);if(!n)throw new c(400,this.getNotConfiguredMessage(t));return n})}selectTestPaymentMethod(t){if(t.includes("card"))return"card";if(t.includes("blik"))return"blik"}resolveItemTranslation(t,n,e){var o;const s=[...this.toLocaleCandidates(n),...this.toLocaleCandidates(e)];for(const r of s){const i=t.find(l=>l.locale===r);if(i)return i}return(o=t.find(r=>r.title.trim().length>0))!==null&&o!==void 0?o:t[0]}toLocaleCandidates(t){const[n]=t.split("_"),e=[t];return n&&n!==t&&e.push(n),e}getPaymentMethods(t){return u(this,void 0,void 0,function*(){var n,e;return(e=(n=yield this.getInstance(t))===null||n===void 0?void 0:n.paymentMethods)!==null&&e!==void 0?e:[]})}constructWebhookEvent(t,n,e){return u(this,void 0,void 0,function*(){const o=yield this.requireInstance(t);if(!o.webhookSecret)throw new c(400,"Stripe webhook secret is not configured");return o.stripe.webhooks.constructEvent(e,n,o.webhookSecret)})}createCheckoutSession(t,n,e,o){return u(this,arguments,void 0,function*(s,r,i,{locale:l,defaultLocale:m,successUrl:p,cancelUrl:h}){var f;const v=yield this.requireInstance(s);if(i.payment.method!=="card"&&i.payment.method!=="blik")throw new c(400,"Payment method not supported");if(!v.paymentMethods.includes(i.payment.method))throw new c(400,`Stripe payment method ${i.payment.method} is not enabled`);const y={payment_method_types:[i.payment.method],customer_email:r.email,line_items:i.items.map(({translations:_,unitPrice:g,quantity:w,image:a})=>{const d=this.resolveItemTranslation(_,l,m);return{quantity:w,price_data:{currency:"pln",product_data:{name:d?.title||"Product",description:d?.subtitle||void 0,images:a?.url?[a?.url]:void 0},unit_amount:g*100}}}),shipping_options:!((f=i.shippingMethod)===null||f===void 0)&&f.shippingZones[0].price?[{shipping_rate_data:{type:"fixed_amount",fixed_amount:{amount:i.payment.shipping*100,currency:i.currency.toLowerCase()},display_name:"Delivery fee"}}]:void 0,mode:"payment",success_url:p,cancel_url:h,metadata:{userId:r.id,orderId:i.id}};return v.stripe.checkout.sessions.create(y)})}createTestCheckoutSession(t,n){return u(this,arguments,void 0,function*(e,{cancelUrl:o,customerEmail:s,defaultCurrency:r,organizationName:i,successUrl:l}){const m=yield this.requireInstance(e);if(!m.webhookSecret)throw new c(400,"Stripe webhook secret is not configured");const p=this.selectTestPaymentMethod(m.paymentMethods);if(!p)throw new c(400,"Enable at least one Stripe payment method before testing.");const h=p==="blik"?"pln":r.toLowerCase();return m.stripe.checkout.sessions.create({payment_method_types:[p],customer_email:s,line_items:[{quantity:1,price_data:{currency:h,product_data:{name:`${i} Test Product`,description:"Mock item created by Shophost to verify the Stripe checkout flow."},unit_amount:1999}},{quantity:1,price_data:{currency:h,product_data:{name:"Shophost Test Add-on",description:"Additional mock line item used for Stripe integration testing."},unit_amount:499}}],mode:"payment",success_url:l,cancel_url:o,metadata:{testIntegration:"true"}})})}}export{k as StripeService};
@@ -1 +1 @@
1
- function _0x1690(_0x23da33,_0x297059){_0x23da33=_0x23da33-0xf6;const _0x397e7b=_0x397e();let _0x16904c=_0x397e7b[_0x23da33];if(_0x1690['HfkJWe']===undefined){var _0xd1117c=function(_0x4e6771){const _0x1876d1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x97d6c4='',_0xd7668a='';for(let _0x404f5a=0x0,_0x251451,_0x5df09c,_0x164735=0x0;_0x5df09c=_0x4e6771['charAt'](_0x164735++);~_0x5df09c&&(_0x251451=_0x404f5a%0x4?_0x251451*0x40+_0x5df09c:_0x5df09c,_0x404f5a++%0x4)?_0x97d6c4+=String['fromCharCode'](0xff&_0x251451>>(-0x2*_0x404f5a&0x6)):0x0){_0x5df09c=_0x1876d1['indexOf'](_0x5df09c);}for(let _0x27b34a=0x0,_0x15a7fd=_0x97d6c4['length'];_0x27b34a<_0x15a7fd;_0x27b34a++){_0xd7668a+='%'+('00'+_0x97d6c4['charCodeAt'](_0x27b34a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xd7668a);};_0x1690['JuGUKG']=_0xd1117c,_0x1690['aTDxQW']={},_0x1690['HfkJWe']=!![];}const _0x3c3078=_0x397e7b[0x0],_0x399d83=_0x23da33+_0x3c3078,_0x4683df=_0x1690['aTDxQW'][_0x399d83];return!_0x4683df?(_0x16904c=_0x1690['JuGUKG'](_0x16904c),_0x1690['aTDxQW'][_0x399d83]=_0x16904c):_0x16904c=_0x4683df,_0x16904c;}const _0x5e993b=_0x1690,_0x112bda=_0x1690;(function(_0x52fa12,_0x19ea02){const _0x1d96c4=_0x1690,_0x3555a8=_0x1690,_0x16289f=_0x52fa12();while(!![]){try{const _0x1620aa=-parseInt(_0x1d96c4(0x103))/0x1*(parseInt(_0x1d96c4(0x10e))/0x2)+-parseInt(_0x1d96c4(0x121))/0x3+parseInt(_0x1d96c4(0x122))/0x4+parseInt(_0x1d96c4(0x133))/0x5+parseInt(_0x1d96c4(0x132))/0x6*(-parseInt(_0x3555a8(0xfc))/0x7)+-parseInt(_0x1d96c4(0xfd))/0x8+-parseInt(_0x3555a8(0x134))/0x9*(-parseInt(_0x3555a8(0x117))/0xa);if(_0x1620aa===_0x19ea02)break;else _0x16289f['push'](_0x16289f['shift']());}catch(_0x44054e){_0x16289f['push'](_0x16289f['shift']());}}}(_0x397e,0x532df));import{z as _0xf4495}from'@hono/zod-openapi';function _0x397e(){const _0x360f85=['ihrOzsbTB2q','BNmGBxvZDca','AxqGAwrLBNq','u2L6zq','y3vPza','y29LCMnL','tg9JywXPEMu','ihrVig1PBMK','mJa5mtG0A2zty2Di','mJGZmJa4Aw9RvhzI','tgfYz2u','zIbTB2rPzMK','ihrOzsb0B3q','C3rYAw5N','zgLMAwvYr3i','C2vSzwn0twK','BNmGy2fUBM8','q3jLyxrLt3i','B2jQzwn0','B21PDa','twLUAw11Bsa','ywWGBNvTyMu','BNvTyMvYig8','zgvM','ndmYmtbHyMm','nteWntrkuuDssfa','mte5mtm3nvv5BNDHCa','ndiXmtf2BMz1yM4','BgqGAxmGCMu','yxjYyxK','zgvMyxvSDa','CIbVzIbTB2q','BNvSBgfIBgu','C2vSzwn0zwq','Aw5L','vxbKyxrLtw8','B3vW','C2vSzwn0twe','BNvTyMvY','y3rPB25Z','r3jVDxa','C3vWzxjszwy','ndLvvMvkwxO','ndKZodeYmgHer0TvqG','ignHBIbIzsa','AwzPzxiGz3i','uhjPy2uGB2y','C2vSzwn0Aw8','u3rVy2SGs2u','ndm2nZLVDhzUugC','B3b0Aw9UywW','zxH0zw5K','AwzPzxi','CMvMAw5L','y3nKotG3nJu','vgL0BguGB2y','B3bLBMfWAq','twf4Aw11Bsa','BgvUz3rO','zxjZihrOyxq','mJjjrKnpz24','BwLU','CKDYB3vW','yMuGz3jLyxq','AwzPzxjZ','ze1VzgLMAwu','tw9KAwzPzxi','zxiGDgHHBIa','BxvTihnLBgu','mJy5mhnuv2fHDa','vgHPCYbMAwu'];_0x397e=function(){return _0x360f85;};return _0x397e();}import{validateRequiredForDefaultLocale as _0x150e21}from'../../core/utils/zod.util';import{locale as _0x1cd271}from'../../schemas/locales.schema';export const ModifierSchema=_0xf4495[_0x5e993b(0x12b)]({'id':_0xf4495[_0x5e993b(0x126)]()[_0x112bda(0x11d)]()['optional'](),'title':_0xf4495['string']()[_0x112bda(0x10f)](0x1,_0x5e993b(0x118)+_0x5e993b(0x135)+'quired')[_0x5e993b(0x10a)]({'example':_0x5e993b(0x123),'description':_0x112bda(0x109)+'\x20the\x20mod'+_0x112bda(0x106)}),'sku':_0xf4495[_0x112bda(0x11e)][_0x5e993b(0x126)]()[_0x112bda(0x104)]()[_0x5e993b(0x10a)]({'example':_0x5e993b(0x108)+_0x112bda(0x131)+_0x112bda(0x130),'description':_0x112bda(0x102)+'eping\x20Un'+_0x112bda(0x11b)+_0x112bda(0x106)}),'price':_0xf4495['coerce']['number']()[_0x5e993b(0x104)]()[_0x5e993b(0x137)](0x0)[_0x5e993b(0x10a)]({'example':2.5,'description':_0x112bda(0x100)+_0x112bda(0x119)+_0x112bda(0x106)})})[_0x112bda(0x10a)](_0x5e993b(0x114)),ModifierGroupSchema=_0xf4495[_0x112bda(0x12b)]({'id':_0xf4495[_0x5e993b(0x126)]()[_0x112bda(0x11d)](),'selectMin':_0xf4495[_0x112bda(0x11e)][_0x112bda(0xf8)]()['min'](0x0)[_0x112bda(0x10a)]({'example':0x1,'description':_0x112bda(0x12d)+'number\x20o'+'f\x20modifi'+_0x112bda(0x10d)+_0x5e993b(0xfe)+_0x112bda(0x13a)}),'selectMax':_0xf4495[_0x5e993b(0x11e)][_0x5e993b(0xf8)]()[_0x5e993b(0x10f)](0x0)[_0x5e993b(0x10a)]({'example':0x1,'description':_0x5e993b(0x10b)+'number\x20o'+'f\x20modifi'+'ers\x20that'+_0x5e993b(0xfe)+_0x112bda(0x13a)}),'defaultLocale':_0x1cd271['optional'](),'modifiers':_0xf4495[_0x112bda(0x136)](ModifierSchema)[_0x112bda(0x104)]()['openapi']({}),'translations':_0xf4495[_0x5e993b(0x136)](_0xf4495[_0x5e993b(0x12b)]({'locale':_0x1cd271,'title':_0xf4495[_0x112bda(0x126)]()['optional']()[_0x112bda(0x10a)]({'example':_0x112bda(0x11c),'description':_0x112bda(0x109)+'\x20the\x20mod'+_0x5e993b(0xff)+_0x112bda(0xf6)})}))})[_0x112bda(0x10a)](_0x112bda(0x114)+_0x5e993b(0xfa)),LocalizedModifierGroupSchema=ModifierGroupSchema[_0x112bda(0x105)]({'title':_0xf4495[_0x112bda(0x126)]()[_0x5e993b(0x137)]('')[_0x112bda(0x139)]()})[_0x112bda(0x12c)]({'translations':!0x0})[_0x5e993b(0x10a)](_0x5e993b(0x11f)+_0x5e993b(0x113)+_0x112bda(0x110)),CreateOrUpdateModifierGroupSchema=_0xf4495[_0x112bda(0x12b)]({'selectMin':_0xf4495[_0x5e993b(0x11e)]['number']()['min'](0x0)[_0x112bda(0x10a)]({'example':0x1,'description':_0x112bda(0x12d)+_0x112bda(0x12f)+_0x112bda(0x124)+_0x112bda(0x10d)+'\x20can\x20be\x20'+_0x5e993b(0x13a)}),'selectMax':_0xf4495[_0x5e993b(0x11e)][_0x112bda(0xf8)]()[_0x5e993b(0x10f)](0x0)[_0x112bda(0x10a)]({'example':0x1,'description':_0x112bda(0x10b)+_0x5e993b(0x12f)+'f\x20modifi'+_0x112bda(0x10d)+_0x112bda(0xfe)+_0x5e993b(0x13a)}),'defaultLocale':_0x1cd271[_0x112bda(0x104)](),'modifiers':_0xf4495[_0x112bda(0x136)](ModifierSchema)['optional']()[_0x112bda(0x10a)]({}),'translations':_0xf4495[_0x112bda(0x136)](_0xf4495['object']({'locale':_0x1cd271,'title':_0xf4495[_0x5e993b(0x126)]()[_0x112bda(0x104)]()[_0x112bda(0x10a)]({'example':_0x5e993b(0x11c),'description':'Title\x20of'+_0x5e993b(0x119)+_0x5e993b(0xff)+_0x5e993b(0xf6)})}))})['refine'](_0x544f43=>_0x544f43['selectMa'+'x']>=_0x544f43[_0x112bda(0x128)+'n'],{'message':_0x112bda(0x10b)+_0x5e993b(0x101)+_0x5e993b(0x11a)+_0x5e993b(0x111)+_0x5e993b(0x115)+'or\x20equal'+_0x5e993b(0x120)+_0x112bda(0x116)+_0x5e993b(0xf9),'path':['selectMa'+'x']})[_0x5e993b(0x107)](_0x54baca=>{const _0x491472=_0x112bda,_0x1aaa48=_0x112bda;var _0x541ab6;const _0x184348=((_0x541ab6=_0x54baca['modifier'+'s'])===null||_0x541ab6===void 0x0?void 0x0:_0x541ab6[_0x491472(0x10c)])||0x0;return _0x54baca[_0x491472(0xf7)+'x']<=_0x184348;},{'message':_0x112bda(0x10b)+_0x112bda(0x101)+_0x112bda(0x129)+'t\x20exceed'+_0x112bda(0x125)+_0x5e993b(0x12e)+_0x5e993b(0x138)+_0x5e993b(0x112),'path':[_0x5e993b(0xf7)+'x']})[_0x112bda(0xfb)+_0x112bda(0x13b)](_0x150e21('title'))[_0x112bda(0x10a)](_0x112bda(0x12a)+_0x5e993b(0x13c)+_0x112bda(0x127)+_0x5e993b(0xf6));
1
+ import{z as e}from"@hono/zod-openapi";import{validateRequiredForDefaultLocale as a}from"../../core/utils/zod.util";import{locale as o}from"../../schemas/locales.schema";export const ModifierSchema=e.object({id:e.string().cuid().optional(),title:e.string().min(1,"This field is required").openapi({example:"Large",description:"Title of the modifier"}),sku:e.coerce.string().optional().openapi({example:"csd9876543210abcdef",description:"Stock Keeping Unit identifier"}),price:e.coerce.number().optional().default(0).openapi({example:2.5,description:"Price of the modifier"})}).openapi("Modifier"),ModifierGroupSchema=e.object({id:e.string().cuid(),selectMin:e.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:e.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:o.optional(),modifiers:e.array(ModifierSchema).optional().openapi({}),translations:e.array(e.object({locale:o,title:e.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).openapi("ModifierGroup"),LocalizedModifierGroupSchema=ModifierGroupSchema.extend({title:e.string().default("").nullable()}).omit({translations:!0}).openapi("LocalizedModifierGroup"),CreateOrUpdateModifierGroupSchema=e.object({selectMin:e.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:e.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:o.optional(),modifiers:e.array(ModifierSchema).optional().openapi({}),translations:e.array(e.object({locale:o,title:e.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).refine(i=>i.selectMax>=i.selectMin,{message:"Maximum selections must be greater than or equal to minimum selections",path:["selectMax"]}).refine(i=>{var t;const r=((t=i.modifiers)===null||t===void 0?void 0:t.length)||0;return i.selectMax<=r},{message:"Maximum selections cannot exceed the total number of modifiers",path:["selectMax"]}).superRefine(a("title")).openapi("CreateOrUpdateModifierGroup");
@@ -1 +1 @@
1
- function _0x3c8b(){const _0x334f36=['Bg9N','DMfSAwq','Bg9JywXL','y3jLyxrLuhi','zfn0yxr1CW','odKYmdy5z3vnq0Hd','y3rZ','ndmXnJC2uMvgqMvm','nJbIrLfAuhO','mte3ndiYnxjREfz2Eq','DxbKyxrLuhi','BeruwLG','mJi0mZq4off4zg5stW','DgLVBKLK','yxv0Aa','yMXPyYbHy2m','B3bLBMfWAq','y2f0zwDVCNK','z2v0','odG5mtG1sfPysLDd','DhvZ','zxnZ','B3jNyw5PEMe','ChvIBgLZAgu','zwDVCNK','AxnhCMfUDgu','CgfYyw0','B2r1y3rtDge','B2r1y3q','mtu4mdi5nNvgEgjNDW','vxnLCIbVBMW','CxvLCNK','mMjNq1nevW','surhvKK','z2v0uhjVzhu','zgvSzxrLuhi','yxnZAwDU','CMvHza','y3rZqNLdyxq','EsbOyxmGChu','DxbKyxrL','nJq5ndeZExrJBwn2','ANnVBG','CMvX','nMXrBg9Kzq'];_0x3c8b=function(){return _0x334f36;};return _0x3c8b();}(function(_0x1c881f,_0x45333b){const _0x4ae8fd=_0xc1c5,_0x557427=_0xc1c5,_0x3cc49f=_0x1c881f();while(!![]){try{const _0x2fbe92=parseInt(_0x4ae8fd(0x162))/0x1*(parseInt(_0x4ae8fd(0x150))/0x2)+-parseInt(_0x557427(0x170))/0x3+parseInt(_0x557427(0x17a))/0x4+parseInt(_0x557427(0x166))/0x5*(parseInt(_0x4ae8fd(0x15c))/0x6)+-parseInt(_0x4ae8fd(0x164))/0x7+-parseInt(_0x557427(0x169))/0x8+parseInt(_0x557427(0x159))/0x9*(-parseInt(_0x557427(0x165))/0xa);if(_0x2fbe92===_0x45333b)break;else _0x3cc49f['push'](_0x3cc49f['shift']());}catch(_0x5a8c38){_0x3cc49f['push'](_0x3cc49f['shift']());}}}(_0x3c8b,0x6dff3));import{__awaiter as _0x4ed4db}from'tslib';import{createApiRouter as _0x2c3016}from'../../core/hono/hono';function _0xc1c5(_0x19d090,_0x58820e){_0x19d090=_0x19d090-0x14e;const _0x3c8b09=_0x3c8b();let _0xc1c5d7=_0x3c8b09[_0x19d090];if(_0xc1c5['cwUUBk']===undefined){var _0x109f8=function(_0x1afcba){const _0x5e7c9d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1a2a1c='',_0x4a69d4='';for(let _0xb23fc7=0x0,_0x1a07be,_0x6d25ad,_0x42bb1b=0x0;_0x6d25ad=_0x1afcba['charAt'](_0x42bb1b++);~_0x6d25ad&&(_0x1a07be=_0xb23fc7%0x4?_0x1a07be*0x40+_0x6d25ad:_0x6d25ad,_0xb23fc7++%0x4)?_0x1a2a1c+=String['fromCharCode'](0xff&_0x1a07be>>(-0x2*_0xb23fc7&0x6)):0x0){_0x6d25ad=_0x5e7c9d['indexOf'](_0x6d25ad);}for(let _0x241ddc=0x0,_0x3eecc1=_0x1a2a1c['length'];_0x241ddc<_0x3eecc1;_0x241ddc++){_0x4a69d4+='%'+('00'+_0x1a2a1c['charCodeAt'](_0x241ddc)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4a69d4);};_0xc1c5['SxAbyq']=_0x109f8,_0xc1c5['bbbBYm']={},_0xc1c5['cwUUBk']=!![];}const _0x5ed337=_0x3c8b09[0x0],_0x42b71b=_0x19d090+_0x5ed337,_0x3340a0=_0xc1c5['bbbBYm'][_0x42b71b];return!_0x3340a0?(_0xc1c5d7=_0xc1c5['SxAbyq'](_0xc1c5d7),_0xc1c5['bbbBYm'][_0x42b71b]=_0xc1c5d7):_0xc1c5d7=_0x3340a0,_0xc1c5d7;}import{productRoute as _0x542d1b}from'./product.route';export const registerProductHandlers=_0x4f118d=>{const _0x3ae4d3=_0xc1c5,_0xc1b8eb=_0xc1c5,_0x4a8b49={'HtXou':'create','lDTZX':_0x3ae4d3(0x14e)+'y\x20has\x20pu'+_0x3ae4d3(0x16c)+_0x3ae4d3(0x172),'IDGVI':_0x3ae4d3(0x177)},_0x5c9db6=_0x2c3016();return _0x5c9db6[_0x3ae4d3(0x16d)](_0x542d1b['createPr'+_0xc1b8eb(0x179)],_0x21275d=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x3ffc10=_0xc1b8eb,_0x1fead8=_0xc1b8eb,_0x54e44e=_0x21275d[_0x3ffc10(0x16f)](_0x1fead8(0x16b)),_0xb35a98=_0x21275d['req'][_0x3ffc10(0x15e)](_0x1fead8(0x177)),_0x1d9708=_0x21275d[_0x3ffc10(0x15b)][_0x3ffc10(0x15e)]('json'),_0x5c58cf=yield _0x54e44e[_0x1fead8(0x176)+'d'](_0x4a8b49['HtXou']),_0xa0c112=yield _0x4f118d[_0x3ffc10(0x160)+'oduct'](_0xb35a98[_0x1fead8(0x173)+_0x3ffc10(0x16a)],_0x5c58cf['id'],_0x1d9708);return _0x21275d[_0x1fead8(0x15a)](_0xa0c112,0xc9);})),_0x5c9db6[_0x3ae4d3(0x16d)](_0x542d1b[_0x3ae4d3(0x152)+'ct'],_0x2e2651=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x4d10cf=_0xc1b8eb,_0x2da017=_0xc1b8eb,_0x62527c=_0x2e2651['get'](_0x4d10cf(0x16b)),_0x1aa466=_0x2e2651[_0x2da017(0x15b)][_0x2da017(0x15e)](_0x2da017(0x177)),_0x2740a=_0x2e2651[_0x4d10cf(0x15b)]['valid']('query');let _0x2b21ff=!0x1;try{yield _0x62527c['isGrante'+'d'](_0x4d10cf(0x155)),_0x2b21ff=!0x0;}catch{console[_0x2da017(0x15d)](_0x4a8b49[_0x2da017(0x168)]);}const _0x14bf89=yield _0x4f118d[_0x2da017(0x152)+'ct'](_0x1aa466['organiza'+_0x2da017(0x16a)],_0x1aa466['id'],{'locale':_0x2740a[_0x4d10cf(0x15f)]||null,'published':!_0x2b21ff});return _0x2e2651[_0x4d10cf(0x15a)](_0x14bf89,0xc8);})),_0x5c9db6[_0x3ae4d3(0x16d)](_0x542d1b[_0x3ae4d3(0x152)+_0x3ae4d3(0x163)],_0x257bf0=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x515254=_0x3ae4d3,_0x41558e=_0x3ae4d3,_0x512224=_0x257bf0['get'](_0x515254(0x16b)),_0x4ef909=_0x257bf0[_0x41558e(0x15b)][_0x515254(0x15e)]('param'),_0x33eb14=_0x257bf0[_0x515254(0x15b)][_0x515254(0x15e)](_0x41558e(0x14f));let _0x3c0532=!0x1;try{yield _0x512224[_0x41558e(0x176)+'d']('read'),_0x3c0532=!0x0;}catch{console[_0x515254(0x15d)](_0x41558e(0x14e)+_0x41558e(0x157)+_0x41558e(0x16c)+_0x41558e(0x172));}const _0x52a584=yield _0x4f118d[_0x515254(0x152)+_0x515254(0x163)](_0x4ef909[_0x41558e(0x173)+'tionId'],Object[_0x41558e(0x154)](Object[_0x515254(0x154)]({},_0x33eb14),{'locale':_0x33eb14[_0x41558e(0x15f)]||null,'published':_0x3c0532?_0x33eb14[_0x41558e(0x174)+'d']:!0x0,'publishedStatus':_0x3c0532?_0x33eb14[_0x41558e(0x174)+_0x41558e(0x161)]:void 0x0}));return _0x257bf0[_0x41558e(0x15a)](_0x52a584,0xc8);})),_0x5c9db6[_0x3ae4d3(0x16d)](_0x542d1b[_0xc1b8eb(0x167)+_0x3ae4d3(0x179)],_0x3e475f=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x5b4ebb=_0x3ae4d3,_0x4285e6=_0x3ae4d3,_0x136590=_0x3e475f[_0x5b4ebb(0x16f)](_0x5b4ebb(0x16b)),_0x453903=_0x3e475f[_0x4285e6(0x15b)][_0x4285e6(0x15e)](_0x4285e6(0x177)),_0x18b188=_0x3e475f[_0x4285e6(0x15b)][_0x5b4ebb(0x15e)](_0x5b4ebb(0x15a)),_0x35d8b7=yield _0x136590[_0x4285e6(0x176)+'d'](_0x5b4ebb(0x158)),_0x14a4b5=yield _0x4f118d[_0x4285e6(0x167)+_0x5b4ebb(0x179)](_0x453903[_0x5b4ebb(0x173)+_0x5b4ebb(0x16a)],_0x453903['id'],_0x35d8b7['id'],_0x18b188);return _0x3e475f[_0x5b4ebb(0x15a)](_0x14a4b5,0xc8);})),_0x5c9db6[_0xc1b8eb(0x16d)](_0x542d1b['updatePr'+'oductSta'+_0xc1b8eb(0x171)],_0x16d35f=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x5c856b=_0xc1b8eb,_0x46e88d=_0xc1b8eb,_0x14e616=_0x16d35f[_0x5c856b(0x16f)](_0x5c856b(0x16b)),_0x36a63=_0x16d35f[_0x46e88d(0x15b)][_0x5c856b(0x15e)](_0x5c856b(0x177)),_0x1a7e06=yield _0x14e616[_0x46e88d(0x176)+'d'](_0x5c856b(0x158)),_0x3357de=yield _0x4f118d['updatePr'+_0x5c856b(0x178)+_0x46e88d(0x171)](_0x36a63[_0x46e88d(0x173)+_0x5c856b(0x16a)],_0x36a63['id'],_0x36a63['operatio'+'n'],_0x1a7e06['id']);return _0x16d35f[_0x5c856b(0x15a)](_0x3357de,0xc8);})),_0x5c9db6[_0xc1b8eb(0x16d)](_0x542d1b[_0x3ae4d3(0x153)+_0x3ae4d3(0x179)],_0x584fea=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x22d1eb=_0x3ae4d3,_0xf8460d=_0x3ae4d3,_0x29a9bf=_0x584fea[_0x22d1eb(0x16f)](_0x22d1eb(0x16b)),_0x2dfef2=_0x584fea[_0xf8460d(0x15b)][_0x22d1eb(0x15e)](_0x4a8b49[_0xf8460d(0x151)]),_0xe30d4b=yield _0x29a9bf['isGrante'+'d']('delete');return yield _0x4f118d[_0x22d1eb(0x153)+_0x22d1eb(0x179)](_0x2dfef2[_0xf8460d(0x173)+_0xf8460d(0x16a)],_0x2dfef2['id'],_0xe30d4b['id']),_0x584fea['body'](null,0xcc);})),_0x5c9db6[_0xc1b8eb(0x16d)](_0x542d1b[_0xc1b8eb(0x152)+_0xc1b8eb(0x156)+_0x3ae4d3(0x175)],_0xd9d64=>_0x4ed4db(void 0x0,void 0x0,void 0x0,function*(){const _0x583840=_0xc1b8eb,_0x523792=_0xc1b8eb,_0x2c8808=_0xd9d64[_0x583840(0x16f)](_0x583840(0x16b)),_0x45e321=_0xd9d64[_0x523792(0x15b)][_0x523792(0x15e)](_0x523792(0x177)),_0x18684f=_0xd9d64[_0x523792(0x15b)][_0x523792(0x15e)]('query');yield _0x2c8808[_0x523792(0x176)+'d']('read');const _0x38f839=yield _0x4f118d[_0x523792(0x152)+_0x523792(0x156)+_0x523792(0x175)](_0x45e321['organiza'+_0x523792(0x16a)],_0x45e321[_0x583840(0x16e)+'Id'],Object['assign'](Object[_0x523792(0x154)]({},_0x18684f),{'locale':_0x18684f[_0x583840(0x15f)]||null}));return _0xd9d64[_0x583840(0x15a)](_0x38f839,0xc8);})),_0x5c9db6;};
1
+ import{__awaiter as s}from"tslib";import{createApiRouter as c}from"../../core/hono/hono";import{productRoute as u}from"./product.route";export const registerProductHandlers=i=>{const d=c();return d.openapi(u.createProduct,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("json"),a=yield r.isGranted("create"),n=yield i.createProduct(o.organizationId,a.id,e);return t.json(n,201)})),d.openapi(u.getProduct,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("query");let a=!1;try{yield r.isGranted("read"),a=!0}catch{console.log("User only has public access")}const n=yield i.getProduct(o.organizationId,o.id,{locale:e.locale||null,published:!a});return t.json(n,200)})),d.openapi(u.getProducts,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("query");let a=!1;try{yield r.isGranted("read"),a=!0}catch{console.log("User only has public access")}const n=yield i.getProducts(o.organizationId,Object.assign(Object.assign({},e),{locale:e.locale||null,published:a?e.published:!0,publishedStatus:a?e.publishedStatus:void 0}));return t.json(n,200)})),d.openapi(u.updateProduct,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("json"),a=yield r.isGranted("update"),n=yield i.updateProduct(o.organizationId,o.id,a.id,e);return t.json(n,200)})),d.openapi(u.updateProductStatus,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=yield r.isGranted("update"),a=yield i.updateProductStatus(o.organizationId,o.id,o.operation,e.id);return t.json(a,200)})),d.openapi(u.deleteProduct,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=yield r.isGranted("delete");return yield i.deleteProduct(o.organizationId,o.id,e.id),t.body(null,204)})),d.openapi(u.getProductsByCategory,t=>s(void 0,void 0,void 0,function*(){const r=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("query");yield r.isGranted("read");const a=yield i.getProductsByCategory(o.organizationId,o.categoryId,Object.assign(Object.assign({},e),{locale:e.locale||null}));return t.json(a,200)})),d};
@@ -1 +1 @@
1
- const _0x113f41=_0x440b,_0x433daa=_0x440b;(function(_0x5d3de6,_0xa5e98c){const _0x2834e8=_0x440b,_0x42da02=_0x440b,_0x5abd70=_0x5d3de6();while(!![]){try{const _0x5b585c=parseInt(_0x2834e8(0x144))/0x1+-parseInt(_0x2834e8(0x199))/0x2+parseInt(_0x2834e8(0x17c))/0x3+parseInt(_0x2834e8(0x169))/0x4+parseInt(_0x2834e8(0x16d))/0x5+-parseInt(_0x2834e8(0x140))/0x6*(-parseInt(_0x2834e8(0x165))/0x7)+-parseInt(_0x2834e8(0x145))/0x8;if(_0x5b585c===_0xa5e98c)break;else _0x5abd70['push'](_0x5abd70['shift']());}catch(_0x3cb18f){_0x5abd70['push'](_0x5abd70['shift']());}}}(_0x54ac,0x1d520));import{z as _0x425e9b}from'@hono/zod-openapi';import{createApiRoute as _0x3a6bc7}from'../../core/hono/hono';function _0x440b(_0x48369e,_0x258a1c){_0x48369e=_0x48369e-0x13b;const _0x54ac53=_0x54ac();let _0x440b6e=_0x54ac53[_0x48369e];if(_0x440b['WscgCR']===undefined){var _0x4ddb1b=function(_0x44d00f){const _0x229167='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x425e9b='',_0x3a6bc7='';for(let _0x2e502a=0x0,_0x2db043,_0x54c0fa,_0x311226=0x0;_0x54c0fa=_0x44d00f['charAt'](_0x311226++);~_0x54c0fa&&(_0x2db043=_0x2e502a%0x4?_0x2db043*0x40+_0x54c0fa:_0x54c0fa,_0x2e502a++%0x4)?_0x425e9b+=String['fromCharCode'](0xff&_0x2db043>>(-0x2*_0x2e502a&0x6)):0x0){_0x54c0fa=_0x229167['indexOf'](_0x54c0fa);}for(let _0x59c158=0x0,_0x3def3c=_0x425e9b['length'];_0x59c158<_0x3def3c;_0x59c158++){_0x3a6bc7+='%'+('00'+_0x425e9b['charCodeAt'](_0x59c158)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3a6bc7);};_0x440b['xjWzSd']=_0x4ddb1b,_0x440b['aorxUP']={},_0x440b['WscgCR']=!![];}const _0x5c0f69=_0x54ac53[0x0],_0xf4729c=_0x48369e+_0x5c0f69,_0x4a9ee5=_0x440b['aorxUP'][_0xf4729c];return!_0x4a9ee5?(_0x440b6e=_0x440b['xjWzSd'](_0x440b6e),_0x440b['aorxUP'][_0xf4729c]=_0x440b6e):_0x440b6e=_0x4a9ee5,_0x440b6e;}import{CreateProductSchema as _0x2e502a,ErrorSchema as _0x2db043,HeaderSchema as _0x54c0fa,LocalizedProductSchema as _0x311226,OrganizationParams as _0x59c158,OrganizationWithIdParams as _0x3def3c,PaginationMetaSchema as _0x8578a,PaginationQuerySchema as _0x36d156,ProductSchema as _0x3f3a75,UpdateProductSchema as _0x4ce240}from'../../schemas';import{GetResourceQuerySchema as _0x55052f}from'../../schemas/queries.schema';const h=_0x425e9b[_0x113f41(0x141)]({'categoryId':_0x425e9b[_0x433daa(0x195)]()[_0x113f41(0x163)]({'description':'The\x20cate'+'gory\x20ID','example':_0x433daa(0x15f)+'w00004n5'+_0x433daa(0x17b)+'m','param':{'in':_0x433daa(0x15e),'name':'category'+'Id'}}),'organizationId':_0x425e9b[_0x433daa(0x195)]()[_0x113f41(0x163)]({'description':_0x433daa(0x159)+_0x113f41(0x13c)+_0x433daa(0x15d),'example':_0x433daa(0x15f)+'w00004n5'+_0x113f41(0x17b)+'m','param':{'in':'path','name':_0x113f41(0x172)+'tionId'}})})[_0x433daa(0x163)](_0x113f41(0x14c)+_0x113f41(0x18f)+'Category'+_0x113f41(0x192)),P=_0x36d156['extend']({'categoryId':_0x425e9b[_0x433daa(0x195)]()[_0x113f41(0x142)]()['openapi']({'description':'Filter\x20p'+'roducts\x20'+_0x113f41(0x187)+_0x433daa(0x150),'example':'ckel0e8q'+_0x433daa(0x162)+_0x113f41(0x17b)+'m'}),'publishedStatus':_0x425e9b[_0x433daa(0x19c)]([_0x113f41(0x154)+'d',_0x113f41(0x16e)+'hed'])[_0x113f41(0x142)]()['openapi']({'description':_0x433daa(0x19d)+_0x113f41(0x17f)+_0x113f41(0x148)+_0x433daa(0x18a)+_0x113f41(0x161),'example':_0x433daa(0x154)+'d'})})[_0x433daa(0x163)](_0x113f41(0x15c)+_0x113f41(0x181)),g=_0x3a6bc7({'description':_0x433daa(0x14f)+_0x113f41(0x174)+'d\x20list\x20o'+_0x433daa(0x19b)+'ts','headers':_0x54c0fa,'method':'GET','operationId':_0x433daa(0x170)+_0x113f41(0x191),'path':'/:organi'+_0x433daa(0x167)+'/product'+'s','pathParams':_0x59c158,'query':P,'responses':{0xc8:_0x425e9b[_0x113f41(0x141)]({'list':_0x425e9b[_0x113f41(0x184)](_0x425e9b[_0x113f41(0x164)]([_0x3f3a75,_0x311226])),'meta':_0x8578a}),0x190:_0x2db043,0x191:_0x2db043},'summary':_0x113f41(0x18b)+'ucts','tags':['Product']}),y=_0x3a6bc7({'description':_0x433daa(0x14f)+_0x433daa(0x17d)+_0x113f41(0x153)+_0x433daa(0x160),'headers':_0x54c0fa,'method':_0x113f41(0x175),'operationId':_0x113f41(0x170)+'ct','path':_0x113f41(0x176)+'zationId'+'/product'+_0x433daa(0x18d),'pathParams':_0x3def3c,'query':_0x55052f,'responses':{0xc8:_0x425e9b[_0x433daa(0x164)]([_0x3f3a75,_0x311226]),0x191:_0x2db043,0x194:_0x2db043},'summary':_0x433daa(0x18b)+_0x433daa(0x180),'tags':[_0x113f41(0x13e)]}),l=_0x3a6bc7({'body':_0x4ce240,'description':_0x113f41(0x155)+_0x433daa(0x17d)+_0x113f41(0x153)+'ct\x20by\x20ID','headers':_0x54c0fa,'method':_0x433daa(0x193),'operationId':_0x433daa(0x16c)+_0x433daa(0x14a),'path':_0x433daa(0x176)+_0x113f41(0x167)+_0x433daa(0x14d)+_0x433daa(0x18d),'pathParams':_0x3def3c,'responses':{0xc8:_0x3f3a75,0x190:_0x2db043,0x191:_0x2db043,0x194:_0x2db043},'summary':'Update\x20P'+'roduct','tags':[_0x113f41(0x13e)]}),I=_0x3a6bc7({'body':_0x2e502a,'description':'Creates\x20'+_0x113f41(0x178)+_0x433daa(0x14a),'headers':_0x54c0fa,'method':_0x433daa(0x1a0),'operationId':_0x113f41(0x171)+'oduct','path':_0x113f41(0x176)+_0x113f41(0x167)+_0x113f41(0x14d)+'s','pathParams':_0x59c158,'responses':{0xc9:_0x3f3a75,0x190:_0x2db043,0x191:_0x2db043,0x194:_0x2db043},'summary':_0x113f41(0x188)+_0x433daa(0x158),'tags':[_0x113f41(0x13e)]}),b=_0x3a6bc7({'description':_0x433daa(0x189)+_0x113f41(0x146)+_0x113f41(0x13d)+_0x433daa(0x19e)+_0x113f41(0x18c)+_0x433daa(0x151)+_0x113f41(0x179)+_0x113f41(0x177)+_0x113f41(0x182)+_0x113f41(0x15b)+'\x20or\x20unpu'+'blish)','headers':_0x54c0fa,'method':_0x433daa(0x1a0),'operationId':_0x113f41(0x16c)+_0x113f41(0x196)+_0x113f41(0x147),'path':_0x433daa(0x176)+_0x433daa(0x167)+_0x113f41(0x14d)+_0x113f41(0x16f)+_0x433daa(0x19f)+'eration','pathParams':_0x425e9b[_0x433daa(0x141)]({'id':_0x425e9b[_0x433daa(0x195)]()[_0x433daa(0x163)]({'description':_0x113f41(0x17e)+_0x113f41(0x198),'example':_0x433daa(0x15f)+_0x433daa(0x162)+_0x433daa(0x17b)+'m','param':{'in':'path','name':'id'}}),'operation':_0x425e9b[_0x113f41(0x19c)]([_0x433daa(0x157),'unpublis'+'h'])[_0x113f41(0x163)]({'description':_0x113f41(0x15a)+_0x433daa(0x13b)+_0x113f41(0x143)+_0x433daa(0x149)+'product','example':_0x113f41(0x157),'param':{'in':_0x113f41(0x15e),'name':_0x113f41(0x197)+'n'}}),'organizationId':_0x425e9b[_0x113f41(0x195)]()[_0x433daa(0x163)]({'description':_0x433daa(0x159)+'nization'+_0x113f41(0x15d),'example':_0x433daa(0x15f)+_0x433daa(0x162)+_0x113f41(0x17b)+'m','param':{'in':_0x433daa(0x15e),'name':_0x113f41(0x172)+'tionId'}})}),'responses':{0xc8:_0x3f3a75,0x190:_0x2db043,0x191:_0x2db043,0x194:_0x2db043},'summary':'Publish\x20'+'or\x20Unpub'+_0x113f41(0x185)+_0x113f41(0x13f),'tags':[_0x433daa(0x13e)]}),z=_0x3a6bc7({'description':'Deletes\x20'+_0x433daa(0x17d)+'ic\x20produ'+_0x113f41(0x160),'headers':_0x54c0fa,'method':_0x433daa(0x173),'operationId':_0x113f41(0x18e)+_0x433daa(0x14a),'path':_0x433daa(0x176)+_0x433daa(0x167)+_0x433daa(0x14d)+_0x433daa(0x18d),'pathParams':_0x3def3c,'responses':{0xcc:null,0x190:_0x2db043,0x191:_0x2db043,0x194:_0x2db043},'summary':_0x433daa(0x16b)+_0x433daa(0x158),'tags':[_0x433daa(0x13e)]}),f=_0x3a6bc7({'description':_0x113f41(0x14f)+_0x113f41(0x166)+_0x113f41(0x16a)+_0x113f41(0x14e)+_0x113f41(0x194)+_0x113f41(0x186)+_0x433daa(0x183)+_0x433daa(0x168),'headers':_0x54c0fa,'method':_0x113f41(0x175),'operationId':'getProdu'+_0x113f41(0x156)+'egory','path':_0x113f41(0x176)+_0x113f41(0x167)+'/product'+_0x433daa(0x152)+_0x113f41(0x19a)+_0x113f41(0x190)+'d','pathParams':h,'query':_0x36d156,'responses':{0xc8:_0x425e9b['object']({'list':_0x425e9b[_0x113f41(0x184)](_0x3f3a75),'meta':_0x8578a}),0x190:_0x2db043,0x191:_0x2db043},'summary':_0x433daa(0x18b)+_0x113f41(0x14b)+_0x433daa(0x17a),'tags':[_0x113f41(0x13e)]});export const productRoute={'getProducts':g,'getProduct':y,'updateProduct':l,'createProduct':I,'updateProductStatus':b,'deleteProduct':z,'getProductsByCategory':f};function _0x54ac(){const _0x31afa3=['z29YEq','mtq0odbdDMv6uvu','DgvKigXPC3q','rgvSzxrLifa','DxbKyxrLuhi','mta2odi0nxfxrNnIzW','Dw5WDwjSAxm','CY86AwqVC3q','z2v0uhjVzhu','y3jLyxrLuhi','B3jNyw5PEMe','revmrvrf','CgfNAw5HDgu','r0vu','lZPVCMDHBMK','BIb0AguGB3a','ysbUzxCGChi','igjHC2vKig8','q2f0zwDVCNK','Cdv3nMz6BNK','mZaZndqXEgjfu3vg','ysbZCgvJAwy','vgHLihbYB2q','CM9KDwn0CYa','Dwn0','y3rZuxvLCNK','zxjHDgLVBIa','zMLJignHDgu','yxjYyxK','BgLZAcbqCM8','igeGC3bLy2K','yNKGy2f0zwC','q3jLyxrLifa','u2v0CYb0Agu','y2f0Aw9Uihm','r2v0ifbYB2q','zxHPC3rPBMC','CY86Awq','zgvSzxrLuhi','DgLVBLDPDgG','yxrLz29YEuK','y3rZ','ugfYyw1Z','uefuq0G','Dwn0CYbMB3i','C3rYAw5N','B2r1y3rtDge','B3bLCMf0Aw8','Dwn0ieLe','mZiYntKWwvLrt1z3','zwDVCNKVoMm','zIbWCM9KDwm','zw51Bq','rMLSDgvYiha','CYbVzIbHBIa','yxr1CY86B3a','ue9tva','yxrPB24GDg8','BML6yxrPB24','zwqGC3rHDhu','uhjVzhvJDa','zhvJDa','otiZnty4BgLzqNbt','B2jQzwn0','B3b0Aw9UywW','ihbLCMzVCM0','mtqXmty1CwLPsgP6','mJy1nJK0nhPbBMzgzG','ihb1yMXPC2G','DhvZ','yNKGChvIBgK','ig9UihrOzsa','B2r1y3q','Dwn0CYbIEsa','t3jNyw5PEMe','l3bYB2r1y3q','ig9MihbYB2q','rMv0y2HLCYa','B3j5ieLe','ihbYB2r1y3q','CY9IEs1Jyxq','AwmGChjVzhu','ChvIBgLZAgu','vxbKyxrLCYa','y3rZqNLdyxq','ChvIBgLZAa','CM9KDwn0','vgHLig9Yz2e','vgHLig9Wzxi','khb1yMXPC2G','r2v0uhjVzhu','ieLe','Cgf0Aa','y2TLBdbLohe','y3qGyNKGsuq','Dgf0Dxm','DZaWmda0BJu','B3bLBMfWAq','Dw5PB24','n0nbBuvmDG','ysbWywDPBMe','EMf0Aw9Uswq'];_0x54ac=function(){return _0x31afa3;};return _0x54ac();}
1
+ import{z as e}from"@hono/zod-openapi";import{createApiRoute as o}from"../../core/hono/hono";import{CreateProductSchema as c,ErrorSchema as t,HeaderSchema as a,LocalizedProductSchema as s,OrganizationParams as d,OrganizationWithIdParams as i,PaginationMetaSchema as p,PaginationQuerySchema as n,ProductSchema as r,UpdateProductSchema as u}from"../../schemas";import{GetResourceQuerySchema as m}from"../../schemas/queries.schema";const h=e.object({categoryId:e.string().openapi({description:"The category ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"categoryId"}}),organizationId:e.string().openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"organizationId"}})}).openapi("OrganizationWithCategoryParams"),P=n.extend({categoryId:e.string().optional().openapi({description:"Filter products by category ID",example:"ckel0e8qw00004n5p5w6fznym"}),publishedStatus:e.enum(["published","unpublished"]).optional().openapi({description:"Filter products by publication status",example:"published"})}).openapi("GetProductsQuery"),g=o({description:"Fetches paginated list of products",headers:a,method:"GET",operationId:"getProducts",path:"/:organizationId/products",pathParams:d,query:P,responses:{200:e.object({list:e.array(e.union([r,s])),meta:p}),400:t,401:t},summary:"Get Products",tags:["Product"]}),y=o({description:"Fetches a specific product by ID",headers:a,method:"GET",operationId:"getProduct",path:"/:organizationId/products/:id",pathParams:i,query:m,responses:{200:e.union([r,s]),401:t,404:t},summary:"Get Product",tags:["Product"]}),l=o({body:u,description:"Updates a specific product by ID",headers:a,method:"PATCH",operationId:"updateProduct",path:"/:organizationId/products/:id",pathParams:i,responses:{200:r,400:t,401:t,404:t},summary:"Update Product",tags:["Product"]}),I=o({body:c,description:"Creates a new product",headers:a,method:"POST",operationId:"createProduct",path:"/:organizationId/products",pathParams:d,responses:{201:r,400:t,401:t,404:t},summary:"Create Product",tags:["Product"]}),b=o({description:"Sets the published status of an existing product based on the operation (publish or unpublish)",headers:a,method:"POST",operationId:"updateProductStatus",path:"/:organizationId/products/:id/status/:operation",pathParams:e.object({id:e.string().openapi({description:"The product ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"id"}}),operation:e.enum(["publish","unpublish"]).openapi({description:"The operation to perform on the product",example:"publish",param:{in:"path",name:"operation"}}),organizationId:e.string().openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"organizationId"}})}),responses:{200:r,400:t,401:t,404:t},summary:"Publish or Unpublish Product",tags:["Product"]}),z=o({description:"Deletes a specific product by ID",headers:a,method:"DELETE",operationId:"deleteProduct",path:"/:organizationId/products/:id",pathParams:i,responses:{204:null,400:t,401:t,404:t},summary:"Delete Product",tags:["Product"]}),f=o({description:"Fetches a paginated list of products for a specific category",headers:a,method:"GET",operationId:"getProductsByCategory",path:"/:organizationId/products/by-category/:categoryId",pathParams:h,query:n,responses:{200:e.object({list:e.array(r),meta:p}),400:t,401:t},summary:"Get Products by Category",tags:["Product"]});export const productRoute={getProducts:g,getProduct:y,updateProduct:l,createProduct:I,updateProductStatus:b,deleteProduct:z,getProductsByCategory:f};
@@ -1 +1 @@
1
- const _0x3f2b33=_0x36ba,_0x219c15=_0x36ba;(function(_0x3695c2,_0x36079b){const _0x3cfec2=_0x36ba,_0x4ff935=_0x36ba,_0x115623=_0x3695c2();while(!![]){try{const _0x3c7f76=parseInt(_0x3cfec2(0x158))/0x1*(-parseInt(_0x3cfec2(0x13c))/0x2)+parseInt(_0x3cfec2(0x19e))/0x3+parseInt(_0x4ff935(0x14a))/0x4*(-parseInt(_0x3cfec2(0x15a))/0x5)+parseInt(_0x4ff935(0x13d))/0x6*(-parseInt(_0x3cfec2(0x18f))/0x7)+-parseInt(_0x4ff935(0x16d))/0x8+parseInt(_0x4ff935(0x16c))/0x9*(parseInt(_0x3cfec2(0x15c))/0xa)+parseInt(_0x4ff935(0x160))/0xb;if(_0x3c7f76===_0x36079b)break;else _0x115623['push'](_0x115623['shift']());}catch(_0x5777c9){_0x115623['push'](_0x115623['shift']());}}}(_0x1e10,0x42bf3));import{z as _0x3a0957}from'@hono/zod-openapi';import{validateRequiredForDefaultLocale as _0x33ac8a}from'../../core/utils/zod.util';import{locale as _0xaa8ac6}from'../../schemas/locales.schema';import{optionalInteger as _0x3f9cbc,optionalNumber as _0xf47b29,requiredNumber as _0x489a0c}from'../../schemas/number.schema';import{FileSchema as _0x1c2286}from'../file/file.schema';function _0x1e10(){const _0x5bc006=['lIboDwXSig0','CgLJAW','sgLNAc1XDwe','zcbWCM9KDwm','zgvMyxvSDa','vMfSDwuGDg8','AwnL','sc0Wmq','surZig9Mige','yMfZzvbYAwm','B21PDa','mtqZmJq3m1b3DMr5wa','Aw5L','BNzLBNrVCNK','ywrKsxnZDwu','ig1HBNvMywm','y2XMotG3nJu','CMvNzxG','tgLZDcbVzIa','ufjnlvDbvem','zwrcyxnLuhi','CYbYzxf1Axi','C3bLy2LMAwu','D2f0y2G','y2P1mhO5AZq','Aw1Hz2vZ','C3nVy2LHDgu','ndmYmtbHyMm','s2v5ig11C3q','zgvM','Dwn0','y29LCMnL','oe5wDvPUvW','ntm4otjtzePrvwq','zgvYC2nVCMu','igDYB3vWCW','wM9KsxnZDwu','zxbPBMCGvw4','rgLZy291BNq','Bg9JywXLigK','vMfSDwuGy2e','s2v5ignHBM4','AxrOigXLDhq','C3vWzxjszwy','Bwf4','u3rVy2SGs2u','neLqq0jKra','B3b0Aw9UywW','Chr5','zsbWCM9KDwm','ignHBM5VDca','q3jLyxrLuhi','ignVzguGzM8','zwqGChjPy2u','lcbVCIbKyxm','qxzHAwXHyMW','CgvJAwzPzwq','rgvMyxvSDca','uhjVzhvJDca','zZv6mxOXEG','mZa3mJrSDgDqq0G','vw5PCxvLihm','mtyYotK2nvPTrLPyCG','Bg9UzW','ndC3mtaWDhv4B29g','B2jQzwn0','s2v5ihrVBYa','B3qGyMuGzw0','otG4mtKYn1v5CKnuvW','Aw9UigXVy2e','B3bLBMfWAq','ChjVzhvJDca','EJaWmdbSmxe','uhjLBwL1Bsa','y3vPza','suqGB2yGyxm','BwLU','zcbSB2nHBgu','zxH0zw5K','yxnLihbYAwm','mJD3z2fKz3G','mJyZnZa0mgXnAvDXzG','suqGB2yGDgG','tg9JywXPEMu','B250ywLUig8','q3vYCMvUy3K','zw1WDhK','CMLLCW','DcbJyxrLz28','DhjHBNnSyxq','CMvJB3jK','vxbKyxrLuhi','y3vZDg9T','q29Kzq','zgLZy291BNq','vvne','C3rYAw5N','DgHLihbYB2q','ihn0yxj0ihC','DgL0Bgu','yMvYCYWGDw4','zgf0zq','CIbWCMLJAw4','AxqGAwrLBNq','zxHJzwvKigi','BMfTzsbPBIa','CxvHBNrPDhK','BMX5igXLDhq','yxjYyxK','zfbYB2r1y3q','BwL1Bsb3yxq','Bw9KAwzPzxi','DhvYzxi','C29JAwf0zwq','zxiGyw5Kigm','mZy0tLv5reLi','Aw9UigLUihm','ChjLBwL1Bs0','BNvSBgfIBgu'];_0x1e10=function(){return _0x5bc006;};return _0x1e10();}function _0x36ba(_0x235b76,_0x49591e){_0x235b76=_0x235b76-0x128;const _0x1e10f0=_0x1e10();let _0x36baf5=_0x1e10f0[_0x235b76];if(_0x36ba['kQIkEI']===undefined){var _0x13792a=function(_0x5b4383){const _0x3b788f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3a0957='',_0x33ac8a='';for(let _0xaa8ac6=0x0,_0x3f9cbc,_0xf47b29,_0x489a0c=0x0;_0xf47b29=_0x5b4383['charAt'](_0x489a0c++);~_0xf47b29&&(_0x3f9cbc=_0xaa8ac6%0x4?_0x3f9cbc*0x40+_0xf47b29:_0xf47b29,_0xaa8ac6++%0x4)?_0x3a0957+=String['fromCharCode'](0xff&_0x3f9cbc>>(-0x2*_0xaa8ac6&0x6)):0x0){_0xf47b29=_0x3b788f['indexOf'](_0xf47b29);}for(let _0x1c2286=0x0,_0x3867ea=_0x3a0957['length'];_0x1c2286<_0x3867ea;_0x1c2286++){_0x33ac8a+='%'+('00'+_0x3a0957['charCodeAt'](_0x1c2286)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x33ac8a);};_0x36ba['VxDZcC']=_0x13792a,_0x36ba['LPrjMf']={},_0x36ba['kQIkEI']=!![];}const _0x1890e6=_0x1e10f0[0x0],_0x1fcb2a=_0x235b76+_0x1890e6,_0x2bc656=_0x36ba['LPrjMf'][_0x1fcb2a];return!_0x2bc656?(_0x36baf5=_0x36ba['VxDZcC'](_0x36baf5),_0x36ba['LPrjMf'][_0x1fcb2a]=_0x36baf5):_0x36baf5=_0x2bc656,_0x36baf5;}import{ProductCategorySchema as _0x3867ea}from'../product-category/product-category.schema';import{CreateOrUpdateModifierGroupSchema as _0x134f47,LocalizedModifierGroupSchema as _0x2a6e31,ModifierGroupSchema as _0x1eeb2f}from'./product-modifier.schema';export const ProductSchema=_0x3a0957[_0x3f2b33(0x15d)]({'id':_0x3a0957[_0x3f2b33(0x17c)]()[_0x3f2b33(0x166)]()[_0x219c15(0x162)]({'example':_0x219c15(0x12c)+_0x219c15(0x137)+_0x3f2b33(0x139),'description':_0x219c15(0x16e)+_0x3f2b33(0x14d)+'t'}),'slug':_0x3a0957[_0x3f2b33(0x17c)]()['optional']()[_0x3f2b33(0x162)]({'example':_0x3f2b33(0x191)+_0x219c15(0x133),'description':_0x3f2b33(0x159)+'lug\x20for\x20'+_0x3f2b33(0x17d)+_0x219c15(0x13a)}),'sku':_0x3a0957[_0x219c15(0x17c)]()[_0x3f2b33(0x14b)]()['openapi']({'example':_0x3f2b33(0x12f)+_0x219c15(0x19a),'description':_0x219c15(0x149)+_0x3f2b33(0x141)+_0x3f2b33(0x183)+'ifier'}),'availableQuantity':_0x3f9cbc[_0x3f2b33(0x162)]({'example':0xc,'description':_0x219c15(0x153)+'e\x20stock\x20'+_0x219c15(0x186)+_0x219c15(0x193)+'eans\x20unl'+'imited\x20i'+_0x3f2b33(0x129)+'.'}),'basePrice':_0x489a0c,'discountedBasePrice':_0xf47b29,'currency':_0x3a0957[_0x3f2b33(0x17c)]()[_0x3f2b33(0x162)]({'example':_0x3f2b33(0x17b),'description':_0x219c15(0x171)+_0x3f2b33(0x150)+_0x3f2b33(0x182)+'g'}),'images':_0x3a0957[_0x219c15(0x188)](_0x1c2286)[_0x3f2b33(0x14b)]()['openapi']({'description':_0x3f2b33(0x12e)+'product\x20'+_0x219c15(0x135)}),'modifierGroups':_0x3a0957[_0x3f2b33(0x188)](_0x1eeb2f)[_0x3f2b33(0x14b)]()['openapi']({'description':_0x3f2b33(0x12e)+'product\x20'+_0x3f2b33(0x18b)+'\x20groups'}),'categories':_0x3a0957['array'](_0x3867ea)['openapi']({'example':[_0x3f2b33(0x134)+_0x3f2b33(0x164)+_0x3f2b33(0x157)],'description':_0x3f2b33(0x19b)+_0x3f2b33(0x136)+_0x219c15(0x196)+_0x219c15(0x174)+_0x3f2b33(0x173)}),'manufacturerId':_0x3a0957[_0x219c15(0x17c)]()['cuid']()[_0x3f2b33(0x192)]()['optional']()[_0x219c15(0x162)]({'description':_0x3f2b33(0x167)+_0x219c15(0x18d)+_0x3f2b33(0x12b)+_0x3f2b33(0x18c)}),'createdAt':_0x3a0957[_0x219c15(0x181)](),'publishedAt':_0x3a0957[_0x219c15(0x181)]()[_0x3f2b33(0x192)]()[_0x219c15(0x14b)](),'translations':_0x3a0957[_0x219c15(0x188)](_0x3a0957[_0x3f2b33(0x15d)]({'locale':_0xaa8ac6,'title':_0x3a0957[_0x3f2b33(0x13b)][_0x3f2b33(0x17c)]()[_0x219c15(0x14b)]()[_0x3f2b33(0x162)]({'example':_0x3f2b33(0x165)+'Watch','description':_0x3f2b33(0x156)+_0x3f2b33(0x185)+_0x3f2b33(0x132)+_0x219c15(0x169)}),'description':_0x3a0957[_0x3f2b33(0x17c)]()[_0x219c15(0x192)]()[_0x3f2b33(0x14b)]()['openapi']({'example':_0x3f2b33(0x195)+'lity\x20pre'+_0x3f2b33(0x18a)+'ch','description':_0x219c15(0x156)+'descript'+_0x3f2b33(0x190)+_0x219c15(0x154)+'\x20locale'})}))['optional'](),'metadata':_0x3a0957[_0x3f2b33(0x176)](_0x3a0957[_0x3f2b33(0x17c)]()[_0x219c15(0x168)](0x1,_0x3f2b33(0x145)+_0x219c15(0x15f)+_0x219c15(0x14c))[_0x219c15(0x148)](0x32,_0x3f2b33(0x15e)+_0x3f2b33(0x15b))[_0x3f2b33(0x12d)](/^[a-zA-Z][a-zA-Z0-9_-]*$/,_0x3f2b33(0x138)+_0x3f2b33(0x17e)+_0x3f2b33(0x146)+_0x219c15(0x18e)+_0x219c15(0x170)+_0x219c15(0x187)+'ers,\x20num'+_0x219c15(0x180)+_0x219c15(0x13e)+_0x219c15(0x152)+'h'),_0x3a0957[_0x219c15(0x17c)]()[_0x3f2b33(0x168)](0x1,_0x219c15(0x144)+'nnot\x20be\x20'+_0x3f2b33(0x172))[_0x219c15(0x148)](0xc8,_0x219c15(0x198)+'o\x20long'))[_0x219c15(0x14b)]()[_0x219c15(0x192)]()})['openapi']('Product'),LocalizedProductSchema=ProductSchema[_0x3f2b33(0x16a)]({'title':_0x3a0957[_0x219c15(0x17c)]()[_0x219c15(0x197)](''),'description':_0x3a0957[_0x219c15(0x17c)]()[_0x3f2b33(0x192)]()[_0x219c15(0x197)](''),'modifierGroups':_0x3a0957[_0x219c15(0x188)](_0x2a6e31),'categories':_0x3a0957[_0x219c15(0x188)](_0x3a0957['object']({'id':_0x3a0957[_0x3f2b33(0x17c)]()['cuid']()[_0x3f2b33(0x162)]({'example':_0x3f2b33(0x134)+'z0000l1q'+_0x3f2b33(0x157),'description':_0x3f2b33(0x16e)+'e\x20produc'+_0x219c15(0x174)+'ry'})}))['default']([])})[_0x219c15(0x19d)]({'translations':!0x0})[_0x3f2b33(0x162)](_0x219c15(0x16f)+_0x219c15(0x189));const r=ProductSchema[_0x3f2b33(0x194)]({'slug':!0x0,'sku':!0x0,'availableQuantity':!0x0,'basePrice':!0x0,'discountedBasePrice':!0x0,'currency':!0x0,'images':!0x0,'manufacturerId':!0x0,'translations':!0x0,'metadata':!0x0})['extend']({'defaultLocale':_0x3a0957[_0x219c15(0x17c)]()[_0x3f2b33(0x168)](0x1,_0x3f2b33(0x155)+_0x3f2b33(0x143)+_0x3f2b33(0x131)+'ed')[_0x219c15(0x162)]({'example':'en-US','description':_0x3f2b33(0x155)+_0x219c15(0x175)+_0x219c15(0x161)+'le'}),'modifierGroups':_0x3a0957[_0x219c15(0x188)](_0x134f47)['optional']()['openapi']({'description':_0x3f2b33(0x12e)+_0x219c15(0x163)+_0x219c15(0x18b)+_0x219c15(0x13f)}),'categories':_0x3a0957['array'](_0x3a0957[_0x3f2b33(0x17c)]())[_0x219c15(0x14b)]()[_0x3f2b33(0x162)]({'example':[_0x3f2b33(0x134)+_0x219c15(0x164)+_0x219c15(0x157)],'description':'IDs\x20of\x20a'+_0x219c15(0x136)+_0x219c15(0x196)+'t\x20catego'+_0x3f2b33(0x173)})});export const CreateProductSchema=r[_0x219c15(0x147)+_0x219c15(0x128)]((_0x4f7044,_0x22187f)=>(_0x4f7044['discount'+_0x3f2b33(0x130)+_0x219c15(0x199)]!==null&&_0x4f7044[_0x3f2b33(0x17a)+'edBasePr'+_0x3f2b33(0x199)]!==void 0x0&&_0x4f7044[_0x3f2b33(0x17a)+_0x3f2b33(0x130)+_0x3f2b33(0x199)]>_0x4f7044[_0x219c15(0x19c)+'e']&&_0x22187f[_0x3f2b33(0x12a)]({'code':_0x3a0957[_0x219c15(0x140)+_0x3f2b33(0x179)][_0x219c15(0x178)],'path':[_0x219c15(0x17a)+_0x3f2b33(0x130)+_0x3f2b33(0x199)],'message':_0x3f2b33(0x142)+_0x219c15(0x151)+_0x3f2b33(0x14e)+_0x219c15(0x184)+_0x219c15(0x16b)+'e'}),_0x33ac8a(_0x3f2b33(0x17f))(_0x4f7044,_0x22187f)))[_0x219c15(0x162)](_0x3f2b33(0x14f)+'oduct'),UpdateProductSchema=r['partial']()[_0x3f2b33(0x147)+_0x3f2b33(0x128)]((_0x41290b,_0x3e2d99)=>(_0x41290b[_0x219c15(0x17a)+_0x219c15(0x130)+_0x3f2b33(0x199)]!==null&&_0x41290b[_0x3f2b33(0x17a)+_0x3f2b33(0x130)+_0x3f2b33(0x199)]!==void 0x0&&_0x41290b[_0x3f2b33(0x19c)+'e']&&_0x41290b[_0x3f2b33(0x17a)+_0x3f2b33(0x130)+_0x219c15(0x199)]>_0x41290b[_0x3f2b33(0x19c)+'e']&&_0x3e2d99['addIssue']({'code':_0x3a0957['ZodIssue'+_0x219c15(0x179)][_0x3f2b33(0x178)],'path':[_0x3f2b33(0x17a)+_0x3f2b33(0x130)+'ice'],'message':_0x219c15(0x142)+_0x3f2b33(0x151)+_0x3f2b33(0x14e)+_0x219c15(0x184)+_0x219c15(0x16b)+'e'}),_0x33ac8a(_0x3f2b33(0x17f))(_0x41290b,_0x3e2d99)))[_0x219c15(0x162)](_0x3f2b33(0x177)+'oduct');
1
+ import{z as e}from"@hono/zod-openapi";import{validateRequiredForDefaultLocale as t}from"../../core/utils/zod.util";import{locale as a}from"../../schemas/locales.schema";import{optionalInteger as n,optionalNumber as c,requiredNumber as s}from"../../schemas/number.schema";import{FileSchema as p}from"../file/file.schema";import{ProductCategorySchema as u}from"../product-category/product-category.schema";import{CreateOrUpdateModifierGroupSchema as d,LocalizedModifierGroupSchema as l,ModifierGroupSchema as m}from"./product-modifier.schema";export const ProductSchema=e.object({id:e.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the product"}),slug:e.string().optional().openapi({example:"premium-watch",description:"Unique slug for the product"}),sku:e.string().optional().openapi({example:"PRM-WATCH-01",description:"Stock Keeping Unit identifier"}),availableQuantity:n.openapi({example:12,description:"Available stock quantity. Null means unlimited inventory."}),basePrice:s,discountedBasePrice:c,currency:e.string().openapi({example:"USD",description:"Currency code for pricing"}),images:e.array(p).optional().openapi({description:"List of product images"}),modifierGroups:e.array(m).optional().openapi({description:"List of product modifier groups"}),categories:e.array(u).openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"}),manufacturerId:e.string().cuid().nullable().optional().openapi({description:"ID of associated manufacturer"}),createdAt:e.date(),publishedAt:e.date().nullable().optional(),translations:e.array(e.object({locale:a,title:e.coerce.string().optional().openapi({example:"Premium Watch",description:"Product name in specified locale"}),description:e.string().nullable().optional().openapi({example:"High-quality premium watch",description:"Product description in specified locale"})})).optional(),metadata:e.record(e.string().min(1,"Key cannot be empty").max(50,"Key too long").regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,"Key must start with letter and contain only letters, numbers, underscore, or dash"),e.string().min(1,"Value cannot be empty").max(200,"Value too long")).optional().nullable()}).openapi("Product"),LocalizedProductSchema=ProductSchema.extend({title:e.string().default(""),description:e.string().nullable().default(""),modifierGroups:e.array(l),categories:e.array(e.object({id:e.string().cuid().openapi({example:"cju0z9k4z0000l1qg5z1z1z",description:"ID of the product category"})})).default([])}).omit({translations:!0}).openapi("LocalizedProduct");const r=ProductSchema.pick({slug:!0,sku:!0,availableQuantity:!0,basePrice:!0,discountedBasePrice:!0,currency:!0,images:!0,manufacturerId:!0,translations:!0,metadata:!0}).extend({defaultLocale:e.string().min(1,"Default locale is required").openapi({example:"en-US",description:"Default translation locale"}),modifierGroups:e.array(d).optional().openapi({description:"List of product modifier groups"}),categories:e.array(e.string()).optional().openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"})});export const CreateProductSchema=r.superRefine((i,o)=>(i.discountedBasePrice!==null&&i.discountedBasePrice!==void 0&&i.discountedBasePrice>i.basePrice&&o.addIssue({code:e.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),t("title")(i,o))).openapi("CreateProduct"),UpdateProductSchema=r.partial().superRefine((i,o)=>(i.discountedBasePrice!==null&&i.discountedBasePrice!==void 0&&i.basePrice&&i.discountedBasePrice>i.basePrice&&o.addIssue({code:e.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),t("title")(i,o))).openapi("UpdateProduct");
@@ -1 +1 @@
1
- const _0x2a4125=_0x1c30,_0x15b147=_0x1c30;(function(_0x536d98,_0x5356f9){const _0x5f58fe=_0x1c30,_0x158485=_0x1c30,_0x1f3c1b=_0x536d98();while(!![]){try{const _0x566f28=-parseInt(_0x5f58fe(0x10a))/0x1+parseInt(_0x5f58fe(0xed))/0x2*(-parseInt(_0x158485(0x12d))/0x3)+parseInt(_0x158485(0xfb))/0x4*(parseInt(_0x158485(0x131))/0x5)+parseInt(_0x5f58fe(0xee))/0x6+-parseInt(_0x5f58fe(0x125))/0x7+-parseInt(_0x5f58fe(0xfa))/0x8*(parseInt(_0x5f58fe(0x116))/0x9)+parseInt(_0x158485(0xfc))/0xa*(parseInt(_0x5f58fe(0xf9))/0xb);if(_0x566f28===_0x5356f9)break;else _0x1f3c1b['push'](_0x1f3c1b['shift']());}catch(_0x101bb6){_0x1f3c1b['push'](_0x1f3c1b['shift']());}}}(_0xefd1,0xc9e90));import{__awaiter as _0x51da33}from'tslib';import{z as _0x46136f}from'@hono/zod-openapi';import{HttpException as _0x3f48dd}from'../../core/exceptions/http-exception';function _0x1c30(_0x372be,_0x2085e6){_0x372be=_0x372be-0xea;const _0xefd1e5=_0xefd1();let _0x1c308b=_0xefd1e5[_0x372be];if(_0x1c30['BqaFsR']===undefined){var _0x50a8ed=function(_0x430d35){const _0x194835='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3977bb='',_0x4993fb='';for(let _0x1a0a1d=0x0,_0x235e9,_0x72f6d2,_0x5e3108=0x0;_0x72f6d2=_0x430d35['charAt'](_0x5e3108++);~_0x72f6d2&&(_0x235e9=_0x1a0a1d%0x4?_0x235e9*0x40+_0x72f6d2:_0x72f6d2,_0x1a0a1d++%0x4)?_0x3977bb+=String['fromCharCode'](0xff&_0x235e9>>(-0x2*_0x1a0a1d&0x6)):0x0){_0x72f6d2=_0x194835['indexOf'](_0x72f6d2);}for(let _0x5115d9=0x0,_0x2c2789=_0x3977bb['length'];_0x5115d9<_0x2c2789;_0x5115d9++){_0x4993fb+='%'+('00'+_0x3977bb['charCodeAt'](_0x5115d9)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4993fb);};_0x1c30['eOeLKm']=_0x50a8ed,_0x1c30['wgSTEE']={},_0x1c30['BqaFsR']=!![];}const _0x395f82=_0xefd1e5[0x0],_0x24f906=_0x372be+_0x395f82,_0x4987ee=_0x1c30['wgSTEE'][_0x24f906];return!_0x4987ee?(_0x1c308b=_0x1c30['eOeLKm'](_0x1c308b),_0x1c30['wgSTEE'][_0x24f906]=_0x1c308b):_0x1c308b=_0x4987ee,_0x1c308b;}import{flattenTranslationData as _0xec1513}from'../../core/utils/zod.util';import{LocalizedProductSchema as _0x4d0580,PaginationMetaSchema as _0x2d108f,ProductSchema as _0x418472}from'../../schemas';function _0xefd1(){const _0x108f37=['zvf1yw50Axq','ChvIBgLZAgu','Aw5JBhvKzq','B2jQzwn0','Aw9UCW','ChvIBgLZAa','mZa0nduXmgf6wM1Syq','DxbKyxrLuhi','ChjVzhvJDfm','zMLUzfvUAxe','C2X1zW','DLfmrvC','DxbKyxrL','yxnZAwDU','mZm4mdm2n3j5vvjQCa','BwfUDwzHy3q','DhvZ','CLPsuLm','mJe1AufRvunq','z2v0uhjVzhu','BwfW','Dw5WDwjSAxm','mMj0vNDhAW','nZuZndGYnerxBuPKta','yxjYyxK','CgfYC2u','ChjVzhvJDa','BM90igzVDw4','ChjPC21H','zhzcEKG','tK5wtuO','B2r1y3rtDge','B2r1y3q','zgLZy291BNq','mtu3mZC1ntDmzxbJrLy','mtK5mZq5nKXsr0jgva','ntaXndHry0rnsLO','mtbsDM1tsuq','Bwv0ywrHDge','y3rZqNLdyxq','Aw5Zzw5ZAxq','r3jVDxbZ','AgvK','y3jLyxrL','Dwn0','C2vSzwn0twK','AxzL','yMfZzvbYAwm','EhLYrLm','y3vYCMvUy3K','zMLUzfbYB2q','ntG3nJuYBvflA0Xn','Bw9KAwzPzxi','C2T1','DxjLCKLK','AwnL','zgvZyW','y3jLyxrLuhi','BMfWC2HVDa','D2L0AfbHz2u','zwDVCNK','y2f0zwDVCMK','zwrcyxnLuhi','own6zLjsCa','uhjVzhvJDca','DhjHBNnSyxq','C2vSzwn0twe','Aw1Hz2vZ','yxzHAwXHyMW','zgvSzxrLuhi','y3rZ','jhrYyw5Zywm'];_0xefd1=function(){return _0x108f37;};return _0xefd1();}class O{constructor(_0x4a8d00){const _0x1bda4f=_0x1c30;this[_0x1bda4f(0xf3)]=_0x4a8d00;}[_0x2a4125(0x109)+_0x2a4125(0x103)](_0x245cf1,_0x87021d,_0x2d0364){return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x2ecf33=_0x1c30,_0xebcaca=_0x1c30,_0x22d507=yield this[_0x2ecf33(0xf3)][_0xebcaca(0xf1)][_0xebcaca(0x128)+'ue']({'where':{'id':_0x245cf1,'organizationId':_0x87021d,'deletedAt':null},'include':_0x2d0364?.[_0x2ecf33(0x121)]});if(!_0x22d507)throw new _0x3f48dd(0x194,_0x2ecf33(0x117)+_0x2ecf33(0xf2)+'d');return _0x22d507;});}[_0x15b147(0x110)+_0x15b147(0xf7)](_0x117ee8,_0x7ff0de,_0x1323c0){return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x2e6cf9=_0x1c30,_0x29fbb5=_0x1c30,_0x232dc4=yield this[_0x2e6cf9(0xf3)][_0x2e6cf9(0x11e)+'tion'](_0x4e3419=>_0x51da33(this,void 0x0,void 0x0,function*(){const _0x3b7c00=_0x29fbb5,_0x535c09=_0x29fbb5;var _0x4440ca,_0x554e04;const _0x566e0f=yield _0x4e3419[_0x3b7c00(0xf1)][_0x3b7c00(0x102)]({'data':Object[_0x3b7c00(0x12c)](Object[_0x3b7c00(0x12c)]({'slug':_0x1323c0[_0x535c09(0x129)],'sku':_0x1323c0[_0x3b7c00(0x10c)],'availableQuantity':_0x1323c0['availabl'+_0x535c09(0x11f)+'y'],'basePrice':_0x1323c0[_0x535c09(0x106)+'e'],'discountedBasePrice':_0x1323c0[_0x3b7c00(0xf8)+_0x535c09(0x115)+'ice'],'currency':_0x1323c0[_0x535c09(0x108)],'organizationId':_0x117ee8,'manufacturerId':_0x1323c0['manufact'+_0x3b7c00(0x10d)],'createdBy':_0x7ff0de,'translations':{'create':_0x1323c0[_0x3b7c00(0x118)+_0x535c09(0x123)]},'images':{'connect':(_0x4440ca=_0x1323c0[_0x535c09(0x11a)])===null||_0x4440ca===void 0x0?void 0x0:_0x4440ca[_0x535c09(0xeb)](_0xe404e1=>({'id':_0xe404e1['id']}))},'modifierGroups':{'create':(_0x554e04=_0x1323c0[_0x535c09(0x10b)+_0x3b7c00(0x100)])===null||_0x554e04===void 0x0?void 0x0:_0x554e04[_0x535c09(0xeb)](_0x48bd64=>({'selectMin':_0x48bd64[_0x3b7c00(0x104)+'n'],'selectMax':_0x48bd64[_0x535c09(0x119)+'x'],'translations':{'create':_0x48bd64[_0x3b7c00(0x118)+_0x535c09(0x123)]},'modifiers':{'create':_0x48bd64['modifier'+'s']}}))}},_0x1323c0[_0x535c09(0x114)+'es']?{'categories':{'connect':_0x1323c0[_0x3b7c00(0x114)+'es'][_0x3b7c00(0xeb)](_0x106ae3=>({'id':_0x106ae3}))}}:void 0x0),{'metadata':_0x1323c0[_0x535c09(0xfd)]||{}}),'include':{'translations':!0x0,'images':!0x0,'categories':{'include':{'translations':!0x0}},'modifierGroups':{'include':{'translations':!0x0,'modifiers':!0x0}}}}),_0x5a4098=yield _0x4e3419[_0x535c09(0x127)+_0x535c09(0x111)][_0x535c09(0x102)]({'data':{'productId':_0x566e0f['id'],'data':_0x566e0f,'createdBy':_0x7ff0de}});return yield _0x4e3419[_0x3b7c00(0xf1)]['update']({'where':{'id':_0x566e0f['id']},'data':{'latestSnapshotId':_0x5a4098['id']}}),_0x566e0f;}));return _0x418472[_0x29fbb5(0xf0)](_0x232dc4);});}[_0x2a4125(0xea)+'ct'](_0x58dd2c,_0x276ec0,_0x1e5ffc){return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x2d416f=_0x1c30,_0x5bb6c4=_0x1c30,{locale:_0x3e1293}=_0x1e5ffc,_0xfbb8a8=yield this[_0x2d416f(0x109)+_0x5bb6c4(0x103)](_0x276ec0,_0x58dd2c,Object[_0x2d416f(0x12c)](Object[_0x2d416f(0x12c)]({},_0x1e5ffc[_0x5bb6c4(0x120)+'d']&&{'publishedAt':{'not':null}}),{'include':{'translations':_0x3e1293?{'where':{'locale':_0x3e1293}}:!0x0,'images':!0x0,'categories':{'include':{'translations':_0x3e1293?{'where':{'locale':_0x3e1293}}:!0x0}},'modifierGroups':{'include':{'translations':_0x3e1293?{'where':{'locale':_0x3e1293}}:!0x0,'modifiers':!0x0}}}}));return _0x3e1293?_0x4d0580[_0x2d416f(0xf0)](_0xec1513(_0xfbb8a8)):_0x418472[_0x2d416f(0xf0)](_0xfbb8a8);});}[_0x15b147(0xea)+_0x2a4125(0x11d)](_0x289cea,_0xc0b254){const _0x4aced9=_0x2a4125,_0x101e70={'rZRRS':_0x4aced9(0x10f)};return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x42c5a8=_0x4aced9,_0x11f5b1=_0x4aced9,{page:_0x2c0586=0x1,limit:_0x564418=0xa,search:_0x2c8742,locale:_0x40dd76,published:_0x59466f,categoryId:_0xc40263,publishedStatus:_0x254d80}=_0xc0b254,_0xb9a94f=_0x59466f||_0x254d80===_0x42c5a8(0x120)+'d'?{'publishedAt':{'not':null}}:_0x254d80===_0x11f5b1(0xec)+_0x11f5b1(0x101)?{'publishedAt':null}:void 0x0,[_0x511498,_0x52a427]=yield this[_0x42c5a8(0xf3)][_0x11f5b1(0xf1)]['paginate']({'orderBy':{'createdAt':_0x101e70[_0x42c5a8(0x130)]},'where':Object[_0x11f5b1(0x12c)](Object[_0x42c5a8(0x12c)](Object[_0x11f5b1(0x12c)]({'organizationId':_0x289cea,'deletedAt':null},_0xc40263&&{'categories':{'some':{'id':_0xc40263}}}),_0x2c8742&&{'translations':{'some':{'title':{'contains':_0x2c8742,'mode':_0x11f5b1(0xff)+'ive'}}}}),_0xb9a94f??{}),'include':{'translations':_0x40dd76?{'where':{'locale':_0x40dd76}}:!0x0,'images':!0x0,'categories':{'include':{'translations':_0x40dd76?{'where':{'locale':_0x40dd76}}:!0x0}},'modifierGroups':{'include':{'translations':_0x40dd76?{'where':{'locale':_0x40dd76}}:!0x0,'modifiers':!0x0}}}})[_0x11f5b1(0x112)+'s']({'page':_0x2c0586,'limit':_0x564418});if(!_0x40dd76)return _0x46136f[_0x42c5a8(0x122)]({'meta':_0x2d108f,'list':_0x46136f[_0x42c5a8(0xef)](_0x418472)})[_0x42c5a8(0xf0)]({'meta':_0x52a427,'list':_0x511498});const _0xd63591=_0x511498[_0x42c5a8(0xeb)](_0x58b5fd=>_0xec1513(_0x58b5fd));return _0x46136f[_0x42c5a8(0x122)]({'meta':_0x2d108f,'list':_0x46136f['array'](_0x4d0580)})[_0x11f5b1(0xf0)]({'meta':_0x52a427,'list':_0xd63591});});}[_0x2a4125(0xea)+_0x2a4125(0xfe)+_0x15b147(0x113)](_0x312d13,_0x152953,_0x30b6b4){return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x13f064=_0x1c30,_0x540639=_0x1c30,{page:_0x404813=0x1,limit:_0x53f04d=0xa,search:_0x5312a8,locale:_0xec3f43}=_0x30b6b4,[_0x40c2d2,_0x62be3a]=yield this[_0x13f064(0xf3)][_0x540639(0xf1)]['paginate']({'orderBy':{'createdAt':'desc'},'where':Object[_0x13f064(0x12c)]({'organizationId':_0x312d13,'deletedAt':null,'categories':{'some':{'id':_0x152953}}},_0x5312a8&&{'translations':{'some':{'title':{'contains':_0x5312a8,'mode':_0x13f064(0xff)+_0x13f064(0x105)}}}}),'include':{'translations':_0xec3f43?{'where':{'locale':_0xec3f43}}:!0x0,'images':!0x0,'categories':{'include':{'translations':_0xec3f43?{'where':{'locale':_0xec3f43}}:!0x0}},'modifierGroups':{'include':{'translations':_0xec3f43?{'where':{'locale':_0xec3f43}}:!0x0,'modifiers':!0x0}}}})[_0x540639(0x112)+'s']({'page':_0x404813,'limit':_0x53f04d}),_0x1b5483=_0xec3f43?_0x40c2d2['map'](_0x1a8435=>_0x418472[_0x13f064(0xf0)](_0xec1513(_0x1a8435))):_0x40c2d2[_0x13f064(0xeb)](_0x28a126=>_0x418472[_0x540639(0xf0)](_0x28a126));return _0x46136f[_0x540639(0x122)]({'meta':_0x2d108f,'list':_0x46136f['array'](_0x418472)})[_0x540639(0xf0)]({'meta':_0x62be3a,'list':_0x1b5483});});}['updatePr'+_0x15b147(0xf7)](_0x2435e9,_0x262d48,_0x1d87b1,_0x106f9d){const _0x1bbd67=_0x2a4125,_0xd69688={'vQLEW':function(_0x4eb7f2,_0x520186){return _0x4eb7f2!==_0x520186;},'xyrFS':function(_0x6a89b6,_0x2d8d1d,_0x48f869,_0x2e43b2,_0x2144d1){return _0x6a89b6(_0x2d8d1d,_0x48f869,_0x2e43b2,_0x2144d1);}};return _0xd69688[_0x1bbd67(0x107)](_0x51da33,this,void 0x0,void 0x0,function*(){const _0x3eefad=_0x1bbd67,_0x15a281=_0x1bbd67;yield this[_0x3eefad(0x109)+_0x15a281(0x103)](_0x262d48,_0x2435e9);const _0x5eb025=yield this[_0x15a281(0xf3)][_0x3eefad(0x11e)+'tion'](_0x28eac5=>_0x51da33(this,void 0x0,void 0x0,function*(){const _0x3cd283=_0x15a281,_0x3d8f45=_0x15a281;var _0x3d3479;const _0x2c6e1d=Object[_0x3cd283(0x12c)](Object['assign'](Object[_0x3cd283(0x12c)](Object['assign'](Object[_0x3cd283(0x12c)](Object[_0x3cd283(0x12c)](Object[_0x3d8f45(0x12c)](Object[_0x3cd283(0x12c)](Object['assign'](Object[_0x3d8f45(0x12c)](Object[_0x3cd283(0x12c)](Object[_0x3d8f45(0x12c)](Object[_0x3d8f45(0x12c)]({},_0x106f9d[_0x3cd283(0x129)]!==void 0x0?{'slug':_0x106f9d['slug']}:{}),_0x106f9d[_0x3cd283(0x10c)]!==void 0x0?{'sku':_0x106f9d[_0x3cd283(0x10c)]}:{}),_0x106f9d[_0x3d8f45(0x11b)+_0x3d8f45(0x11f)+'y']!==void 0x0?{'availableQuantity':_0x106f9d[_0x3cd283(0x11b)+_0x3d8f45(0x11f)+'y']}:{}),_0x106f9d[_0x3d8f45(0x106)+'e']!==void 0x0?{'basePrice':_0x106f9d[_0x3cd283(0x106)+'e']}:{}),_0x106f9d[_0x3cd283(0xf8)+_0x3d8f45(0x115)+_0x3cd283(0x10e)]!==void 0x0?{'discountedBasePrice':_0x106f9d[_0x3cd283(0xf8)+'edBasePr'+_0x3d8f45(0x10e)]}:{}),_0x106f9d[_0x3d8f45(0x108)]!==void 0x0?{'currency':_0x106f9d[_0x3cd283(0x108)]}:{}),_0x106f9d[_0x3cd283(0x12e)+_0x3d8f45(0x10d)]!==void 0x0?{'manufacturerId':_0x106f9d[_0x3d8f45(0x12e)+_0x3cd283(0x10d)]}:{}),{'updatedBy':_0x1d87b1}),_0x106f9d[_0x3cd283(0x118)+_0x3d8f45(0x123)]!==void 0x0?{'translations':{'deleteMany':{},'create':_0x106f9d[_0x3d8f45(0x118)+_0x3d8f45(0x123)]}}:{}),_0x106f9d[_0x3d8f45(0x11a)]!==void 0x0?{'images':{'set':_0x106f9d['images'][_0x3d8f45(0xeb)](_0x56fd6d=>({'id':_0x56fd6d['id']}))}}:{}),_0x106f9d[_0x3d8f45(0x10b)+_0x3cd283(0x100)]!==void 0x0?{'modifierGroups':{'deleteMany':{},'create':_0x106f9d[_0x3cd283(0x10b)+_0x3d8f45(0x100)][_0x3cd283(0xeb)](_0x2cf260=>({'selectMin':_0x2cf260[_0x3cd283(0x104)+'n'],'selectMax':_0x2cf260['selectMa'+'x'],'translations':{'create':_0x2cf260[_0x3d8f45(0x118)+'ions']},'modifiers':{'create':_0x2cf260[_0x3d8f45(0x10b)+'s']}}))}}:{}),_0x106f9d[_0x3cd283(0x114)+'es']!==void 0x0?{'categories':{'set':_0x106f9d[_0x3cd283(0x114)+'es'][_0x3cd283(0xeb)](_0x49418c=>({'id':_0x49418c}))}}:{}),_0x106f9d[_0x3d8f45(0xfd)]!==void 0x0?{'metadata':_0xd69688[_0x3d8f45(0x12a)](_0x3d3479=_0x106f9d[_0x3d8f45(0xfd)],null)&&_0x3d3479!==void 0x0?_0x3d3479:{}}:{}),_0x40c425=yield _0x28eac5[_0x3cd283(0xf1)]['update']({'where':{'id':_0x262d48,'organizationId':_0x2435e9,'deletedAt':null},'data':_0x2c6e1d,'include':{'translations':!0x0,'images':!0x0,'categories':{'include':{'translations':!0x0}},'modifierGroups':{'include':{'translations':!0x0,'modifiers':!0x0}}}}),_0x1997d5=yield _0x28eac5['productS'+_0x3cd283(0x111)][_0x3cd283(0x102)]({'data':{'productId':_0x40c425['id'],'data':_0x40c425,'createdBy':_0x1d87b1}});return yield _0x28eac5[_0x3d8f45(0xf1)][_0x3d8f45(0x12b)]({'where':{'id':_0x40c425['id']},'data':{'latestSnapshotId':_0x1997d5['id']}}),_0x40c425;}));return _0x418472[_0x3eefad(0xf0)](_0x5eb025);});}[_0x15b147(0x126)+_0x15b147(0xf6)+_0x15b147(0x12f)](_0x480334,_0x271764,_0x15d80f,_0x50ebea){const _0x5dfcfb=_0x2a4125,_0x3377de=_0x2a4125,_0x36ccbc={'dvBzH':_0x5dfcfb(0x124),'NNVMJ':function(_0x2f3a6e,_0x263254,_0x597f81,_0x4d9fab,_0x3327cf){return _0x2f3a6e(_0x263254,_0x597f81,_0x4d9fab,_0x3327cf);}};return _0x36ccbc[_0x5dfcfb(0xf5)](_0x51da33,this,void 0x0,void 0x0,function*(){const _0x414c00=_0x3377de,_0x12918a=_0x3377de;yield this[_0x414c00(0x109)+'uct'](_0x271764,_0x480334);const _0x2c4a28=yield this[_0x414c00(0xf3)]['product'][_0x12918a(0x12b)]({'where':{'id':_0x271764,'organizationId':_0x480334,'deletedAt':null},'data':{'publishedAt':_0x15d80f===_0x414c00(0x124)?new Date():null,'publishedBy':_0x15d80f===_0x36ccbc[_0x414c00(0xf4)]?_0x50ebea:null,'updatedBy':_0x50ebea},'include':{'translations':!0x0,'images':!0x0,'categories':{'include':{'translations':!0x0}},'modifierGroups':{'include':{'translations':!0x0,'modifiers':!0x0}}}});return _0x418472[_0x414c00(0xf0)](_0x2c4a28);});}[_0x2a4125(0x11c)+_0x2a4125(0xf7)](_0x15c769,_0x1f257d,_0xca55b4){return _0x51da33(this,void 0x0,void 0x0,function*(){const _0x1191cb=_0x1c30,_0x262130=_0x1c30;yield this['findProd'+_0x1191cb(0x103)](_0x1f257d,_0x15c769),yield this[_0x1191cb(0xf3)][_0x1191cb(0xf1)][_0x1191cb(0x12b)]({'where':{'id':_0x1f257d,'organizationId':_0x15c769,'deletedAt':null},'data':{'deletedAt':new Date(),'deletedBy':_0xca55b4}});});}}export{O as ProductService};
1
+ import{__awaiter as l}from"tslib";import{z as m}from"@hono/zod-openapi";import{HttpException as w}from"../../core/exceptions/http-exception";import{flattenTranslationData as f}from"../../core/utils/zod.util";import{LocalizedProductSchema as v,PaginationMetaSchema as h,ProductSchema as p}from"../../schemas";class O{constructor(i){this.prisma=i}findProduct(i,a,t){return l(this,void 0,void 0,function*(){const e=yield this.prisma.product.findUnique({where:{id:i,organizationId:a,deletedAt:null},include:t?.include});if(!e)throw new w(404,"Product not found");return e})}createProduct(i,a,t){return l(this,void 0,void 0,function*(){const e=yield this.prisma.$transaction(d=>l(this,void 0,void 0,function*(){var s,r;const c=yield d.product.create({data:Object.assign(Object.assign({slug:t.slug,sku:t.sku,availableQuantity:t.availableQuantity,basePrice:t.basePrice,discountedBasePrice:t.discountedBasePrice,currency:t.currency,organizationId:i,manufacturerId:t.manufacturerId,createdBy:a,translations:{create:t.translations},images:{connect:(s=t.images)===null||s===void 0?void 0:s.map(n=>({id:n.id}))},modifierGroups:{create:(r=t.modifierGroups)===null||r===void 0?void 0:r.map(n=>({selectMin:n.selectMin,selectMax:n.selectMax,translations:{create:n.translations},modifiers:{create:n.modifiers}}))}},t.categories?{categories:{connect:t.categories.map(n=>({id:n}))}}:void 0),{metadata:t.metadata||{}}),include:{translations:!0,images:!0,categories:{include:{translations:!0}},modifierGroups:{include:{translations:!0,modifiers:!0}}}}),o=yield d.productSnapshot.create({data:{productId:c.id,data:c,createdBy:a}});return yield d.product.update({where:{id:c.id},data:{latestSnapshotId:o.id}}),c}));return p.parse(e)})}getProduct(i,a,t){return l(this,void 0,void 0,function*(){const{locale:e}=t,d=yield this.findProduct(a,i,Object.assign(Object.assign({},t.published&&{publishedAt:{not:null}}),{include:{translations:e?{where:{locale:e}}:!0,images:!0,categories:{include:{translations:e?{where:{locale:e}}:!0}},modifierGroups:{include:{translations:e?{where:{locale:e}}:!0,modifiers:!0}}}}));return e?v.parse(f(d)):p.parse(d)})}getProducts(i,a){return l(this,void 0,void 0,function*(){const{page:t=1,limit:e=10,search:d,locale:s,published:r,categoryId:c,publishedStatus:o}=a,n=r||o==="published"?{publishedAt:{not:null}}:o==="unpublished"?{publishedAt:null}:void 0,[u,g]=yield this.prisma.product.paginate({orderBy:{createdAt:"desc"},where:Object.assign(Object.assign(Object.assign({organizationId:i,deletedAt:null},c&&{categories:{some:{id:c}}}),d&&{translations:{some:{title:{contains:d,mode:"insensitive"}}}}),n??{}),include:{translations:s?{where:{locale:s}}:!0,images:!0,categories:{include:{translations:s?{where:{locale:s}}:!0}},modifierGroups:{include:{translations:s?{where:{locale:s}}:!0,modifiers:!0}}}}).withPages({page:t,limit:e});if(!s)return m.object({meta:h,list:m.array(p)}).parse({meta:g,list:u});const P=u.map(j=>f(j));return m.object({meta:h,list:m.array(v)}).parse({meta:g,list:P})})}getProductsByCategory(i,a,t){return l(this,void 0,void 0,function*(){const{page:e=1,limit:d=10,search:s,locale:r}=t,[c,o]=yield this.prisma.product.paginate({orderBy:{createdAt:"desc"},where:Object.assign({organizationId:i,deletedAt:null,categories:{some:{id:a}}},s&&{translations:{some:{title:{contains:s,mode:"insensitive"}}}}),include:{translations:r?{where:{locale:r}}:!0,images:!0,categories:{include:{translations:r?{where:{locale:r}}:!0}},modifierGroups:{include:{translations:r?{where:{locale:r}}:!0,modifiers:!0}}}}).withPages({page:e,limit:d}),n=r?c.map(u=>p.parse(f(u))):c.map(u=>p.parse(u));return m.object({meta:h,list:m.array(p)}).parse({meta:o,list:n})})}updateProduct(i,a,t,e){return l(this,void 0,void 0,function*(){yield this.findProduct(a,i);const d=yield this.prisma.$transaction(s=>l(this,void 0,void 0,function*(){var r;const c=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e.slug!==void 0?{slug:e.slug}:{}),e.sku!==void 0?{sku:e.sku}:{}),e.availableQuantity!==void 0?{availableQuantity:e.availableQuantity}:{}),e.basePrice!==void 0?{basePrice:e.basePrice}:{}),e.discountedBasePrice!==void 0?{discountedBasePrice:e.discountedBasePrice}:{}),e.currency!==void 0?{currency:e.currency}:{}),e.manufacturerId!==void 0?{manufacturerId:e.manufacturerId}:{}),{updatedBy:t}),e.translations!==void 0?{translations:{deleteMany:{},create:e.translations}}:{}),e.images!==void 0?{images:{set:e.images.map(u=>({id:u.id}))}}:{}),e.modifierGroups!==void 0?{modifierGroups:{deleteMany:{},create:e.modifierGroups.map(u=>({selectMin:u.selectMin,selectMax:u.selectMax,translations:{create:u.translations},modifiers:{create:u.modifiers}}))}}:{}),e.categories!==void 0?{categories:{set:e.categories.map(u=>({id:u}))}}:{}),e.metadata!==void 0?{metadata:(r=e.metadata)!==null&&r!==void 0?r:{}}:{}),o=yield s.product.update({where:{id:a,organizationId:i,deletedAt:null},data:c,include:{translations:!0,images:!0,categories:{include:{translations:!0}},modifierGroups:{include:{translations:!0,modifiers:!0}}}}),n=yield s.productSnapshot.create({data:{productId:o.id,data:o,createdBy:t}});return yield s.product.update({where:{id:o.id},data:{latestSnapshotId:n.id}}),o}));return p.parse(d)})}updateProductStatus(i,a,t,e){return l(this,void 0,void 0,function*(){yield this.findProduct(a,i);const d=yield this.prisma.product.update({where:{id:a,organizationId:i,deletedAt:null},data:{publishedAt:t==="publish"?new Date:null,publishedBy:t==="publish"?e:null,updatedBy:e},include:{translations:!0,images:!0,categories:{include:{translations:!0}},modifierGroups:{include:{translations:!0,modifiers:!0}}}});return p.parse(d)})}deleteProduct(i,a,t){return l(this,void 0,void 0,function*(){yield this.findProduct(a,i),yield this.prisma.product.update({where:{id:a,organizationId:i,deletedAt:null},data:{deletedAt:new Date,deletedBy:t}})})}}export{O as ProductService};
@@ -1 +1 @@
1
- (function(_0x646799,_0x21adf3){const _0x179bee=_0x2f73,_0x96dd23=_0x2f73,_0x4ce5a7=_0x646799();while(!![]){try{const _0x33a1bd=parseInt(_0x179bee(0xf3))/0x1+parseInt(_0x96dd23(0xe4))/0x2+parseInt(_0x96dd23(0xe8))/0x3+-parseInt(_0x179bee(0xf2))/0x4+-parseInt(_0x96dd23(0xe1))/0x5+-parseInt(_0x179bee(0xe9))/0x6*(-parseInt(_0x179bee(0xe5))/0x7)+parseInt(_0x96dd23(0x105))/0x8*(-parseInt(_0x96dd23(0xec))/0x9);if(_0x33a1bd===_0x21adf3)break;else _0x4ce5a7['push'](_0x4ce5a7['shift']());}catch(_0x55f8b8){_0x4ce5a7['push'](_0x4ce5a7['shift']());}}}(_0x13e5,0x1f60e));function _0x13e5(){const _0x351f38=['ru5rAui','zwDVCNLtDge','ANnVBG','Bg9JywXL','z2v0','DgLVBKLK','zwDVCNK','zgvSzxrLuhi','AxnhCMfUDgu','y3rdyxrLz28','y3jLyxrL','DxbKyxrLuhi','y3jLyxrLuhi','DxbKyxrL','CMvX','DMfSAwq','mJrytLHLvNu','CxvLCNK','rM5tELq','ndeYnJa1BMTbruXO','zgvSzxrL','CMLLCW','nda0ntqWD3jLB2vK','otqWofPfChnZrW','DhvZ','z2v0uhjVzhu','nZu3mty3t3jtAezZ','mta4qM1oBunM','B2r1y3rdyxq','B3jNyw5PEMe','ndK5odG3sMXRqLLZ','CgfYyw0','B3bLBMfWAq','yxv0Aa','yxnZAwDU','ChvIBgLZAgu','ntu5ota0t0zlwvvU','mZG4mdfwrhjks1e','zfn0yxr1CW'];_0x13e5=function(){return _0x351f38;};return _0x13e5();}import{__awaiter as _0x2b9232}from'tslib';import{createApiRouter as _0x2a9d45}from'../../core/hono/hono';import{productCategoryRoute as _0x123865}from'./product-category.route';function _0x2f73(_0x4fc11b,_0x127479){_0x4fc11b=_0x4fc11b-0xe0;const _0x13e594=_0x13e5();let _0x2f7378=_0x13e594[_0x4fc11b];if(_0x2f73['TOHFvj']===undefined){var _0x232c1d=function(_0x2668f1){const _0x499a2a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4f2b1f='',_0x53ac07='';for(let _0x2c8051=0x0,_0x2482d6,_0x4b44a4,_0x39637d=0x0;_0x4b44a4=_0x2668f1['charAt'](_0x39637d++);~_0x4b44a4&&(_0x2482d6=_0x2c8051%0x4?_0x2482d6*0x40+_0x4b44a4:_0x4b44a4,_0x2c8051++%0x4)?_0x4f2b1f+=String['fromCharCode'](0xff&_0x2482d6>>(-0x2*_0x2c8051&0x6)):0x0){_0x4b44a4=_0x499a2a['indexOf'](_0x4b44a4);}for(let _0x493282=0x0,_0x4c93f5=_0x4f2b1f['length'];_0x493282<_0x4c93f5;_0x493282++){_0x53ac07+='%'+('00'+_0x4f2b1f['charCodeAt'](_0x493282)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x53ac07);};_0x2f73['jWOGlw']=_0x232c1d,_0x2f73['ekpwQU']={},_0x2f73['TOHFvj']=!![];}const _0x19fc35=_0x13e594[0x0],_0x3d3b46=_0x4fc11b+_0x19fc35,_0x52bcc3=_0x2f73['ekpwQU'][_0x3d3b46];return!_0x52bcc3?(_0x2f7378=_0x2f73['jWOGlw'](_0x2f7378),_0x2f73['ekpwQU'][_0x3d3b46]=_0x2f7378):_0x2f7378=_0x52bcc3,_0x2f7378;}export const registerProductCategoryHandlers=_0x140da8=>{const _0x237ae0=_0x2f73,_0x3db382=_0x2f73,_0x52578b={'FnSzT':_0x237ae0(0xed),'ENQiB':_0x3db382(0x102)},_0x2b27a6=_0x2a9d45();return _0x2b27a6[_0x237ae0(0xee)](_0x123865[_0x237ae0(0x101)+_0x237ae0(0xea)+'egory'],_0x4d4049=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0x1b82f1=_0x3db382,_0x1a61ca=_0x3db382,_0x1f169d=_0x4d4049[_0x1b82f1(0xf9)]('auth'),_0x2e5bf7=_0x4d4049[_0x1a61ca(0x103)][_0x1b82f1(0x104)](_0x1a61ca(0xed)),_0x447923=_0x4d4049[_0x1b82f1(0x103)]['valid'](_0x1a61ca(0xf7)),_0x6dc1cd=yield _0x1f169d[_0x1a61ca(0xfd)+'d'](_0x1a61ca(0xff)),_0x477a26=yield _0x140da8[_0x1b82f1(0x101)+_0x1a61ca(0xea)+_0x1b82f1(0xfb)](_0x2e5bf7[_0x1b82f1(0xeb)+_0x1b82f1(0xfa)],_0x6dc1cd['id'],_0x447923);return _0x4d4049[_0x1b82f1(0xf7)](_0x477a26,0xc9);})),_0x2b27a6[_0x3db382(0xee)](_0x123865[_0x3db382(0xe7)+_0x3db382(0xfe)+'ry'],_0x3a7b75=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0x159cc4=_0x237ae0,_0x165787=_0x237ae0,_0x3ff7a4=_0x3a7b75[_0x159cc4(0xf9)](_0x165787(0xef)),_0x26f040=_0x3a7b75[_0x165787(0x103)][_0x165787(0x104)](_0x52578b[_0x159cc4(0xe0)]),_0xf40e4e=_0x3a7b75['req'][_0x165787(0x104)]('query');yield _0x3ff7a4[_0x165787(0xfd)+'d']('read');const _0x39d7bf=yield _0x140da8[_0x165787(0xe7)+_0x165787(0xfe)+'ry'](_0x26f040[_0x165787(0xeb)+_0x165787(0xfa)],_0x26f040['id'],{'locale':_0xf40e4e[_0x165787(0xf8)]||null});return _0x3a7b75['json'](_0x39d7bf,0xc8);})),_0x2b27a6[_0x3db382(0xee)](_0x123865['getProdu'+_0x3db382(0xfe)+_0x237ae0(0xe3)],_0x8e34b3=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0xe03d47=_0x237ae0,_0x324087=_0x237ae0,_0x3630e3=_0x8e34b3[_0xe03d47(0x103)][_0xe03d47(0x104)]('param'),_0xd9082d=_0x8e34b3['req']['valid'](_0x324087(0x106)),_0x4d19f3=yield _0x140da8[_0xe03d47(0xe7)+_0xe03d47(0xfe)+_0x324087(0xe3)](_0x3630e3[_0xe03d47(0xeb)+'tionId'],Object[_0xe03d47(0xf0)](Object[_0xe03d47(0xf0)]({},_0xd9082d),{'locale':_0xd9082d[_0xe03d47(0xf8)]||null,'published':_0xd9082d[_0x324087(0xf1)+'d'],'publishedStatus':_0xd9082d[_0xe03d47(0xf1)+_0x324087(0xf4)]}));return _0x8e34b3[_0x324087(0xf7)](_0x4d19f3,0xc8);})),_0x2b27a6[_0x3db382(0xee)](_0x123865[_0x237ae0(0x100)+_0x3db382(0xea)+_0x237ae0(0xfb)],_0x538430=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0x50d7f5=_0x3db382,_0x4451a3=_0x3db382,_0x379c72=_0x538430[_0x50d7f5(0xf9)](_0x4451a3(0xef)),_0x54e189=_0x538430[_0x50d7f5(0x103)][_0x4451a3(0x104)]('param'),_0x171025=_0x538430[_0x4451a3(0x103)][_0x50d7f5(0x104)]('json'),_0x49f3a2=yield _0x379c72[_0x4451a3(0xfd)+'d'](_0x52578b[_0x50d7f5(0xf5)]),_0xe56597=yield _0x140da8['updatePr'+_0x50d7f5(0xea)+_0x4451a3(0xfb)](_0x54e189['organiza'+_0x4451a3(0xfa)],_0x54e189['id'],_0x49f3a2['id'],_0x171025);return _0x538430[_0x4451a3(0xf7)](_0xe56597,0xc8);})),_0x2b27a6[_0x237ae0(0xee)](_0x123865[_0x3db382(0x100)+_0x3db382(0xea)+_0x237ae0(0xf6)+'tus'],_0x4ca450=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0x41caaf=_0x3db382,_0x37dfa0=_0x3db382,_0x35d79a=_0x4ca450[_0x41caaf(0xf9)](_0x41caaf(0xef)),_0x4dec42=_0x4ca450[_0x41caaf(0x103)][_0x37dfa0(0x104)](_0x41caaf(0xed)),_0x5dbcb5=yield _0x35d79a[_0x41caaf(0xfd)+'d']('update'),_0x7cdaa5=yield _0x140da8[_0x37dfa0(0x100)+_0x37dfa0(0xea)+_0x41caaf(0xf6)+_0x37dfa0(0xe6)](_0x4dec42[_0x41caaf(0xeb)+'tionId'],_0x4dec42['id'],_0x4dec42['operatio'+'n'],_0x5dbcb5['id']);return _0x4ca450[_0x41caaf(0xf7)](_0x7cdaa5,0xc8);})),_0x2b27a6['openapi'](_0x123865[_0x3db382(0xfc)+_0x3db382(0xea)+'egory'],_0x58c604=>_0x2b9232(void 0x0,void 0x0,void 0x0,function*(){const _0x357c37=_0x237ae0,_0x3db4ac=_0x237ae0,_0x12380e=_0x58c604['get'](_0x357c37(0xef)),_0x494f9a=_0x58c604[_0x357c37(0x103)][_0x3db4ac(0x104)](_0x3db4ac(0xed)),_0x1dd518=yield _0x12380e[_0x3db4ac(0xfd)+'d'](_0x3db4ac(0xe2));return yield _0x140da8[_0x357c37(0xfc)+_0x357c37(0xea)+_0x3db4ac(0xfb)](_0x494f9a[_0x357c37(0xeb)+_0x3db4ac(0xfa)],_0x494f9a['id'],_0x1dd518['id']),_0x58c604['body'](null,0xcc);})),_0x2b27a6;};
1
+ import{__awaiter as n}from"tslib";import{createApiRouter as p}from"../../core/hono/hono";import{productCategoryRoute as u}from"./product-category.route";export const registerProductCategoryHandlers=i=>{const r=p();return r.openapi(u.createProductCategory,t=>n(void 0,void 0,void 0,function*(){const a=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("json"),d=yield a.isGranted("create"),s=yield i.createProductCategory(o.organizationId,d.id,e);return t.json(s,201)})),r.openapi(u.getProductCategory,t=>n(void 0,void 0,void 0,function*(){const a=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("query");yield a.isGranted("read");const d=yield i.getProductCategory(o.organizationId,o.id,{locale:e.locale||null});return t.json(d,200)})),r.openapi(u.getProductCategories,t=>n(void 0,void 0,void 0,function*(){const a=t.req.valid("param"),o=t.req.valid("query"),e=yield i.getProductCategories(a.organizationId,Object.assign(Object.assign({},o),{locale:o.locale||null,published:o.published,publishedStatus:o.publishedStatus}));return t.json(e,200)})),r.openapi(u.updateProductCategory,t=>n(void 0,void 0,void 0,function*(){const a=t.get("auth"),o=t.req.valid("param"),e=t.req.valid("json"),d=yield a.isGranted("update"),s=yield i.updateProductCategory(o.organizationId,o.id,d.id,e);return t.json(s,200)})),r.openapi(u.updateProductCategoryStatus,t=>n(void 0,void 0,void 0,function*(){const a=t.get("auth"),o=t.req.valid("param"),e=yield a.isGranted("update"),d=yield i.updateProductCategoryStatus(o.organizationId,o.id,o.operation,e.id);return t.json(d,200)})),r.openapi(u.deleteProductCategory,t=>n(void 0,void 0,void 0,function*(){const a=t.get("auth"),o=t.req.valid("param"),e=yield a.isGranted("delete");return yield i.deleteProductCategory(o.organizationId,o.id,e.id),t.body(null,204)})),r};
@@ -1 +1 @@
1
- const _0x192872=_0x1ddf,_0x4befd9=_0x1ddf;(function(_0xcde3f8,_0xcaebe3){const _0xa4dbf=_0x1ddf,_0x5d20e7=_0x1ddf,_0x3b58c2=_0xcde3f8();while(!![]){try{const _0x4b71c8=parseInt(_0xa4dbf(0x11f))/0x1+-parseInt(_0x5d20e7(0x100))/0x2*(parseInt(_0xa4dbf(0x142))/0x3)+-parseInt(_0x5d20e7(0xf0))/0x4+parseInt(_0xa4dbf(0x10a))/0x5+-parseInt(_0x5d20e7(0x127))/0x6*(-parseInt(_0xa4dbf(0x120))/0x7)+-parseInt(_0x5d20e7(0xf3))/0x8*(parseInt(_0x5d20e7(0xee))/0x9)+parseInt(_0x5d20e7(0xde))/0xa;if(_0x4b71c8===_0xcaebe3)break;else _0x3b58c2['push'](_0x3b58c2['shift']());}catch(_0x252b47){_0x3b58c2['push'](_0x3b58c2['shift']());}}}(_0x4974,0xdd7e6));import{z as _0x162fae}from'@hono/zod-openapi';import{createApiRoute as _0x67b171}from'../../core/hono/hono';function _0x4974(){const _0xf39134=['ntC0otK4ELDWuhHJ','Cgf0Aa','rMLSDgvYiha','AgvK','vxbKyxrLCYa','zxHPC3rPBMC','AcbVCIb1BNa','vgHLig9Wzxi','y3qGy2f0zwC','y2TLBdbLohe','l3bYB2r1y3q','B2jQzwn0','z2fUAxPHDgK','rgvSzxrLCYa','BML6yxrPB24','ysbZCgvJAwy','z29YEq','B2r1y3qGy2e','CMLLC1f1zxi','ChvIBgLZAa','CYbVzIbHBIa','r2v0ifbYB2q','zw51Bq','lwnHDgvNB3i','B3bLBMfWAq','DgvKigXPC3q','yxrLz29YEq','mtKZmdC3CMLXrMLx','ihn0yxr1CW','mZq3mJu0mZbKEgnIyNi','uhjVzhvJDem','ChvIBgLZAgu','DhvZ','y2f0zwDVCNK','Dw5WDwjSAxm','B3iGysbZCgu','vgHLig9Yz2e','CgvYyxrPB24','CM9KDwn0igm','BgLZAcbqCM8','EMf0Aw9Uswq','ihbLCMzVCM0','ysbUzxCGChi','yxrPB24GDg8','vxbKyxrLifa','mtGZnZq2n1HHAxDwBq','yxrLz29YAwu','ntKWmduXnMPXvKL5Bq','B3j5igj5ieK','C3rHDhvZlZO','ndHNvMnttum','CM9KDwn0iem','B3bLCMf0Aw8','B3jNyw5PEMe','y2LMAwmGB3i','rMv0y2HLCYa','yxjYyxK','Cdv3nMz6BNK','Dw5PB24','ue9tva','CYbIEsbWDwi','DZaWmda0BJu','zwDVCNLtDge','ntb6t1Lnsxy','DgvNB3j5igy','ysbWywDPBMe','DxbKyxrLuhi','DwjSAxnOkq','AwmGChjVzhu','y3rdyxrLz28','ignHDgvNB3i','ihb1yMXPC2G','r2v0uhjVzhu','nJm5ntiXmg9Zq3PnDa','ChjVzhvJDca','zwDVCNK','y3jLyxrLuhi','z29YAwvZigy','ihbYB2r1y3q','u2v0CYb0Agu','AwvZlZPPza','q3jLyxrLifa','z2v0uhjVzhu','ig9UihrOzsa','BgLJyxrPB24','CMLLCW','AwvZ','ig9MihbYB2q','zwqGC3rHDhu','C3rYAw5N','ieLe','z29YAwvZ','rgvSzxrLifa','Dwn0ignHDgu','ode0mdnMwuXcBwu','mJHMAhDmvhG','B2r1y3rdyxq','q3jLyxrLCYa','uhvIBgLZAca','r0vu','lZPVCMDHBMK','revmrvrf'];_0x4974=function(){return _0xf39134;};return _0x4974();}import{CreateProductCategorySchema as _0x3e389d,ErrorSchema as _0x94373f,HeaderSchema as _0x52184d,LocalizedProductCategorySchema as _0x238b4b,OrganizationParams as _0x1ed241,OrganizationWithIdParams as _0x1553b0,PaginationMetaSchema as _0x4841f3,PaginationQuerySchema as _0x395bd0,ProductCategorySchema as _0xd73030,UpdateProductCategorySchema as _0x2d3731}from'../../schemas';import{GetResourceQuerySchema as _0x33a838}from'../../schemas/queries.schema';const m=_0x395bd0['extend']({'publishedStatus':_0x162fae[_0x192872(0x13d)](['publishe'+'d',_0x4befd9(0xe3)+_0x192872(0x12a)])['optional']()[_0x4befd9(0x13f)]({'description':_0x4befd9(0x129)+_0x192872(0xe7)+_0x192872(0xef)+_0x4befd9(0xfd)+_0x4befd9(0x115)+_0x192872(0x143),'example':_0x192872(0xe0)+'d'})})[_0x192872(0x13f)](_0x4befd9(0x109)+'ctCatego'+_0x4befd9(0x139)+'y'),h=_0x67b171({'description':_0x4befd9(0xf8)+_0x4befd9(0x102)+_0x4befd9(0x140)+_0x4befd9(0x118)+_0x192872(0x11e)+_0x192872(0x10e)+_0x4befd9(0xe4)+'cific\x20or'+'ganizati'+'on','headers':_0x52184d,'method':_0x4befd9(0x124),'operationId':_0x192872(0x113)+_0x192872(0x106)+_0x192872(0x116),'path':_0x192872(0x125)+_0x4befd9(0xe9)+_0x192872(0x131)+_0x4befd9(0x13e)+_0x192872(0x117),'pathParams':_0x1ed241,'query':m,'responses':{0xc8:_0x162fae[_0x192872(0x132)]({'list':_0x162fae[_0x4befd9(0xf9)](_0x162fae[_0x4befd9(0xfb)]([_0xd73030,_0x238b4b])),'meta':_0x4841f3}),0x190:_0x94373f,0x191:_0x94373f},'summary':_0x4befd9(0x13c)+'uct\x20Cate'+_0x192872(0x11c),'tags':[_0x192872(0xdf)+_0x4befd9(0x141)]}),y=_0x67b171({'body':_0x3e389d,'description':_0x192872(0x122)+_0x192872(0xeb)+_0x192872(0x138)+_0x4befd9(0x101)+_0x4befd9(0xe4)+_0x192872(0xf7)+_0x4befd9(0x133)+'on','headers':_0x52184d,'method':_0x4befd9(0xfc),'operationId':_0x4befd9(0x10d)+_0x4befd9(0x121)+'egory','path':_0x4befd9(0x125)+_0x4befd9(0xe9)+'/product'+_0x192872(0x13e)+_0x4befd9(0x117),'pathParams':_0x1ed241,'responses':{0xc9:_0xd73030,0x190:_0x94373f,0x191:_0x94373f,0x194:_0x94373f},'summary':_0x192872(0x112)+'roduct\x20C'+_0x4befd9(0x141),'tags':[_0x4befd9(0xdf)+'ategory']}),P=_0x67b171({'description':_0x192872(0xf8)+_0x192872(0x136)+'ic\x20produ'+_0x4befd9(0x12f)+_0x192872(0xf1)+'D','headers':_0x52184d,'method':_0x192872(0x124),'operationId':_0x4befd9(0x113)+'ctCatego'+'ry','path':'/:organi'+_0x4befd9(0xe9)+'/product'+_0x192872(0x13e)+_0x192872(0x111),'pathParams':_0x1553b0,'query':_0x33a838,'responses':{0xc8:_0x162fae[_0x192872(0xfb)]([_0xd73030,_0x238b4b]),0x191:_0x94373f,0x194:_0x94373f},'summary':_0x4befd9(0x13c)+'uct\x20Cate'+_0x4befd9(0x137),'tags':[_0x4befd9(0xdf)+_0x192872(0x141)]}),C=_0x67b171({'body':_0x2d3731,'description':_0x192872(0x12b)+_0x4befd9(0x136)+_0x4befd9(0x105)+_0x4befd9(0x12f)+_0x4befd9(0xf1)+'D','headers':_0x52184d,'method':'PATCH','operationId':_0x4befd9(0x103)+_0x4befd9(0x121)+_0x4befd9(0x10c),'path':_0x192872(0x125)+'zationId'+_0x192872(0x131)+_0x192872(0x13e)+_0x192872(0x111),'pathParams':_0x1553b0,'responses':{0xc8:_0xd73030,0x190:_0x94373f,0x191:_0x94373f,0x194:_0x94373f},'summary':_0x4befd9(0xed)+'roduct\x20C'+_0x192872(0x141),'tags':['ProductC'+_0x192872(0x141)]}),l=_0x67b171({'description':_0x192872(0x110)+_0x192872(0x108)+_0x192872(0x119)+_0x192872(0x13b)+_0x4befd9(0x12c)+_0x192872(0x10f)+_0x192872(0x107)+'y\x20based\x20'+'on\x20the\x20o'+_0x4befd9(0xe6)+'\x20(publis'+_0x192872(0x12d)+_0x4befd9(0x104),'headers':_0x52184d,'method':_0x192872(0xfc),'operationId':_0x192872(0x103)+'oductCat'+_0x192872(0xff)+_0x192872(0xe1),'path':_0x4befd9(0x125)+_0x4befd9(0xe9)+_0x4befd9(0x131)+_0x4befd9(0x13e)+'ies/:id/'+_0x192872(0xf2)+_0x192872(0xf5)+'n','pathParams':_0x162fae[_0x4befd9(0x132)]({'id':_0x162fae[_0x192872(0x11a)]()[_0x192872(0x13f)]({'description':_0x192872(0xe5)+_0x192872(0x135)+_0x192872(0x11b),'example':_0x4befd9(0x130)+_0x192872(0xfe)+_0x4befd9(0xfa)+'m','param':{'in':_0x4befd9(0x128),'name':'id'}}),'operation':_0x162fae['enum']([_0x4befd9(0x13a),_0x4befd9(0xe3)+'h'])[_0x4befd9(0x13f)]({'description':_0x4befd9(0x12e)+_0x4befd9(0xec)+_0x192872(0xea)+_0x192872(0x114)+_0x4befd9(0x10b)+_0x4befd9(0xe2),'example':_0x4befd9(0x13a),'param':{'in':_0x192872(0x128),'name':_0x192872(0xf5)+'n'}}),'organizationId':_0x162fae['string']()[_0x4befd9(0x13f)]({'description':_0x192872(0xe5)+_0x192872(0x135)+_0x4befd9(0x11b),'example':_0x192872(0x130)+_0x192872(0xfe)+'p5w6fzny'+'m','param':{'in':_0x4befd9(0x128),'name':_0x192872(0xf6)+'tionId'}})}),'responses':{0xc8:_0xd73030,0x190:_0x94373f,0x191:_0x94373f,0x194:_0x94373f},'summary':_0x4befd9(0x123)+'or\x20Unpub'+_0x4befd9(0xe8)+'duct\x20Cat'+_0x4befd9(0x10c),'tags':[_0x4befd9(0xdf)+_0x4befd9(0x141)]}),b=_0x67b171({'description':_0x4befd9(0x134)+_0x4befd9(0x136)+_0x192872(0x105)+_0x4befd9(0x12f)+_0x192872(0xf1)+'D','headers':_0x52184d,'method':_0x192872(0x126),'operationId':'deletePr'+_0x4befd9(0x121)+'egory','path':_0x4befd9(0x125)+_0x192872(0xe9)+_0x4befd9(0x131)+_0x4befd9(0x13e)+_0x4befd9(0x111),'pathParams':_0x1553b0,'responses':{0xcc:null,0x190:_0x94373f,0x191:_0x94373f,0x194:_0x94373f},'summary':_0x192872(0x11d)+_0x192872(0xf4)+_0x4befd9(0x141),'tags':[_0x192872(0xdf)+_0x4befd9(0x141)]});function _0x1ddf(_0x261df9,_0x4bbe6a){_0x261df9=_0x261df9-0xde;const _0x497406=_0x4974();let _0x1ddf44=_0x497406[_0x261df9];if(_0x1ddf['MVGIJz']===undefined){var _0x185cb6=function(_0xb505e2){const _0x1dd541='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x162fae='',_0x67b171='';for(let _0x3e389d=0x0,_0x94373f,_0x52184d,_0x238b4b=0x0;_0x52184d=_0xb505e2['charAt'](_0x238b4b++);~_0x52184d&&(_0x94373f=_0x3e389d%0x4?_0x94373f*0x40+_0x52184d:_0x52184d,_0x3e389d++%0x4)?_0x162fae+=String['fromCharCode'](0xff&_0x94373f>>(-0x2*_0x3e389d&0x6)):0x0){_0x52184d=_0x1dd541['indexOf'](_0x52184d);}for(let _0x1ed241=0x0,_0x1553b0=_0x162fae['length'];_0x1ed241<_0x1553b0;_0x1ed241++){_0x67b171+='%'+('00'+_0x162fae['charCodeAt'](_0x1ed241)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x67b171);};_0x1ddf['uWVVTw']=_0x185cb6,_0x1ddf['vyxfKA']={},_0x1ddf['MVGIJz']=!![];}const _0x4120f8=_0x497406[0x0],_0x291a1a=_0x261df9+_0x4120f8,_0x56efd1=_0x1ddf['vyxfKA'][_0x291a1a];return!_0x56efd1?(_0x1ddf44=_0x1ddf['uWVVTw'](_0x1ddf44),_0x1ddf['vyxfKA'][_0x291a1a]=_0x1ddf44):_0x1ddf44=_0x56efd1,_0x1ddf44;}export const productCategoryRoute={'getProductCategories':h,'createProductCategory':y,'getProductCategory':P,'updateProductCategory':C,'updateProductCategoryStatus':l,'deleteProductCategory':b};
1
+ import{z as e}from"@hono/zod-openapi";import{createApiRoute as o}from"../../core/hono/hono";import{CreateProductCategorySchema as s,ErrorSchema as t,HeaderSchema as a,LocalizedProductCategorySchema as d,OrganizationParams as c,OrganizationWithIdParams as i,PaginationMetaSchema as p,PaginationQuerySchema as u,ProductCategorySchema as r,UpdateProductCategorySchema as n}from"../../schemas";import{GetResourceQuerySchema as g}from"../../schemas/queries.schema";const m=u.extend({publishedStatus:e.enum(["published","unpublished"]).optional().openapi({description:"Filter product categories by publication status",example:"published"})}).openapi("GetProductCategoriesQuery"),h=o({description:"Fetches a paginated list of product categories for a specific organization",headers:a,method:"GET",operationId:"getProductCategories",path:"/:organizationId/product-categories",pathParams:c,query:m,responses:{200:e.object({list:e.array(e.union([r,d])),meta:p}),400:t,401:t},summary:"Get Product Categories",tags:["ProductCategory"]}),y=o({body:s,description:"Creates a new product category for a specific organization",headers:a,method:"POST",operationId:"createProductCategory",path:"/:organizationId/product-categories",pathParams:c,responses:{201:r,400:t,401:t,404:t},summary:"Create Product Category",tags:["ProductCategory"]}),P=o({description:"Fetches a specific product category by ID",headers:a,method:"GET",operationId:"getProductCategory",path:"/:organizationId/product-categories/:id",pathParams:i,query:g,responses:{200:e.union([r,d]),401:t,404:t},summary:"Get Product Category",tags:["ProductCategory"]}),C=o({body:n,description:"Updates a specific product category by ID",headers:a,method:"PATCH",operationId:"updateProductCategory",path:"/:organizationId/product-categories/:id",pathParams:i,responses:{200:r,400:t,401:t,404:t},summary:"Update Product Category",tags:["ProductCategory"]}),l=o({description:"Sets the published status of an existing product category based on the operation (publish or unpublish)",headers:a,method:"POST",operationId:"updateProductCategoryStatus",path:"/:organizationId/product-categories/:id/status/:operation",pathParams:e.object({id:e.string().openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"id"}}),operation:e.enum(["publish","unpublish"]).openapi({description:"The operation to perform on the product category",example:"publish",param:{in:"path",name:"operation"}}),organizationId:e.string().openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"organizationId"}})}),responses:{200:r,400:t,401:t,404:t},summary:"Publish or Unpublish Product Category",tags:["ProductCategory"]}),b=o({description:"Deletes a specific product category by ID",headers:a,method:"DELETE",operationId:"deleteProductCategory",path:"/:organizationId/product-categories/:id",pathParams:i,responses:{204:null,400:t,401:t,404:t},summary:"Delete Product Category",tags:["ProductCategory"]});export const productCategoryRoute={getProductCategories:h,createProductCategory:y,getProductCategory:P,updateProductCategory:C,updateProductCategoryStatus:l,deleteProductCategory:b};
@@ -1 +1 @@
1
- const _0x2eccdc=_0x58d4,_0x35529a=_0x58d4;(function(_0x140799,_0x40ce1b){const _0x4bd730=_0x58d4,_0xd30f5e=_0x58d4,_0x329186=_0x140799();while(!![]){try{const _0x15b77c=parseInt(_0x4bd730(0x150))/0x1*(-parseInt(_0xd30f5e(0x14d))/0x2)+parseInt(_0xd30f5e(0x124))/0x3+parseInt(_0x4bd730(0x161))/0x4+-parseInt(_0x4bd730(0x155))/0x5*(parseInt(_0x4bd730(0x141))/0x6)+parseInt(_0xd30f5e(0x16a))/0x7*(-parseInt(_0x4bd730(0x14b))/0x8)+parseInt(_0xd30f5e(0x157))/0x9+parseInt(_0x4bd730(0x13b))/0xa;if(_0x15b77c===_0x40ce1b)break;else _0x329186['push'](_0x329186['shift']());}catch(_0x4a2d79){_0x329186['push'](_0x329186['shift']());}}}(_0x2e14,0x5ecb6));import{z as _0x53dcf7}from'@hono/zod-openapi';function _0x58d4(_0xbda32d,_0x28c30d){_0xbda32d=_0xbda32d-0x123;const _0x2e1468=_0x2e14();let _0x58d431=_0x2e1468[_0xbda32d];if(_0x58d4['TXisdy']===undefined){var _0x56b025=function(_0x44f9fe){const _0x4954d3='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x53dcf7='',_0x24aeb8='';for(let _0x2f0e49=0x0,_0x1e8db7,_0x12a4a4,_0x3e08eb=0x0;_0x12a4a4=_0x44f9fe['charAt'](_0x3e08eb++);~_0x12a4a4&&(_0x1e8db7=_0x2f0e49%0x4?_0x1e8db7*0x40+_0x12a4a4:_0x12a4a4,_0x2f0e49++%0x4)?_0x53dcf7+=String['fromCharCode'](0xff&_0x1e8db7>>(-0x2*_0x2f0e49&0x6)):0x0){_0x12a4a4=_0x4954d3['indexOf'](_0x12a4a4);}for(let _0x44339c=0x0,_0xffe3f8=_0x53dcf7['length'];_0x44339c<_0xffe3f8;_0x44339c++){_0x24aeb8+='%'+('00'+_0x53dcf7['charCodeAt'](_0x44339c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x24aeb8);};_0x58d4['hcLcnN']=_0x56b025,_0x58d4['yJHOyU']={},_0x58d4['TXisdy']=!![];}const _0x465fc3=_0x2e1468[0x0],_0x204b50=_0xbda32d+_0x465fc3,_0x53fc81=_0x58d4['yJHOyU'][_0x204b50];return!_0x53fc81?(_0x58d431=_0x58d4['hcLcnN'](_0x58d431),_0x58d4['yJHOyU'][_0x204b50]=_0x58d431):_0x58d431=_0x53fc81,_0x58d431;}import{validateRequiredForDefaultLocale as _0x24aeb8}from'../../core/utils/zod.util';function _0x2e14(){const _0x54a47b=['AxmGnJaWma','tg9JywXLigK','zhvJDcbJyxq','BwLU','ihrOzsbWCM8','DhjHBNnSyxq','B2jQzwn0','Dwn0ignHDgu','y2XMotG3nJu','mtmZnJqWneTeB1Dtzq','BguGzM9Yihq','q3jLyxrLuhi','BNvSBgfIBgu','zwDVCNK','B2rLigzVCIa','z29YEq','C2XHDgLVBG','vgHLigrLzMe','n3ztt3beqW','zM9YihrOzsa','Aw9Uig9Mihq','zw4Tvvm','B3j5','AwzPzwqGBg8','Bg9JywXLigK','suqGB2yGDgG','Bwf4','zsbPBwfNzsa','q2f0zwDVCNK','twf4Aw11Bsa','uhjVzhvJDem','zsbWCM9KDwm','nZaWotG2yu1dC0fH','u2X1zYbVzIa','DgHLihrYyw4','vxbKyxrLuhi','y3qGy2f0zwC','BgvJDhjVBMK','zgvMyxvSDa','DgHLihbYB2q','zMLLzcbSB2m','vgLTzxn0yw0','tg9JywXPEMu','CIbSAw1PDca','B3b0Aw9UywW','CYbYzxf1Axi','DwX0igXVy2e','yxrLz29YEq','y2HHCMfJDgu','y2f0zwDVCNK','DgHLihnWzwm','DgL0Bgu','rgvMyxvSDca','ndmYmtbHyMm','Ccb3AgvUihq','odK1ndq0me13EwrbCq','ChvIBgLZAgu','tg9JywXLigm','ywXL','rwXLy3rYB24','C3rYAw5N','mtu0ody4nhneue51rG','B3bLBMfWAq','y2fSzq','B2r1y3rdyxq','AwnZ','qsbJyxrLz28','tMfTzsbVzIa','AguGC3bLy2K','zgf0zq','CgLJAW','mJeXmZm2mgfsEKLqrG','CgfYDgLHBa','ntrYsNPJChG','B3j5ihDHCYa','y3vPza','mtC1mJfVyKHmzKu','C3vWzxjszwy','ChjVzhvJDca','zxH0zw5K','AguGChjVzhu','mtbzvg5WBNO','rgvZy3jPChq','mtyWnJGYngjdDNHKtq'];_0x2e14=function(){return _0x54a47b;};return _0x2e14();}import{FileSchema as _0x2f0e49}from'../file/file.schema';export const ProductCategorySchema=_0x53dcf7[_0x2eccdc(0x15e)]({'id':_0x53dcf7[_0x35529a(0x140)]()[_0x35529a(0x142)]({'example':_0x2eccdc(0x160)+_0x35529a(0x139)+'def','description':_0x2eccdc(0x171)+_0x35529a(0x123)+'t\x20catego'+'ry'}),'slug':_0x53dcf7[_0x2eccdc(0x140)]()['openapi']({'example':'electron'+_0x2eccdc(0x145),'description':_0x2eccdc(0x125)+_0x2eccdc(0x12b)+_0x35529a(0x15f)+_0x35529a(0x167)}),'image':_0x2f0e49[_0x2eccdc(0x164)]()[_0x2eccdc(0x130)]()[_0x2eccdc(0x142)]({'description':'Image\x20of'+_0x35529a(0x15c)+_0x35529a(0x15a)+_0x2eccdc(0x165)}),'createdAt':_0x53dcf7[_0x2eccdc(0x149)](),'publishedAt':_0x53dcf7[_0x2eccdc(0x149)]()[_0x35529a(0x164)]()[_0x35529a(0x130)]()[_0x2eccdc(0x142)]({'description':_0x35529a(0x12d)+_0x2eccdc(0x13a)+'he\x20produ'+_0x2eccdc(0x128)+_0x35529a(0x14e)+_0x35529a(0x13c)+'d'}),'translations':_0x53dcf7['array'](_0x53dcf7['object']({'locale':_0x53dcf7[_0x35529a(0x140)]()[_0x2eccdc(0x15b)](0x1,_0x35529a(0x159)+_0x35529a(0x131)+'ed')['openapi']({'example':_0x2eccdc(0x16d),'description':_0x35529a(0x13d)+_0x2eccdc(0x166)+_0x2eccdc(0x126)+_0x35529a(0x168)}),'title':_0x53dcf7[_0x35529a(0x140)]()[_0x2eccdc(0x12a)]('')[_0x35529a(0x142)]({'example':_0x2eccdc(0x13f)+_0x35529a(0x145),'description':_0x2eccdc(0x147)+_0x35529a(0x12b)+'uct\x20cate'+'gory\x20in\x20'+_0x2eccdc(0x136)+_0x2eccdc(0x16f)+_0x2eccdc(0x143)}),'description':_0x53dcf7[_0x2eccdc(0x140)]()[_0x2eccdc(0x172)](0x1770,_0x2eccdc(0x175)+_0x35529a(0x134)+_0x2eccdc(0x12f)+_0x2eccdc(0x158))[_0x2eccdc(0x164)]()[_0x35529a(0x12a)]('')[_0x35529a(0x130)]()[_0x35529a(0x142)]({'example':_0x2eccdc(0x146)+'ry\x20for\x20e'+_0x2eccdc(0x129)+'c\x20device'+'s.','description':_0x2eccdc(0x156)+_0x35529a(0x16c)+'he\x20produ'+_0x2eccdc(0x128)+'ory\x20in\x20t'+_0x35529a(0x148)+_0x2eccdc(0x12c)+_0x2eccdc(0x13e)})}))[_0x2eccdc(0x142)]({'description':'List\x20of\x20'+_0x2eccdc(0x15d)+'ions\x20for'+_0x2eccdc(0x15c)+_0x35529a(0x15a)+_0x2eccdc(0x165)})})[_0x2eccdc(0x142)](_0x2eccdc(0x176)+_0x2eccdc(0x133)),LocalizedProductCategorySchema=ProductCategorySchema['omit']({'translations':!0x0})[_0x35529a(0x153)]({'title':_0x53dcf7['string']()[_0x2eccdc(0x12a)](''),'description':_0x53dcf7[_0x35529a(0x140)]()[_0x35529a(0x12a)]('')})[_0x2eccdc(0x142)](_0x2eccdc(0x12e)+'dProduct'+_0x2eccdc(0x174)),CreateProductCategorySchema=ProductCategorySchema[_0x35529a(0x14a)]({'slug':!0x0,'image':!0x0,'translations':!0x0})[_0x2eccdc(0x153)]({'defaultLocale':_0x53dcf7[_0x35529a(0x140)]()['min'](0x1,_0x35529a(0x138)+_0x2eccdc(0x170)+_0x2eccdc(0x131)+'ed')[_0x2eccdc(0x142)]({'description':_0x35529a(0x169)+_0x2eccdc(0x132)+_0x2eccdc(0x162)+_0x35529a(0x154)+_0x2eccdc(0x128)+'ory'}),'imageId':_0x53dcf7['string']()[_0x35529a(0x14f)]()[_0x35529a(0x130)]()['openapi']({'description':_0x35529a(0x171)+_0x2eccdc(0x173)+_0x35529a(0x16b)+'product\x20'+'category'})})[_0x2eccdc(0x151)+'ine'](_0x24aeb8(_0x35529a(0x137)))[_0x35529a(0x142)](_0x35529a(0x163)+_0x2eccdc(0x144)+'egory'),UpdateProductCategorySchema=ProductCategorySchema[_0x2eccdc(0x14a)]({'slug':!0x0,'image':!0x0,'translations':!0x0})['extend']({'defaultLocale':_0x53dcf7[_0x35529a(0x140)]()[_0x2eccdc(0x15b)](0x1,_0x35529a(0x138)+'locale\x20i'+'s\x20requir'+'ed')[_0x2eccdc(0x142)]({'description':_0x35529a(0x169)+_0x2eccdc(0x132)+_0x35529a(0x162)+_0x2eccdc(0x154)+_0x35529a(0x128)+_0x35529a(0x16e)}),'imageId':_0x53dcf7[_0x2eccdc(0x140)]()['cuid']()[_0x2eccdc(0x130)]()['nullable']()[_0x35529a(0x142)]({'description':'ID\x20of\x20th'+_0x35529a(0x173)+'for\x20the\x20'+_0x2eccdc(0x152)+_0x2eccdc(0x135)})})[_0x35529a(0x14c)]()[_0x35529a(0x151)+'ine'](_0x24aeb8(_0x35529a(0x137)))[_0x35529a(0x142)](_0x35529a(0x127)+'oductCat'+_0x2eccdc(0x165));
1
+ import{z as e}from"@hono/zod-openapi";import{validateRequiredForDefaultLocale as t}from"../../core/utils/zod.util";import{FileSchema as o}from"../file/file.schema";export const ProductCategorySchema=e.object({id:e.string().openapi({example:"clf9876543210abcdef",description:"ID of the product category"}),slug:e.string().openapi({example:"electronics",description:"Slug of the product category"}),image:o.nullable().optional().openapi({description:"Image of the product category"}),createdAt:e.date(),publishedAt:e.date().nullable().optional().openapi({description:"Timestamp when the product category was published"}),translations:e.array(e.object({locale:e.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),title:e.string().default("").openapi({example:"Electronics",description:"Name of the product category in the specified locale"}),description:e.string().max(6e3,"Maximum character limit is 6000").nullable().default("").optional().openapi({example:"A category for electronic devices.",description:"Description of the product category in the specified locale"})})).openapi({description:"List of translations for the product category"})}).openapi("ProductCategory"),LocalizedProductCategorySchema=ProductCategorySchema.omit({translations:!0}).extend({title:e.string().default(""),description:e.string().default("")}).openapi("LocalizedProductCategory"),CreateProductCategorySchema=ProductCategorySchema.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:e.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:e.string().cuid().optional().openapi({description:"ID of the image for the product category"})}).superRefine(t("title")).openapi("CreateProductCategory"),UpdateProductCategorySchema=ProductCategorySchema.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:e.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:e.string().cuid().optional().nullable().openapi({description:"ID of the image for the product category"})}).partial().superRefine(t("title")).openapi("UpdateProductCategory");
@@ -1 +1 @@
1
- const _0x46c3ec=_0x4f1c,_0xb962ee=_0x4f1c;(function(_0x7f3227,_0x2c5a4d){const _0x3d7b91=_0x4f1c,_0x18929b=_0x4f1c,_0x5253e4=_0x7f3227();while(!![]){try{const _0x4e080e=-parseInt(_0x3d7b91(0x1d6))/0x1*(parseInt(_0x18929b(0x1e0))/0x2)+parseInt(_0x18929b(0x1cf))/0x3*(parseInt(_0x3d7b91(0x1d8))/0x4)+-parseInt(_0x3d7b91(0x1bd))/0x5+-parseInt(_0x3d7b91(0x1c9))/0x6*(parseInt(_0x18929b(0x1ce))/0x7)+-parseInt(_0x3d7b91(0x1d7))/0x8+-parseInt(_0x3d7b91(0x1d3))/0x9*(-parseInt(_0x3d7b91(0x1c0))/0xa)+-parseInt(_0x18929b(0x1d2))/0xb*(-parseInt(_0x3d7b91(0x1d5))/0xc);if(_0x4e080e===_0x2c5a4d)break;else _0x5253e4['push'](_0x5253e4['shift']());}catch(_0x119377){_0x5253e4['push'](_0x5253e4['shift']());}}}(_0x1904,0x89675));import{__awaiter as _0x398f3e}from'tslib';function _0x4f1c(_0x1af1a8,_0x275d09){_0x1af1a8=_0x1af1a8-0x1b6;const _0x19046c=_0x1904();let _0x4f1caa=_0x19046c[_0x1af1a8];if(_0x4f1c['LsZIIV']===undefined){var _0x2dec5e=function(_0x19f40c){const _0x1e9c26='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2dc391='',_0x4f32a1='';for(let _0x4e53f5=0x0,_0x78557b,_0x5d7e34,_0xc65c13=0x0;_0x5d7e34=_0x19f40c['charAt'](_0xc65c13++);~_0x5d7e34&&(_0x78557b=_0x4e53f5%0x4?_0x78557b*0x40+_0x5d7e34:_0x5d7e34,_0x4e53f5++%0x4)?_0x2dc391+=String['fromCharCode'](0xff&_0x78557b>>(-0x2*_0x4e53f5&0x6)):0x0){_0x5d7e34=_0x1e9c26['indexOf'](_0x5d7e34);}for(let _0x3e0070=0x0,_0x49b3fc=_0x2dc391['length'];_0x3e0070<_0x49b3fc;_0x3e0070++){_0x4f32a1+='%'+('00'+_0x2dc391['charCodeAt'](_0x3e0070)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4f32a1);};_0x4f1c['ioXTlp']=_0x2dec5e,_0x4f1c['YmhIyv']={},_0x4f1c['LsZIIV']=!![];}const _0x370583=_0x19046c[0x0],_0x30f02f=_0x1af1a8+_0x370583,_0x2919ed=_0x4f1c['YmhIyv'][_0x30f02f];return!_0x2919ed?(_0x4f1caa=_0x4f1c['ioXTlp'](_0x4f1caa),_0x4f1c['YmhIyv'][_0x30f02f]=_0x4f1caa):_0x4f1caa=_0x2919ed,_0x4f1caa;}import{z as _0x38d59b}from'@hono/zod-openapi';import{HttpException as _0x5afc8c}from'../../core/exceptions/http-exception';import{flattenTranslationData as _0x784c5d}from'../../core/utils/zod.util';import{LocalizedProductCategorySchema as _0x50c3ef,PaginationMetaSchema as _0x2c3d9c,ProductCategorySchema as _0x2f6d76}from'../../schemas';class P{constructor(_0x140248){const _0x14dd88=_0x4f1c;this[_0x14dd88(0x1e2)]=_0x140248;}[_0x46c3ec(0x1bc)+_0xb962ee(0x1b9)+'ory'](_0x21f257,_0x3418a8,_0x403e3e){const _0x60e379=_0xb962ee,_0x12fd07={'JPigm':'Product\x20'+_0x60e379(0x1e3)+'\x20not\x20fou'+'nd','XGYTR':function(_0x49490e,_0x49445c,_0x3d4c0d,_0x20a10,_0x1901a5){return _0x49490e(_0x49445c,_0x3d4c0d,_0x20a10,_0x1901a5);}};return _0x12fd07['XGYTR'](_0x398f3e,this,void 0x0,void 0x0,function*(){const _0x9bcf83=_0x60e379,_0x45e748=_0x60e379,_0x3f5ce0=yield this[_0x9bcf83(0x1e2)][_0x9bcf83(0x1de)+_0x45e748(0x1c7)]['findUniq'+'ue']({'where':{'id':_0x21f257,'organizationId':_0x3418a8,'deletedAt':null},'include':_0x403e3e?.[_0x45e748(0x1df)]});if(!_0x3f5ce0)throw new _0x5afc8c(0x194,_0x12fd07[_0x45e748(0x1c6)]);return _0x3f5ce0;});}[_0xb962ee(0x1d9)+'oductCat'+'egory'](_0x2b9284,_0x38663e,_0x1ed697){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x48f97b=_0x4f1c,_0x149888=_0x4f1c,_0x190bb3=yield this[_0x48f97b(0x1e2)][_0x48f97b(0x1de)+_0x149888(0x1c7)][_0x149888(0x1be)]({'data':{'slug':_0x1ed697[_0x48f97b(0x1c3)],'organizationId':_0x2b9284,'createdBy':_0x38663e,'imageId':_0x1ed697['imageId'],'translations':{'create':_0x1ed697[_0x149888(0x1c8)+_0x149888(0x1d1)]}},'include':{'translations':!0x0,'image':!0x0}});return _0x2f6d76[_0x149888(0x1e1)](_0x190bb3);});}[_0xb962ee(0x1db)+_0x46c3ec(0x1b8)+'ry'](_0x30c22a,_0x343050,_0x330a17){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x500cd4=_0x4f1c,_0x19c477=_0x4f1c,{locale:_0x5bf6d4}=_0x330a17,_0x2ffa94=yield this['findProd'+_0x500cd4(0x1b9)+_0x19c477(0x1da)](_0x343050,_0x30c22a,{'include':{'image':!0x0,'translations':_0x5bf6d4?{'where':{'locale':_0x5bf6d4}}:!0x0}});return _0x5bf6d4?_0x50c3ef[_0x19c477(0x1e1)](_0x784c5d(_0x2ffa94)):_0x2f6d76[_0x500cd4(0x1e1)](_0x2ffa94);});}[_0x46c3ec(0x1db)+_0xb962ee(0x1b8)+_0x46c3ec(0x1ba)](_0x5372d3,_0x4e0acf){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x11c5ec=_0x4f1c,_0x278d74=_0x4f1c,{page:_0x40cf45=0x1,limit:_0x9b1fec=0xa,search:_0x3876e1,locale:_0x5f0a18,published:_0x6eacbf,publishedStatus:_0x583dfc}=_0x4e0acf,_0x2a5e8b=_0x6eacbf||_0x583dfc===_0x11c5ec(0x1d4)+'d'?{'publishedAt':{'not':null}}:_0x583dfc===_0x11c5ec(0x1d0)+_0x278d74(0x1b7)?{'publishedAt':null}:void 0x0,[_0x2090e8,_0x4f6863]=yield this['prisma'][_0x11c5ec(0x1de)+_0x278d74(0x1c7)][_0x11c5ec(0x1bf)]({'orderBy':{'priority':_0x11c5ec(0x1cd)},'where':Object['assign'](Object[_0x278d74(0x1cb)]({'organizationId':_0x5372d3,'deletedAt':null},_0x3876e1&&{'slug':{'contains':_0x3876e1,'mode':_0x11c5ec(0x1dc)+_0x278d74(0x1c5)}}),_0x2a5e8b??{}),'include':{'image':!0x0,'translations':_0x5f0a18?{'where':{'locale':_0x5f0a18}}:!0x0}})['withPage'+'s']({'page':_0x40cf45,'limit':_0x9b1fec});if(!_0x5f0a18)return _0x38d59b[_0x11c5ec(0x1e6)]({'meta':_0x2c3d9c,'list':_0x38d59b['array'](_0x2f6d76)})[_0x11c5ec(0x1e1)]({'meta':_0x4f6863,'list':_0x2090e8});const _0x59a874=_0x2090e8[_0x278d74(0x1c1)](_0x159fe2=>_0x784c5d(_0x159fe2));return _0x38d59b[_0x278d74(0x1e6)]({'meta':_0x2c3d9c,'list':_0x38d59b[_0x11c5ec(0x1c2)](_0x50c3ef)})['parse']({'meta':_0x4f6863,'list':_0x59a874});});}['updatePr'+_0x46c3ec(0x1dd)+_0x46c3ec(0x1e4)](_0x1acf20,_0x53e034,_0x319b5d,_0x50c52a){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x1d1d5c=_0x4f1c,_0x616ede=_0x4f1c;yield this[_0x1d1d5c(0x1bc)+_0x1d1d5c(0x1b9)+'ory'](_0x53e034,_0x1acf20);const _0x466d1d=yield this['prisma'][_0x616ede(0x1de)+'ategory']['update']({'where':{'id':_0x53e034,'organizationId':_0x1acf20,'deletedAt':null},'data':{'updatedBy':_0x319b5d,'slug':_0x50c52a['slug'],'translations':{'deleteMany':{},'create':_0x50c52a[_0x1d1d5c(0x1c8)+_0x1d1d5c(0x1d1)]||[]},'imageId':_0x50c52a[_0x616ede(0x1b6)]},'include':{'image':!0x0,'translations':!0x0}});return _0x2f6d76[_0x616ede(0x1e1)](_0x466d1d);});}[_0xb962ee(0x1e7)+'oductCat'+_0xb962ee(0x1c4)+_0xb962ee(0x1e5)](_0x3524de,_0x16613d,_0x716f3b,_0x2e0d4e){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x310a61=_0x4f1c,_0x24ba74=_0x4f1c;yield this[_0x310a61(0x1bc)+_0x310a61(0x1b9)+_0x24ba74(0x1da)](_0x16613d,_0x3524de);const _0x3f9db9=yield this['prisma'][_0x310a61(0x1de)+_0x24ba74(0x1c7)][_0x24ba74(0x1ca)]({'where':{'id':_0x16613d,'organizationId':_0x3524de,'deletedAt':null},'data':{'publishedAt':_0x716f3b===_0x24ba74(0x1bb)?new Date():null,'publishedBy':_0x716f3b===_0x24ba74(0x1bb)?_0x2e0d4e:null,'updatedBy':_0x2e0d4e},'include':{'image':!0x0,'translations':!0x0}});return _0x2f6d76[_0x24ba74(0x1e1)](_0x3f9db9);});}[_0xb962ee(0x1cc)+_0x46c3ec(0x1dd)+_0xb962ee(0x1e4)](_0x1d4561,_0x2038b0,_0x806846){return _0x398f3e(this,void 0x0,void 0x0,function*(){const _0x554a0e=_0x4f1c,_0x65a4ce=_0x4f1c;yield this[_0x554a0e(0x1bc)+_0x554a0e(0x1b9)+'ory'](_0x2038b0,_0x1d4561),yield this[_0x65a4ce(0x1e2)][_0x65a4ce(0x1de)+'ategory'][_0x554a0e(0x1ca)]({'where':{'id':_0x2038b0,'organizationId':_0x1d4561,'deletedAt':null},'data':{'deletedAt':new Date(),'deletedBy':_0x806846}});});}}function _0x1904(){const _0x30dc5b=['ChjPC21H','y2f0zwDVCNK','zwDVCNK','DhvZ','B2jQzwn0','DxbKyxrLuhi','Aw1Hz2vjza','AgvK','y3rdyxrLz28','Dwn0q2f0zwC','CMLLCW','ChvIBgLZAa','zMLUzfbYB2q','mZiYnZu0nwLXwgTqCG','y3jLyxrL','CgfNAw5HDgu','mtbMtgv5Cha','BwfW','yxjYyxK','C2X1zW','zwDVCNLtDge','AxzL','sLbPz20','yxrLz29YEq','DhjHBNnSyxq','mJa3mZm2D1vKDw1P','DxbKyxrL','yxnZAwDU','zgvSzxrLuhi','yxnJ','ntz4we9srKi','m3rhswjlvq','Dw5WDwjSAxm','Aw9UCW','otLAyNbTAe4','mte2odi5oxPuDenvAa','ChvIBgLZAgu','mJCYmZG5mNvZq3LivG','mJm2nZG5B1LozfnP','ndC0oty3mM1vr2LWAa','mtuXnZi3nNDgBfrutW','y3jLyxrLuhi','B3j5','z2v0uhjVzhu','Aw5Zzw5ZAxq','B2r1y3rdyxq','ChjVzhvJDem','Aw5JBhvKzq','ng5WzeDtCa','CgfYC2u'];_0x1904=function(){return _0x30dc5b;};return _0x1904();}export{P as ProductCategoryService};
1
+ import{__awaiter as o}from"tslib";import{z as u}from"@hono/zod-openapi";import{HttpException as v}from"../../core/exceptions/http-exception";import{flattenTranslationData as g}from"../../core/utils/zod.util";import{LocalizedProductCategorySchema as h,PaginationMetaSchema as y,ProductCategorySchema as d}from"../../schemas";class P{constructor(t){this.prisma=t}findProductCategory(t,i,e){return o(this,void 0,void 0,function*(){const r=yield this.prisma.productCategory.findUnique({where:{id:t,organizationId:i,deletedAt:null},include:e?.include});if(!r)throw new v(404,"Product category not found");return r})}createProductCategory(t,i,e){return o(this,void 0,void 0,function*(){const r=yield this.prisma.productCategory.create({data:{slug:e.slug,organizationId:t,createdBy:i,imageId:e.imageId,translations:{create:e.translations}},include:{translations:!0,image:!0}});return d.parse(r)})}getProductCategory(t,i,e){return o(this,void 0,void 0,function*(){const{locale:r}=e,a=yield this.findProductCategory(i,t,{include:{image:!0,translations:r?{where:{locale:r}}:!0}});return r?h.parse(g(a)):d.parse(a)})}getProductCategories(t,i){return o(this,void 0,void 0,function*(){const{page:e=1,limit:r=10,search:a,locale:n,published:m,publishedStatus:l}=i,s=m||l==="published"?{publishedAt:{not:null}}:l==="unpublished"?{publishedAt:null}:void 0,[c,p]=yield this.prisma.productCategory.paginate({orderBy:{priority:"asc"},where:Object.assign(Object.assign({organizationId:t,deletedAt:null},a&&{slug:{contains:a,mode:"insensitive"}}),s??{}),include:{image:!0,translations:n?{where:{locale:n}}:!0}}).withPages({page:e,limit:r});if(!n)return u.object({meta:y,list:u.array(d)}).parse({meta:p,list:c});const C=c.map(f=>g(f));return u.object({meta:y,list:u.array(h)}).parse({meta:p,list:C})})}updateProductCategory(t,i,e,r){return o(this,void 0,void 0,function*(){yield this.findProductCategory(i,t);const a=yield this.prisma.productCategory.update({where:{id:i,organizationId:t,deletedAt:null},data:{updatedBy:e,slug:r.slug,translations:{deleteMany:{},create:r.translations||[]},imageId:r.imageId},include:{image:!0,translations:!0}});return d.parse(a)})}updateProductCategoryStatus(t,i,e,r){return o(this,void 0,void 0,function*(){yield this.findProductCategory(i,t);const a=yield this.prisma.productCategory.update({where:{id:i,organizationId:t,deletedAt:null},data:{publishedAt:e==="publish"?new Date:null,publishedBy:e==="publish"?r:null,updatedBy:r},include:{image:!0,translations:!0}});return d.parse(a)})}deleteProductCategory(t,i,e){return o(this,void 0,void 0,function*(){yield this.findProductCategory(i,t),yield this.prisma.productCategory.update({where:{id:i,organizationId:t,deletedAt:null},data:{deletedAt:new Date,deletedBy:e}})})}}export{P as ProductCategoryService};