@lyxa.ai/marketing 1.0.16 → 1.0.18

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 (143) hide show
  1. package/dist/lib/index.d.ts +52 -0
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/modules/coupon/services/coupon.service.d.ts +2 -1
  4. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  5. package/dist/lib/modules/coupon/services/coupon.service.js +39 -67
  6. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  7. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  8. package/dist/lib/modules/coupon/services/custom-coupon.service.js +5 -4
  9. package/dist/lib/modules/coupon/services/custom-coupon.service.js.map +1 -1
  10. package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  11. package/dist/lib/modules/coupon/services/global-coupon.service.js +5 -4
  12. package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
  13. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  14. package/dist/lib/modules/coupon/services/individual-store-coupon.service.js +5 -4
  15. package/dist/lib/modules/coupon/services/individual-store-coupon.service.js.map +1 -1
  16. package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  17. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +5 -4
  18. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
  19. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +0 -1
  20. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
  21. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +12 -22
  22. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
  23. package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
  24. package/dist/lib/modules/coupon/services/referral-code-coupon.service.js +5 -4
  25. package/dist/lib/modules/coupon/services/referral-code-coupon.service.js.map +1 -1
  26. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  27. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +5 -4
  28. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
  29. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  30. package/dist/lib/modules/marketing/services/marketing.service.js +0 -1
  31. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  32. package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts.map +1 -1
  33. package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.js +11 -4
  34. package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.js.map +1 -1
  35. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +52 -0
  36. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
  37. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.js +7 -1
  38. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.js.map +1 -1
  39. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  40. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +16 -22
  41. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
  42. package/dist/types/index.d.ts +52 -0
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/modules/coupon/services/coupon.service.d.ts +2 -1
  45. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  46. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  47. package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  48. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  49. package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  50. package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts +0 -1
  51. package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
  52. package/dist/types/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
  53. package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  54. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  55. package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts.map +1 -1
  56. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +52 -0
  57. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
  58. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  59. package/package.json +2 -2
  60. package/dist/lib/modules/loyalty-point-setting/routers/index.d.ts +0 -2
  61. package/dist/lib/modules/loyalty-point-setting/routers/index.d.ts.map +0 -1
  62. package/dist/lib/modules/loyalty-point-setting/routers/index.js +0 -18
  63. package/dist/lib/modules/loyalty-point-setting/routers/index.js.map +0 -1
  64. package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts +0 -321
  65. package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts.map +0 -1
  66. package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.js +0 -82
  67. package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.js.map +0 -1
  68. package/dist/lib/modules/loyalty-point-setting/services/index.d.ts +0 -3
  69. package/dist/lib/modules/loyalty-point-setting/services/index.d.ts.map +0 -1
  70. package/dist/lib/modules/loyalty-point-setting/services/index.js +0 -19
  71. package/dist/lib/modules/loyalty-point-setting/services/index.js.map +0 -1
  72. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts +0 -16
  73. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts.map +0 -1
  74. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.js +0 -133
  75. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.js.map +0 -1
  76. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts +0 -16
  77. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts.map +0 -1
  78. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.js +0 -156
  79. package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.js.map +0 -1
  80. package/dist/lib/modules/loyalty-point-setting/transformers/index.d.ts +0 -3
  81. package/dist/lib/modules/loyalty-point-setting/transformers/index.d.ts.map +0 -1
  82. package/dist/lib/modules/loyalty-point-setting/transformers/index.js +0 -19
  83. package/dist/lib/modules/loyalty-point-setting/transformers/index.js.map +0 -1
  84. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts +0 -8
  85. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts.map +0 -1
  86. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.js +0 -7
  87. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.js.map +0 -1
  88. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts +0 -9
  89. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts.map +0 -1
  90. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.js +0 -7
  91. package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.js.map +0 -1
  92. package/dist/lib/modules/loyalty-point-setting/validations/index.d.ts +0 -3
  93. package/dist/lib/modules/loyalty-point-setting/validations/index.d.ts.map +0 -1
  94. package/dist/lib/modules/loyalty-point-setting/validations/index.js +0 -19
  95. package/dist/lib/modules/loyalty-point-setting/validations/index.js.map +0 -1
  96. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts +0 -170
  97. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts.map +0 -1
  98. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.js +0 -19
  99. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.js.map +0 -1
  100. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts +0 -188
  101. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts.map +0 -1
  102. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.js +0 -19
  103. package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.js.map +0 -1
  104. package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.d.ts +0 -12
  105. package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.d.ts.map +0 -1
  106. package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.js +0 -149
  107. package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.js.map +0 -1
  108. package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts +0 -47
  109. package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts.map +0 -1
  110. package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.js +0 -7
  111. package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.js.map +0 -1
  112. package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.d.ts +0 -504
  113. package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.d.ts.map +0 -1
  114. package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.js +0 -34
  115. package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.js.map +0 -1
  116. package/dist/types/modules/loyalty-point-setting/routers/index.d.ts +0 -2
  117. package/dist/types/modules/loyalty-point-setting/routers/index.d.ts.map +0 -1
  118. package/dist/types/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts +0 -321
  119. package/dist/types/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts.map +0 -1
  120. package/dist/types/modules/loyalty-point-setting/services/index.d.ts +0 -3
  121. package/dist/types/modules/loyalty-point-setting/services/index.d.ts.map +0 -1
  122. package/dist/types/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts +0 -37
  123. package/dist/types/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts.map +0 -1
  124. package/dist/types/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts +0 -34
  125. package/dist/types/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts.map +0 -1
  126. package/dist/types/modules/loyalty-point-setting/transformers/index.d.ts +0 -3
  127. package/dist/types/modules/loyalty-point-setting/transformers/index.d.ts.map +0 -1
  128. package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts +0 -8
  129. package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts.map +0 -1
  130. package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts +0 -9
  131. package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts.map +0 -1
  132. package/dist/types/modules/loyalty-point-setting/validations/index.d.ts +0 -3
  133. package/dist/types/modules/loyalty-point-setting/validations/index.d.ts.map +0 -1
  134. package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts +0 -179
  135. package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts.map +0 -1
  136. package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts +0 -197
  137. package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts.map +0 -1
  138. package/dist/types/modules/marketing/services/loyalty-point-marketing.service.d.ts +0 -21
  139. package/dist/types/modules/marketing/services/loyalty-point-marketing.service.d.ts.map +0 -1
  140. package/dist/types/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts +0 -47
  141. package/dist/types/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts.map +0 -1
  142. package/dist/types/modules/marketing/validations/loyalty-point-marketing.validation.d.ts +0 -513
  143. package/dist/types/modules/marketing/validations/loyalty-point-marketing.validation.d.ts.map +0 -1
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loyaltyPointSettingRouter = void 0;
4
- const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
- const services_1 = require("../../loyalty-point-setting/services");
6
- const validations_1 = require("../../loyalty-point-setting/validations");
7
- const transformers_1 = require("../../loyalty-point-setting/transformers");
8
- const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
9
- const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
10
- const response_1 = require("@lyxa.ai/core/dist/utilities/response");
11
- const auth_1 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
12
- const auth_2 = require("@lyxa.ai/core/dist/libraries/auth");
13
- exports.loyaltyPointSettingRouter = (0, trpc_1.createTRPCRouter)({
14
- create: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
15
- .input(validations_1.LoyaltyPointSettingValidationSchema)
16
- .output(validations_1.LoyaltyPointSettingResponseSchema)
17
- .mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
18
- await services_1.loyaltyPointSettingService.create(input, ctx.entity?.id);
19
- return (0, response_1.response)('Loyalty point settings created successfully');
20
- })),
21
- get: trpc_1.publicProcedure
22
- .input(validation_1.FilterSchema)
23
- .output(validations_1.LoyaltyPointSettingResponseSchema)
24
- .query(async () => error_handler_1.ErrorHandler.wrapAsync(async () => {
25
- const result = await services_1.loyaltyPointSettingService.find();
26
- const transformedResult = transformers_1.loyaltyPointSettingTransformer.transformToBasicView(result);
27
- return (0, response_1.response)('Loyalty point settings fetched successfully', transformedResult);
28
- })),
29
- update: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
30
- .input(validations_1.UpdateLoyaltyPointSettingSchema)
31
- .output(validations_1.LoyaltyPointSettingResponseSchema)
32
- .mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
33
- const { _id, ...rest } = input;
34
- await services_1.loyaltyPointSettingService.update(String(_id), rest, ctx.entity?.id);
35
- return (0, response_1.response)('Loyalty point settings updated successfully');
36
- })),
37
- deleteById: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
38
- .input(validation_1.DeleteSchema)
39
- .output(validations_1.LoyaltyPointSettingResponseSchema)
40
- .mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
41
- await services_1.loyaltyPointSettingService.deleteById(input, ctx.entity?.id);
42
- return (0, response_1.response)('Loyalty point settings deleted successfully');
43
- })),
44
- createCategory: trpc_1.publicProcedure
45
- .input(validations_1.LoyaltyPointCategoryValidationSchema)
46
- .output(validations_1.LoyaltyPointCategoryResponseSchema)
47
- .mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
48
- await services_1.loyaltyPointCategoryService.create(input);
49
- return (0, response_1.response)('Loyalty point category created successfully');
50
- })),
51
- getCategoryById: trpc_1.publicProcedure
52
- .input(validation_1.IdSchema)
53
- .output(validations_1.LoyaltyPointCategoryResponseSchema)
54
- .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
55
- const result = await services_1.loyaltyPointCategoryService.findById(input);
56
- const transformedResult = transformers_1.loyaltyPointCategoryTransformer.transformToBasicView(result);
57
- return (0, response_1.response)('Loyalty point category fetched successfully', transformedResult);
58
- })),
59
- getCategories: trpc_1.publicProcedure
60
- .input(validation_1.FilterSchema)
61
- .output(validations_1.LoyaltyPointCategoryResponseSchema)
62
- .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
63
- const result = await services_1.loyaltyPointCategoryService.find(input);
64
- return (0, response_1.response)('Loyalty point categories fetched successfully', result);
65
- })),
66
- updateCategory: trpc_1.publicProcedure
67
- .input(validations_1.UpdateLoyaltyPointCategorySchema)
68
- .output(validations_1.LoyaltyPointCategoryResponseSchema)
69
- .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
70
- const { _id, ...rest } = input;
71
- await services_1.loyaltyPointCategoryService.update(String(_id), rest);
72
- return (0, response_1.response)('Loyalty point category updated successfully');
73
- })),
74
- deleteCategoryById: trpc_1.publicProcedure
75
- .input(validation_1.DeleteSchema)
76
- .output(validations_1.LoyaltyPointCategoryResponseSchema)
77
- .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
78
- await services_1.loyaltyPointCategoryService.deleteById(input);
79
- return (0, response_1.response)('Loyalty point category deleted successfully');
80
- })),
81
- });
82
- //# sourceMappingURL=loyalty-point-setting.router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-setting.router.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/routers/loyalty-point-setting.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,sEAGiD;AACjD,4EAOoD;AACpD,8EAGqD;AACrD,wEAA+F;AAC/F,8EAA0E;AAC1E,oEAAiE;AACjE,6EAAkG;AAClG,4DAAmE;AAEtD,QAAA,yBAAyB,GAAG,IAAA,uBAAgB,EAAC;IACzD,MAAM,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SACzE,KAAK,CAAC,iDAAY,CAAC;SACnB,MAAM,CAAC,+CAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,qCAAO,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5C,OAAO,IAAA,mBAAQ,EAAC,6CAA6C,CAAC,CAAC;IAChE,CAAC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,CAAC,CAAC;QACjD,OAAO,IAAA,mBAAQ,EAAC,+CAA+C,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC,CAAC,CACF;IAEF,cAAc,EAAE,sBAAe;SAC7B,KAAK,CAAC,8CAAoB,CAAC;SAC3B,MAAM,CAAC,gDAAsB,CAAC;SAC9B,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAC/B,MAAM,sCAAe,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,OAAO,IAAA,mBAAQ,EAAC,6CAA6C,CAAC,CAAC;IAChE,CAAC,CAAC,CACF;IAEF,kBAAkB,EAAE,sBAAe;SACjC,KAAK,CAAC,yBAAY,CAAC;SACnB,MAAM,CAAC,gDAAsB,CAAC;SAC9B,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,sCAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAA,mBAAQ,EAAC,6CAA6C,CAAC,CAAC;IAChE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport {\n\tloyaltyPointSettingService as service,\n\tloyaltyPointCategoryService as categoryService,\n} from '@modules/loyalty-point-setting/services';\nimport {\n\tLoyaltyPointSettingValidationSchema as CreateSchema,\n\tUpdateLoyaltyPointSettingSchema as UpdateSchema,\n\tLoyaltyPointSettingResponseSchema as ResponseSchema,\n\tLoyaltyPointCategoryValidationSchema as CreateCategorySchema,\n\tUpdateLoyaltyPointCategorySchema as UpdateCategorySchema,\n\tLoyaltyPointCategoryResponseSchema as CategoryResponseSchema,\n} from '@modules/loyalty-point-setting/validations';\nimport {\n\tloyaltyPointSettingTransformer as transformer,\n\tloyaltyPointCategoryTransformer as categoryTransformer,\n} from '@modules/loyalty-point-setting/transformers';\nimport { FilterSchema, DeleteSchema, IdSchema } from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\n\nexport const loyaltyPointSettingRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(CreateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.create(input, ctx.entity?.id);\n\t\t\t\treturn response('Loyalty point settings created successfully');\n\t\t\t})\n\t\t),\n\n\tget: publicProcedure\n\t\t.input(FilterSchema)\n\t\t.output(ResponseSchema)\n\t\t.query(async () =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.find();\n\t\t\t\tconst transformedResult = transformer.transformToBasicView(result);\n\t\t\t\treturn response('Loyalty point settings fetched successfully', transformedResult);\n\t\t\t})\n\t\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tawait service.update(String(_id), rest, ctx.entity?.id);\n\t\t\t\treturn response('Loyalty point settings updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.deleteById(input, ctx.entity?.id);\n\t\t\t\treturn response('Loyalty point settings deleted successfully');\n\t\t\t})\n\t\t),\n\n\tcreateCategory: publicProcedure\n\t\t.input(CreateCategorySchema)\n\t\t.output(CategoryResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait categoryService.create(input);\n\t\t\t\treturn response('Loyalty point category created successfully');\n\t\t\t})\n\t\t),\n\n\tgetCategoryById: publicProcedure\n\t\t.input(IdSchema)\n\t\t.output(CategoryResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await categoryService.findById(input);\n\t\t\t\tconst transformedResult = categoryTransformer.transformToBasicView(result);\n\t\t\t\treturn response('Loyalty point category fetched successfully', transformedResult);\n\t\t\t})\n\t\t),\n\n\tgetCategories: publicProcedure\n\t\t.input(FilterSchema)\n\t\t.output(CategoryResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await categoryService.find(input);\n\t\t\t\treturn response('Loyalty point categories fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tupdateCategory: publicProcedure\n\t\t.input(UpdateCategorySchema)\n\t\t.output(CategoryResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tawait categoryService.update(String(_id), rest);\n\t\t\t\treturn response('Loyalty point category updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteCategoryById: publicProcedure\n\t\t.input(DeleteSchema)\n\t\t.output(CategoryResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait categoryService.deleteById(input);\n\t\t\t\treturn response('Loyalty point category deleted successfully');\n\t\t\t})\n\t\t),\n});\n"]}
@@ -1,3 +0,0 @@
1
- export * from './loyalty-point-setting.service';
2
- export * from './loyalty-point-category.service';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./loyalty-point-setting.service"), exports);
18
- __exportStar(require("./loyalty-point-category.service"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C;AAC/C,mEAAgD","sourcesContent":["export * from './loyalty-point-setting.service'\nexport * from './loyalty-point-category.service'"]}
@@ -1,16 +0,0 @@
1
- import { DocumentType, mongoose } from '@typegoose/typegoose';
2
- import { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';
3
- import { ModelType } from '@typegoose/typegoose/lib/types';
4
- import { LoyaltyPointCategory as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
5
- import { CreateLoyaltyPointCategoryDTO as CreateDTO, UpdateLoyaltyPointCategoryDTO as UpdateDTO } from '../../loyalty-point-setting/validations';
6
- export declare class LoyaltyPointCategoryService {
7
- private model;
8
- constructor();
9
- create(data: CreateDTO): Promise<DocumentType<Model>>;
10
- findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
11
- find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>>;
12
- update(id: string, data: UpdateDTO): Promise<DocumentType<Model>>;
13
- deleteById(data: DeleteDTO): Promise<string>;
14
- }
15
- export declare const loyaltyPointCategoryService: LoyaltyPointCategoryService;
16
- //# sourceMappingURL=loyalty-point-category.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-category.service.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/services/loyalty-point-category.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,oBAAoB,IAAI,KAAK,EAC7B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,6BAA6B,IAAI,SAAS,EAC1C,6BAA6B,IAAI,SAAS,EAC1C,MAAM,4CAA4C,CAAC;AAGpD,qBACa,2BAA2B;IACvC,OAAO,CAAC,KAAK,CAA4D;;IAU5D,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAerD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAiB5E,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IA0B3F,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IA2BjE,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAazD;AAED,eAAO,MAAM,2BAA2B,6BAA6C,CAAC"}
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __metadata = (this && this.__metadata) || function (k, v) {
42
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.loyaltyPointCategoryService = exports.LoyaltyPointCategoryService = void 0;
46
- const typedi_1 = __importStar(require("typedi"));
47
- const server_1 = require("@trpc/server");
48
- const pagination_1 = require("@lyxa.ai/core/dist/utilities/pagination");
49
- const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
50
- let LoyaltyPointCategoryService = class LoyaltyPointCategoryService {
51
- model;
52
- constructor() {
53
- this.model = models_1.LoyaltyPointCategoryModel;
54
- }
55
- async create(data) {
56
- try {
57
- return await this.model.create(data);
58
- }
59
- catch (err) {
60
- throw new server_1.TRPCError({
61
- code: 'INTERNAL_SERVER_ERROR',
62
- message: `err: ${err}`,
63
- });
64
- }
65
- }
66
- async findById(id) {
67
- const result = await this.model.findOne({
68
- _id: id,
69
- });
70
- if (!result) {
71
- throw new server_1.TRPCError({
72
- code: 'NOT_FOUND',
73
- message: 'Record not found',
74
- });
75
- }
76
- return result;
77
- }
78
- async find(data) {
79
- try {
80
- const paginate = (0, pagination_1.createRawDocumentPaginatorObject)(this.model);
81
- const options = {
82
- page: data?.page,
83
- size: data?.size,
84
- sort: data?.sort,
85
- query: data?.query,
86
- select: data?.select,
87
- populate: data?.populate,
88
- };
89
- const paginatedResult = await paginate(options);
90
- return paginatedResult;
91
- }
92
- catch (err) {
93
- throw new server_1.TRPCError({
94
- code: 'INTERNAL_SERVER_ERROR',
95
- message: `err: ${err}`,
96
- });
97
- }
98
- }
99
- async update(id, data) {
100
- const record = await this.model.findOneAndUpdate({
101
- _id: id,
102
- deletedAt: null,
103
- }, data, {
104
- new: true,
105
- runValidators: true,
106
- });
107
- if (!record) {
108
- throw new server_1.TRPCError({
109
- code: 'NOT_FOUND',
110
- message: `Record not found`,
111
- });
112
- }
113
- return record;
114
- }
115
- async deleteById(data) {
116
- const { _id, softDelete } = data;
117
- const result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);
118
- if (!result) {
119
- throw new server_1.TRPCError({
120
- code: 'NOT_FOUND',
121
- message: 'Record not found',
122
- });
123
- }
124
- return 'Record deleted successfully';
125
- }
126
- };
127
- exports.LoyaltyPointCategoryService = LoyaltyPointCategoryService;
128
- exports.LoyaltyPointCategoryService = LoyaltyPointCategoryService = __decorate([
129
- (0, typedi_1.Service)(),
130
- __metadata("design:paramtypes", [])
131
- ], LoyaltyPointCategoryService);
132
- exports.loyaltyPointCategoryService = typedi_1.default.get(LoyaltyPointCategoryService);
133
- //# sourceMappingURL=loyalty-point-category.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-category.service.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/services/loyalty-point-category.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAGzC,wEAA6G;AAE7G,sEAGmD;AAQ5C,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAC/B,KAAK,CAA4D;IAEzE;QACC,IAAI,CAAC,KAAK,GAAG,kCAAsF,CAAC;IACrG,CAAC;IAMM,KAAK,CAAC,MAAM,CAAC,IAAe;QAClC,IAAI,CAAC;YACJ,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAC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BAAgB,CAC/C;YACC,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,IAAI;SACf,EACD,IAAI,EACJ;YACC,GAAG,EAAE,IAAI;YACT,aAAa,EAAE,IAAI;SACnB,CACD,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,kBAAS,CAAC;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,kBAAkB;aAC3B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAMM,KAAK,CAAC,UAAU,CAAC,IAAe;QACtC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;QACnF,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,kBAAS,CAAC;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,kBAAkB;aAC3B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,6BAA6B,CAAC;IACtC,CAAC;CACD,CAAA;AA7GY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CA6GvC;AAEY,QAAA,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tLoyaltyPointCategoryModel,\n\tLoyaltyPointCategory as Model,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreateLoyaltyPointCategoryDTO as CreateDTO,\n\tUpdateLoyaltyPointCategoryDTO as UpdateDTO,\n} from '@modules/loyalty-point-setting/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\n\n@Service()\nexport class LoyaltyPointCategoryService {\n\tprivate model: typeof LoyaltyPointCategoryModel & SoftDeleteModel<Model>;\n\n\tconstructor() {\n\t\tthis.model = LoyaltyPointCategoryModel as typeof LoyaltyPointCategoryModel & SoftDeleteModel<Model>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\ttry {\n\t\t\treturn await this.model.create(data);\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(id: string, data: UpdateDTO): Promise<DocumentType<Model>> {\n\t\tconst record = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: id,\n\t\t\t\tdeletedAt: null,\n\t\t\t},\n\t\t\tdata,\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn record;\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\treturn 'Record deleted successfully';\n\t}\n}\n\nexport const loyaltyPointCategoryService = Container.get(LoyaltyPointCategoryService);\n"]}
@@ -1,16 +0,0 @@
1
- import { DocumentType } from '@typegoose/typegoose';
2
- import { DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';
3
- import { LoyaltyPointSetting as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
4
- import { CreateLoyaltyPointSettingDTO as CreateDTO, UpdateLoyaltyPointSettingDTO as UpdateDTO } from '../../loyalty-point-setting/validations';
5
- export declare class LoyaltyPointSettingService {
6
- private model;
7
- private categoryModel;
8
- constructor();
9
- create(data: CreateDTO, admin?: string): Promise<DocumentType<Model>>;
10
- find(): Promise<DocumentType<Model>>;
11
- update(id: string, data: UpdateDTO, admin?: string): Promise<DocumentType<Model>>;
12
- private logMarketingSettingAdminAction;
13
- deleteById(data: DeleteDTO, admin?: string): Promise<string>;
14
- }
15
- export declare const loyaltyPointSettingService: LoyaltyPointSettingService;
16
- //# sourceMappingURL=loyalty-point-setting.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-setting.service.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/services/loyalty-point-setting.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA6B,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAgC,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGlG,OAAO,EAEN,mBAAmB,IAAI,KAAK,EAG5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,4BAA4B,IAAI,SAAS,EACzC,4BAA4B,IAAI,SAAS,EAGzC,MAAM,4CAA4C,CAAC;AAOpD,qBACa,0BAA0B;IACtC,OAAO,CAAC,KAAK,CAA2D;IACxE,OAAO,CAAC,aAAa,CAAoE;;IAY5E,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IA+BrE,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAiBpC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAsChF,8BAA8B;IAmB/B,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAoCzE;AAED,eAAO,MAAM,0BAA0B,4BAA4C,CAAC"}
@@ -1,156 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __metadata = (this && this.__metadata) || function (k, v) {
42
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.loyaltyPointSettingService = exports.LoyaltyPointSettingService = void 0;
46
- const typedi_1 = __importStar(require("typedi"));
47
- const server_1 = require("@trpc/server");
48
- const typegoose_1 = require("@typegoose/typegoose");
49
- const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
50
- const event_1 = require("@lyxa.ai/core/dist/libraries/event");
51
- const admin_logs_event_1 = require("@lyxa.ai/core/dist/libraries/event/events/admin-logs-event");
52
- const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
53
- let LoyaltyPointSettingService = class LoyaltyPointSettingService {
54
- model;
55
- categoryModel;
56
- constructor() {
57
- this.model = models_1.LoyaltyPointSettingModel;
58
- this.categoryModel = models_1.LoyaltyPointCategoryModel;
59
- }
60
- async create(data, admin) {
61
- if (!admin) {
62
- throw new server_1.TRPCError({
63
- code: 'NOT_FOUND',
64
- message: 'Admin not found',
65
- });
66
- }
67
- const exists = await this.model.exists({});
68
- if (exists) {
69
- throw new server_1.TRPCError({
70
- code: 'CONFLICT',
71
- message: `Loyalty point settings already exists. Please update the existing settings.`,
72
- });
73
- }
74
- const result = await this.model.create(data);
75
- this.logMarketingSettingAdminAction(new typegoose_1.mongoose.Types.ObjectId(admin), enum_1.AdminLogsUpdatedFieldsType.DELETED_MARKETING_SETTINGS, '', result);
76
- return result;
77
- }
78
- async find() {
79
- const result = await this.model.findOne();
80
- if (!result) {
81
- throw new server_1.TRPCError({
82
- code: 'NOT_FOUND',
83
- message: 'Record not found',
84
- });
85
- }
86
- return result;
87
- }
88
- async update(id, data, admin) {
89
- if (!admin) {
90
- throw new server_1.TRPCError({
91
- code: 'NOT_FOUND',
92
- message: `Admin not found`,
93
- });
94
- }
95
- const record = await this.model.findById(id);
96
- if (!record) {
97
- throw new server_1.TRPCError({
98
- code: 'NOT_FOUND',
99
- message: `Record not found`,
100
- });
101
- }
102
- const result = await this.model.findByIdAndUpdate(id, data, {
103
- new: true,
104
- runValidators: true,
105
- });
106
- if (!result) {
107
- throw new server_1.TRPCError({
108
- code: 'NOT_FOUND',
109
- message: `Record not found`,
110
- });
111
- }
112
- this.logMarketingSettingAdminAction(new typegoose_1.mongoose.Types.ObjectId(admin), enum_1.AdminLogsUpdatedFieldsType.CHANGE_IN_MARKETING_SETTINGS, record, result);
113
- return result;
114
- }
115
- async logMarketingSettingAdminAction(admin, actionType, oldDocument, newDocument) {
116
- const adminActivityLogsEvent = new admin_logs_event_1.AdminActivityLogsEvent({
117
- admin,
118
- updatedField: actionType,
119
- oldDocument: oldDocument ?? '',
120
- newDocument: newDocument ?? '',
121
- });
122
- await (0, event_1.publishEvent)(adminActivityLogsEvent);
123
- }
124
- async deleteById(data, admin) {
125
- const { _id, softDelete } = data;
126
- if (!admin) {
127
- throw new server_1.TRPCError({
128
- code: 'NOT_FOUND',
129
- message: 'Admin not found',
130
- });
131
- }
132
- const record = await this.model.findById(_id);
133
- if (!record) {
134
- throw new server_1.TRPCError({
135
- code: 'NOT_FOUND',
136
- message: 'Record not found',
137
- });
138
- }
139
- const result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);
140
- if (!result) {
141
- throw new server_1.TRPCError({
142
- code: 'INTERNAL_SERVER_ERROR',
143
- message: 'Unable to delete record',
144
- });
145
- }
146
- this.logMarketingSettingAdminAction(new typegoose_1.mongoose.Types.ObjectId(admin), enum_1.AdminLogsUpdatedFieldsType.DELETED_MARKETING_SETTINGS, record, result);
147
- return 'Record deleted successfully';
148
- }
149
- };
150
- exports.LoyaltyPointSettingService = LoyaltyPointSettingService;
151
- exports.LoyaltyPointSettingService = LoyaltyPointSettingService = __decorate([
152
- (0, typedi_1.Service)(),
153
- __metadata("design:paramtypes", [])
154
- ], LoyaltyPointSettingService);
155
- exports.loyaltyPointSettingService = typedi_1.default.get(LoyaltyPointSettingService);
156
- //# sourceMappingURL=loyalty-point-setting.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-setting.service.js","sourceRoot":"/","sources":["modules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CA2JtC;AAEY,QAAA,0BAA0B,GAAG,gBAAS,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tLoyaltyPointSettingModel,\n\tLoyaltyPointSetting as Model,\n\tLoyaltyPointCategoryModel,\n\tLoyaltyPointCategory as CategoryModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreateLoyaltyPointSettingDTO as CreateDTO,\n\tUpdateLoyaltyPointSettingDTO as UpdateDTO,\n\tCreateLoyaltyPointCategoryDTO as CreateCategoryDTO,\n\tUpdateLoyaltyPointCategoryDTO as UpdateCategoryDTO,\n} from '@modules/loyalty-point-setting/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { BaseEvent } from '@lyxa.ai/core/dist/libraries/event/BaseEvent';\nimport { AdminActivityLogsEvent } from '@lyxa.ai/core/dist/libraries/event/events/admin-logs-event';\nimport { AdminLogsUpdatedFieldsType } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class LoyaltyPointSettingService {\n\tprivate model: typeof LoyaltyPointSettingModel & SoftDeleteModel<Model>;\n\tprivate categoryModel: typeof LoyaltyPointCategoryModel & SoftDeleteModel<CategoryModel>;\n\n\tconstructor() {\n\t\tthis.model = LoyaltyPointSettingModel as typeof LoyaltyPointSettingModel & SoftDeleteModel<Model>;\n\t\tthis.categoryModel = LoyaltyPointCategoryModel as typeof LoyaltyPointCategoryModel &\n\t\t\tSoftDeleteModel<CategoryModel>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO, admin?: string): Promise<DocumentType<Model>> {\n\t\tif (!admin) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Admin not found',\n\t\t\t});\n\t\t}\n\n\t\tconst exists = await this.model.exists({});\n\t\tif (exists) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'CONFLICT',\n\t\t\t\tmessage: `Loyalty point settings already exists. Please update the existing settings.`,\n\t\t\t});\n\t\t}\n\t\tconst result = await this.model.create(data);\n\n\t\tthis.logMarketingSettingAdminAction(\n\t\t\tnew mongoose.Types.ObjectId(admin),\n\t\t\tAdminLogsUpdatedFieldsType.DELETED_MARKETING_SETTINGS,\n\t\t\t'',\n\t\t\tresult\n\t\t);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne();\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t * @param admin Admin id\n\t */\n\tpublic async update(id: string, data: UpdateDTO, admin?: string): Promise<DocumentType<Model>> {\n\t\tif (!admin) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Admin not found`,\n\t\t\t});\n\t\t}\n\n\t\tconst record = await this.model.findById(id);\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\tconst result = await this.model.findByIdAndUpdate(id, data, {\n\t\t\tnew: true,\n\t\t\trunValidators: true,\n\t\t});\n\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\tthis.logMarketingSettingAdminAction(\n\t\t\tnew mongoose.Types.ObjectId(admin),\n\t\t\tAdminLogsUpdatedFieldsType.CHANGE_IN_MARKETING_SETTINGS,\n\t\t\trecord,\n\t\t\tresult\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tprivate async logMarketingSettingAdminAction(\n\t\tadmin: mongoose.Types.ObjectId,\n\t\tactionType: AdminLogsUpdatedFieldsType,\n\t\toldDocument?: any,\n\t\tnewDocument?: any\n\t) {\n\t\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\t\tadmin,\n\t\t\tupdatedField: actionType,\n\t\t\toldDocument: oldDocument ?? '',\n\t\t\tnewDocument: newDocument ?? '',\n\t\t});\n\t\tawait publishEvent(adminActivityLogsEvent);\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO, admin?: string): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tif (!admin) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Admin not found',\n\t\t\t});\n\t\t}\n\n\t\tconst record = await this.model.findById(_id);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Unable to delete record',\n\t\t\t});\n\t\t}\n\n\t\tthis.logMarketingSettingAdminAction(\n\t\t\tnew mongoose.Types.ObjectId(admin),\n\t\t\tAdminLogsUpdatedFieldsType.DELETED_MARKETING_SETTINGS,\n\t\t\trecord,\n\t\t\tresult\n\t\t);\n\n\t\treturn 'Record deleted successfully';\n\t}\n}\n\nexport const loyaltyPointSettingService = Container.get(LoyaltyPointSettingService);\n"]}
@@ -1,3 +0,0 @@
1
- export * from './loyalty-point-setting.transformer';
2
- export * from './loyalty-point-category.transformer';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./loyalty-point-setting.transformer"), exports);
18
- __exportStar(require("./loyalty-point-category.transformer"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAmD;AACnD,uEAAoD","sourcesContent":["export * from './loyalty-point-setting.transformer'\nexport * from './loyalty-point-category.transformer'"]}
@@ -1,8 +0,0 @@
1
- import { LoyaltyPointCategory as Model } from '@lyxa.ai/core/dist/libraries/mongo/models/loyalty-point-category.model';
2
- export declare const loyaltyPointCategoryTransformer: import("@lyxa.ai/core/dist/utilities/transformers").GlobalTransformer<Model, import("zod").objectOutputType<{
3
- name: import("zod").ZodOptional<import("zod").ZodString | import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, string, string>>;
4
- status: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>;
5
- sortingOrder: import("zod").ZodOptional<import("zod").ZodNumber>;
6
- _id: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
7
- }, import("zod").ZodTypeAny, "passthrough">>;
8
- //# sourceMappingURL=loyalty-point-category.transformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-category.transformer.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,IAAI,KAAK,EAAE,MAAM,wEAAwE,CAAC;AAMvH,eAAO,MAAM,+BAA+B;;;;;4CAAwC,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loyaltyPointCategoryTransformer = void 0;
4
- const transformers_1 = require("@lyxa.ai/core/dist/utilities/transformers");
5
- const loyalty_point_category_validation_1 = require("../../loyalty-point-setting/validations/loyalty-point-category.validation");
6
- exports.loyaltyPointCategoryTransformer = (0, transformers_1.createTransformer)(loyalty_point_category_validation_1.LoyaltyPointCategorySchema);
7
- //# sourceMappingURL=loyalty-point-category.transformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-category.transformer.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.ts"],"names":[],"mappings":";;;AAAA,4EAA8E;AAE9E,oIAGsF;AAEzE,QAAA,+BAA+B,GAAG,IAAA,gCAAiB,EAAa,8DAAM,CAAC,CAAC","sourcesContent":["import { createTransformer } from '@lyxa.ai/core/dist/utilities/transformers';\nimport { LoyaltyPointCategory as Model } from '@lyxa.ai/core/dist/libraries/mongo/models/loyalty-point-category.model';\nimport {\n\tLoyaltyPointCategorySchema as Schema,\n\tLoyaltyPointCategoryDTO as DTO,\n} from '@modules/loyalty-point-setting/validations/loyalty-point-category.validation';\n\nexport const loyaltyPointCategoryTransformer = createTransformer<Model, DTO>(Schema);\n"]}
@@ -1,9 +0,0 @@
1
- import { LoyaltyPointSetting as Model } from '@lyxa.ai/core/dist/libraries/mongo/models/loyalty-point-setting.model';
2
- export declare const loyaltyPointSettingTransformer: import("@lyxa.ai/core/dist/utilities/transformers").GlobalTransformer<Model, import("zod").objectOutputType<{
3
- earnedValue: import("zod").ZodOptional<import("zod").ZodNumber>;
4
- usedValue: import("zod").ZodOptional<import("zod").ZodNumber>;
5
- rewardBundles: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNumber, "many">>;
6
- expirationInDays: import("zod").ZodOptional<import("zod").ZodNumber>;
7
- _id: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
8
- }, import("zod").ZodTypeAny, "passthrough">>;
9
- //# sourceMappingURL=loyalty-point-setting.transformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-setting.transformer.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,IAAI,KAAK,EAAE,MAAM,uEAAuE,CAAC;AAMrH,eAAO,MAAM,8BAA8B;;;;;;4CAAwC,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loyaltyPointSettingTransformer = void 0;
4
- const transformers_1 = require("@lyxa.ai/core/dist/utilities/transformers");
5
- const loyalty_point_setting_validation_1 = require("../../loyalty-point-setting/validations/loyalty-point-setting.validation");
6
- exports.loyaltyPointSettingTransformer = (0, transformers_1.createTransformer)(loyalty_point_setting_validation_1.LoyaltyPointSettingSchema);
7
- //# sourceMappingURL=loyalty-point-setting.transformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loyalty-point-setting.transformer.js","sourceRoot":"/","sources":["modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.ts"],"names":[],"mappings":";;;AAAA,4EAA8E;AAE9E,kIAGqF;AAExE,QAAA,8BAA8B,GAAG,IAAA,gCAAiB,EAAa,4DAAM,CAAC,CAAC","sourcesContent":["import { createTransformer } from '@lyxa.ai/core/dist/utilities/transformers';\nimport { LoyaltyPointSetting as Model } from '@lyxa.ai/core/dist/libraries/mongo/models/loyalty-point-setting.model';\nimport {\n\tLoyaltyPointSettingSchema as Schema,\n\tLoyaltyPointSettingDTO as DTO,\n} from '@modules/loyalty-point-setting/validations/loyalty-point-setting.validation';\n\nexport const loyaltyPointSettingTransformer = createTransformer<Model, DTO>(Schema);\n"]}
@@ -1,3 +0,0 @@
1
- export * from './loyalty-point-setting.validation';
2
- export * from './loyalty-point-category.validation';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/loyalty-point-setting/validations/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,qCAAqC,CAAA"}