@kshon/loyalty-plugin 2.14.2

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 (222) hide show
  1. package/.medusa/server/src/admin/index.js +69052 -0
  2. package/.medusa/server/src/admin/index.mjs +69034 -0
  3. package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.d.ts +2 -0
  4. package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.js +28 -0
  5. package/.medusa/server/src/api/admin/gift-cards/[id]/route.d.ts +4 -0
  6. package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +41 -0
  7. package/.medusa/server/src/api/admin/gift-cards/middlewares.d.ts +2 -0
  8. package/.medusa/server/src/api/admin/gift-cards/middlewares.js +46 -0
  9. package/.medusa/server/src/api/admin/gift-cards/query-config.d.ts +14 -0
  10. package/.medusa/server/src/api/admin/gift-cards/query-config.js +32 -0
  11. package/.medusa/server/src/api/admin/gift-cards/route.d.ts +4 -0
  12. package/.medusa/server/src/api/admin/gift-cards/route.js +42 -0
  13. package/.medusa/server/src/api/admin/gift-cards/validators.d.ts +139 -0
  14. package/.medusa/server/src/api/admin/gift-cards/validators.js +56 -0
  15. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.d.ts +3 -0
  16. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.js +30 -0
  17. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.d.ts +3 -0
  18. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +19 -0
  19. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.d.ts +3 -0
  20. package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +23 -0
  21. package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.d.ts +2 -0
  22. package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +46 -0
  23. package/.medusa/server/src/api/admin/store-credit-accounts/query-config.d.ts +18 -0
  24. package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +44 -0
  25. package/.medusa/server/src/api/admin/store-credit-accounts/route.d.ts +4 -0
  26. package/.medusa/server/src/api/admin/store-credit-accounts/route.js +52 -0
  27. package/.medusa/server/src/api/admin/store-credit-accounts/validators.d.ts +142 -0
  28. package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +45 -0
  29. package/.medusa/server/src/api/middlewares.d.ts +2 -0
  30. package/.medusa/server/src/api/middlewares.js +18 -0
  31. package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.d.ts +5 -0
  32. package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +43 -0
  33. package/.medusa/server/src/api/store/carts/[id]/store-credits/route.d.ts +4 -0
  34. package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +24 -0
  35. package/.medusa/server/src/api/store/carts/middlewares.d.ts +2 -0
  36. package/.medusa/server/src/api/store/carts/middlewares.js +35 -0
  37. package/.medusa/server/src/api/store/carts/query-config.d.ts +4 -0
  38. package/.medusa/server/src/api/store/carts/query-config.js +9 -0
  39. package/.medusa/server/src/api/store/carts/validators.d.ts +13 -0
  40. package/.medusa/server/src/api/store/carts/validators.js +14 -0
  41. package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.d.ts +3 -0
  42. package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.js +24 -0
  43. package/.medusa/server/src/api/store/gift-cards/middlewares.d.ts +2 -0
  44. package/.medusa/server/src/api/store/gift-cards/middlewares.js +16 -0
  45. package/.medusa/server/src/api/store/gift-cards/query-config.d.ts +9 -0
  46. package/.medusa/server/src/api/store/gift-cards/query-config.js +23 -0
  47. package/.medusa/server/src/api/store/gift-cards/validators.d.ts +7 -0
  48. package/.medusa/server/src/api/store/gift-cards/validators.js +8 -0
  49. package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.d.ts +3 -0
  50. package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +31 -0
  51. package/.medusa/server/src/api/store/store-credit-accounts/claim/route.d.ts +3 -0
  52. package/.medusa/server/src/api/store/store-credit-accounts/claim/route.js +25 -0
  53. package/.medusa/server/src/api/store/store-credit-accounts/middlewares.d.ts +2 -0
  54. package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +36 -0
  55. package/.medusa/server/src/api/store/store-credit-accounts/query-config.d.ts +9 -0
  56. package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +24 -0
  57. package/.medusa/server/src/api/store/store-credit-accounts/route.d.ts +3 -0
  58. package/.medusa/server/src/api/store/store-credit-accounts/route.js +40 -0
  59. package/.medusa/server/src/api/store/store-credit-accounts/validators.d.ts +44 -0
  60. package/.medusa/server/src/api/store/store-credit-accounts/validators.js +19 -0
  61. package/.medusa/server/src/links/cart-gift-cards-link.d.ts +2 -0
  62. package/.medusa/server/src/links/cart-gift-cards-link.js +13 -0
  63. package/.medusa/server/src/links/customer-store-credit-account-link.d.ts +1 -0
  64. package/.medusa/server/src/links/customer-store-credit-account-link.js +13 -0
  65. package/.medusa/server/src/links/gift-card-store-credit.d.ts +2 -0
  66. package/.medusa/server/src/links/gift-card-store-credit.js +10 -0
  67. package/.medusa/server/src/links/order-gift-cards-link.d.ts +2 -0
  68. package/.medusa/server/src/links/order-gift-cards-link.js +13 -0
  69. package/.medusa/server/src/links/order-line-item-gift-card-link.d.ts +1 -0
  70. package/.medusa/server/src/links/order-line-item-gift-card-link.js +19 -0
  71. package/.medusa/server/src/modules/loyalty/index.d.ts +21 -0
  72. package/.medusa/server/src/modules/loyalty/index.js +12 -0
  73. package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.d.ts +5 -0
  74. package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +17 -0
  75. package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.d.ts +5 -0
  76. package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +19 -0
  77. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.d.ts +5 -0
  78. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +19 -0
  79. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.d.ts +5 -0
  80. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +14 -0
  81. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.d.ts +5 -0
  82. package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +14 -0
  83. package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.d.ts +5 -0
  84. package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.js +16 -0
  85. package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.d.ts +5 -0
  86. package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.js +20 -0
  87. package/.medusa/server/src/modules/loyalty/models/gift-card.d.ts +18 -0
  88. package/.medusa/server/src/modules/loyalty/models/gift-card.js +18 -0
  89. package/.medusa/server/src/modules/loyalty/models/index.d.ts +1 -0
  90. package/.medusa/server/src/modules/loyalty/models/index.js +9 -0
  91. package/.medusa/server/src/modules/loyalty/service.d.ts +21 -0
  92. package/.medusa/server/src/modules/loyalty/service.js +13 -0
  93. package/.medusa/server/src/modules/store-credit/index.d.ts +5 -0
  94. package/.medusa/server/src/modules/store-credit/index.js +12 -0
  95. package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.d.ts +5 -0
  96. package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +16 -0
  97. package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.d.ts +5 -0
  98. package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +18 -0
  99. package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.d.ts +5 -0
  100. package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +19 -0
  101. package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.d.ts +5 -0
  102. package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +14 -0
  103. package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.d.ts +5 -0
  104. package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.js +16 -0
  105. package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.d.ts +5 -0
  106. package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.js +16 -0
  107. package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.d.ts +5 -0
  108. package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.js +27 -0
  109. package/.medusa/server/src/modules/store-credit/models/account-transaction.d.ts +28 -0
  110. package/.medusa/server/src/modules/store-credit/models/account-transaction.js +21 -0
  111. package/.medusa/server/src/modules/store-credit/models/index.d.ts +2 -0
  112. package/.medusa/server/src/modules/store-credit/models/index.js +11 -0
  113. package/.medusa/server/src/modules/store-credit/models/store-credit-account.d.ts +27 -0
  114. package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +27 -0
  115. package/.medusa/server/src/modules/store-credit/service.d.ts +29 -0
  116. package/.medusa/server/src/modules/store-credit/service.js +253 -0
  117. package/.medusa/server/src/subscribers/create-gift-card.d.ts +5 -0
  118. package/.medusa/server/src/subscribers/create-gift-card.js +53 -0
  119. package/.medusa/server/src/types/cart/index.d.ts +12 -0
  120. package/.medusa/server/src/types/cart/index.js +3 -0
  121. package/.medusa/server/src/types/http/gift-card.d.ts +42 -0
  122. package/.medusa/server/src/types/http/gift-card.js +3 -0
  123. package/.medusa/server/src/types/http/index.d.ts +3 -0
  124. package/.medusa/server/src/types/http/index.js +20 -0
  125. package/.medusa/server/src/types/http/store-credit-account.d.ts +60 -0
  126. package/.medusa/server/src/types/http/store-credit-account.js +3 -0
  127. package/.medusa/server/src/types/http/transaction.d.ts +19 -0
  128. package/.medusa/server/src/types/http/transaction.js +3 -0
  129. package/.medusa/server/src/types/index.d.ts +4 -0
  130. package/.medusa/server/src/types/index.js +21 -0
  131. package/.medusa/server/src/types/loyalty/index.d.ts +3 -0
  132. package/.medusa/server/src/types/loyalty/index.js +20 -0
  133. package/.medusa/server/src/types/loyalty/module.d.ts +151 -0
  134. package/.medusa/server/src/types/loyalty/module.js +12 -0
  135. package/.medusa/server/src/types/loyalty/service.d.ts +168 -0
  136. package/.medusa/server/src/types/loyalty/service.js +3 -0
  137. package/.medusa/server/src/types/loyalty/workflows.d.ts +3 -0
  138. package/.medusa/server/src/types/loyalty/workflows.js +3 -0
  139. package/.medusa/server/src/types/modules.d.ts +6 -0
  140. package/.medusa/server/src/types/modules.js +12 -0
  141. package/.medusa/server/src/types/store-credit/index.d.ts +2 -0
  142. package/.medusa/server/src/types/store-credit/index.js +19 -0
  143. package/.medusa/server/src/types/store-credit/module.d.ts +290 -0
  144. package/.medusa/server/src/types/store-credit/module.js +13 -0
  145. package/.medusa/server/src/types/store-credit/service.d.ts +325 -0
  146. package/.medusa/server/src/types/store-credit/service.js +3 -0
  147. package/.medusa/server/src/utils/code-generator.d.ts +1 -0
  148. package/.medusa/server/src/utils/code-generator.js +32 -0
  149. package/.medusa/server/src/workflows/carts/index.d.ts +5 -0
  150. package/.medusa/server/src/workflows/carts/index.js +22 -0
  151. package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.d.ts +37 -0
  152. package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.js +36 -0
  153. package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.d.ts +118 -0
  154. package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +179 -0
  155. package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.d.ts +88 -0
  156. package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +134 -0
  157. package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.d.ts +68 -0
  158. package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +110 -0
  159. package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.d.ts +30 -0
  160. package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +154 -0
  161. package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.d.ts +103 -0
  162. package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +124 -0
  163. package/.medusa/server/src/workflows/common/steps/validate-presence-of.d.ts +29 -0
  164. package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +22 -0
  165. package/.medusa/server/src/workflows/gift-cards/index.d.ts +9 -0
  166. package/.medusa/server/src/workflows/gift-cards/index.js +26 -0
  167. package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.d.ts +20 -0
  168. package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +38 -0
  169. package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.d.ts +17 -0
  170. package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +24 -0
  171. package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.d.ts +32 -0
  172. package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +34 -0
  173. package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.d.ts +19 -0
  174. package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +41 -0
  175. package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.d.ts +65 -0
  176. package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.js +101 -0
  177. package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.d.ts +36 -0
  178. package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +88 -0
  179. package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.d.ts +28 -0
  180. package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +34 -0
  181. package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.d.ts +60 -0
  182. package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +129 -0
  183. package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.d.ts +28 -0
  184. package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +31 -0
  185. package/.medusa/server/src/workflows/hooks/after-order-created.d.ts +1 -0
  186. package/.medusa/server/src/workflows/hooks/after-order-created.js +31 -0
  187. package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.d.ts +1 -0
  188. package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +32 -0
  189. package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.d.ts +1 -0
  190. package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +26 -0
  191. package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.d.ts +1 -0
  192. package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +27 -0
  193. package/.medusa/server/src/workflows/index.d.ts +3 -0
  194. package/.medusa/server/src/workflows/index.js +20 -0
  195. package/.medusa/server/src/workflows/orders/index.d.ts +2 -0
  196. package/.medusa/server/src/workflows/orders/index.js +19 -0
  197. package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.d.ts +34 -0
  198. package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +75 -0
  199. package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.d.ts +88 -0
  200. package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +131 -0
  201. package/.medusa/server/src/workflows/store-credit/index.d.ts +8 -0
  202. package/.medusa/server/src/workflows/store-credit/index.js +25 -0
  203. package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.d.ts +19 -0
  204. package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +37 -0
  205. package/.medusa/server/src/workflows/store-credit/steps/credit-account.d.ts +20 -0
  206. package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +31 -0
  207. package/.medusa/server/src/workflows/store-credit/steps/debit-account.d.ts +20 -0
  208. package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +31 -0
  209. package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.d.ts +91 -0
  210. package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.js +170 -0
  211. package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.d.ts +50 -0
  212. package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +50 -0
  213. package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.d.ts +29 -0
  214. package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +32 -0
  215. package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.d.ts +29 -0
  216. package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.js +67 -0
  217. package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.d.ts +29 -0
  218. package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +32 -0
  219. package/.medusa/server/tailwind.config.d.ts +3 -0
  220. package/.medusa/server/tailwind.config.js +12 -0
  221. package/README.md +62 -0
  222. package/package.json +107 -0
@@ -0,0 +1,325 @@
1
+ import { RestoreReturn } from "@medusajs/framework/types";
2
+ import { BaseFilterable, Context, FindConfig, IModuleService } from "@medusajs/types";
3
+ import { ModuleAccountStats, ModuleAccountTransaction, ModuleCreateStoreCreditAccount, ModuleCreditAccount, ModuleDebitAccount, ModuleRetrieveAccountStats, ModuleStoreCreditAccount, ModuleUpdateStoreCreditAccount } from "./module";
4
+ /**
5
+ * The filters to apply when retrieving store credit accounts.
6
+ */
7
+ export interface ModuleStoreCreditAccountFilters extends BaseFilterable<ModuleStoreCreditAccountFilters> {
8
+ /**
9
+ * A search term to filter store credit accounts by.
10
+ */
11
+ q?: string;
12
+ /**
13
+ * Filter by store credit account ID(s).
14
+ */
15
+ id?: string | string[];
16
+ /**
17
+ * Filter by currency code(s).
18
+ */
19
+ currency_code?: string | string[];
20
+ /**
21
+ * Filter by customer ID(s).
22
+ */
23
+ customer_id?: string | string[];
24
+ /**
25
+ * The field to order results by.
26
+ */
27
+ order?: string;
28
+ }
29
+ /**
30
+ * The filters to apply when listing account transactions.
31
+ */
32
+ export interface ModuleListAccountTransactions extends BaseFilterable<ModuleListAccountTransactions> {
33
+ /**
34
+ * Filter by transaction ID(s).
35
+ */
36
+ id?: string | string[];
37
+ /**
38
+ * Filter by store credit account ID(s).
39
+ */
40
+ account_id?: string | string[];
41
+ /**
42
+ * The field to order results by.
43
+ */
44
+ order?: string;
45
+ }
46
+ /**
47
+ * The main service interface for the StoreCredit Module.
48
+ */
49
+ export interface IStoreCreditModuleService extends IModuleService {
50
+ /**
51
+ * This method creates a store credit account.
52
+ *
53
+ * @param {ModuleCreateStoreCreditAccount} data - The store credit account to create.
54
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
55
+ * @returns {Promise<ModuleStoreCreditAccount>} The created store credit account.
56
+ *
57
+ * @example
58
+ * const account = await storeCreditModuleService.createStoreCreditAccounts({
59
+ * currency_code: "usd",
60
+ * customer_id: "cust_123",
61
+ * })
62
+ */
63
+ createStoreCreditAccounts(data: ModuleCreateStoreCreditAccount, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
64
+ /**
65
+ * This method creates store credit accounts.
66
+ *
67
+ * @param {ModuleCreateStoreCreditAccount[]} data - The store credit accounts to create.
68
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
69
+ * @returns {Promise<ModuleStoreCreditAccount[]>} The created store credit accounts.
70
+ *
71
+ * @example
72
+ * const accounts = await storeCreditModuleService.createStoreCreditAccounts([
73
+ * {
74
+ * currency_code: "usd",
75
+ * customer_id: "cust_123",
76
+ * },
77
+ * ])
78
+ */
79
+ createStoreCreditAccounts(data: ModuleCreateStoreCreditAccount[], sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
80
+ /**
81
+ * This method updates a store credit account.
82
+ *
83
+ * @param {ModuleUpdateStoreCreditAccount} data - The attributes to update in the store credit account.
84
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
85
+ * @returns {Promise<ModuleStoreCreditAccount>} The updated store credit account.
86
+ *
87
+ * @example
88
+ * const account = await storeCreditModuleService.updateStoreCreditAccounts({
89
+ * id: "sca_123",
90
+ * customer_id: "cust_456",
91
+ * })
92
+ */
93
+ updateStoreCreditAccounts(data: ModuleUpdateStoreCreditAccount, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
94
+ /**
95
+ * This method updates store credit accounts.
96
+ *
97
+ * @param {ModuleUpdateStoreCreditAccount[]} data - The attributes to update in the store credit accounts.
98
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
99
+ * @returns {Promise<ModuleStoreCreditAccount[]>} The updated store credit accounts.
100
+ *
101
+ * @example
102
+ * const accounts = await storeCreditModuleService.updateStoreCreditAccounts([
103
+ * {
104
+ * id: "sca_123",
105
+ * customer_id: "cust_456",
106
+ * },
107
+ * ])
108
+ */
109
+ updateStoreCreditAccounts(data: ModuleUpdateStoreCreditAccount[], sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
110
+ /**
111
+ * This method retrieves a paginated list of store credit accounts based on optional filters and configuration.
112
+ *
113
+ * @param {ModuleStoreCreditAccountFilters} filters - The filters to apply on the retrieved store credit accounts.
114
+ * @param {FindConfig<ModuleStoreCreditAccount>} config - The configurations determining how the store credit accounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a store credit account.
115
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
116
+ * @returns {Promise<ModuleStoreCreditAccount[]>} The list of store credit accounts.
117
+ *
118
+ * @example
119
+ * To retrieve a list of store credit accounts by customer:
120
+ *
121
+ * ```ts
122
+ * const accounts = await storeCreditModuleService.listStoreCreditAccounts({
123
+ * id: ["sca_123", "sca_321"],
124
+ * })
125
+ * ```
126
+ *
127
+ * To specify relations that should be retrieved within the store credit accounts:
128
+ *
129
+ * :::note
130
+ *
131
+ * You can only retrieve data models defined in the same module. To retrieve linked data models
132
+ * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
133
+ *
134
+ * :::
135
+ *
136
+ * ```ts
137
+ * const accounts = await storeCreditModuleService.listStoreCreditAccounts(
138
+ * {
139
+ * id: ["sca_123", "sca_321"],
140
+ * },
141
+ * {
142
+ * relations: ["transactions"],
143
+ * }
144
+ * )
145
+ * ```
146
+ *
147
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
148
+ *
149
+ * ```ts
150
+ * const accounts = await storeCreditModuleService.listStoreCreditAccounts(
151
+ * { id: ["sca_123", "sca_321"] },
152
+ * { take: 20, skip: 2 }
153
+ * )
154
+ * ```
155
+ */
156
+ listStoreCreditAccounts(filters?: ModuleStoreCreditAccountFilters, config?: FindConfig<ModuleStoreCreditAccount>, sharedContext?: Context): Promise<ModuleStoreCreditAccount[]>;
157
+ /**
158
+ * This method retrieves a store credit account by its ID.
159
+ *
160
+ * @param {string} id - The ID of the store credit account to retrieve.
161
+ * @param {FindConfig<ModuleStoreCreditAccount>} config - The configurations determining how the store credit account is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a store credit account.
162
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
163
+ * @returns {Promise<ModuleStoreCreditAccount>} The retrieved store credit account.
164
+ *
165
+ * @example
166
+ * A simple example that retrieves a store credit account by its ID:
167
+ *
168
+ * ```ts
169
+ * const account = await storeCreditModuleService.retrieveStoreCreditAccount("sca_123")
170
+ * ```
171
+ *
172
+ * To specify relations that should be retrieved:
173
+ *
174
+ * :::note
175
+ *
176
+ * You can only retrieve data models defined in the same module. To retrieve linked data models
177
+ * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
178
+ *
179
+ * :::
180
+ *
181
+ * ```ts
182
+ * const account = await storeCreditModuleService.retrieveStoreCreditAccount("sca_123", {
183
+ * relations: ["transactions"],
184
+ * })
185
+ * ```
186
+ */
187
+ retrieveStoreCreditAccount(id: string, config?: FindConfig<ModuleStoreCreditAccount>, sharedContext?: Context): Promise<ModuleStoreCreditAccount>;
188
+ /**
189
+ * This method deletes store credit accounts by their IDs.
190
+ *
191
+ * @param {string[]} ids - The IDs of the store credit accounts to delete.
192
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
193
+ * @returns {Promise<void>} Resolves when the store credit accounts are deleted successfully.
194
+ *
195
+ * @example
196
+ * await storeCreditModuleService.deleteStoreCreditAccounts(["sca_123", "sca_456"])
197
+ */
198
+ deleteStoreCreditAccounts(ids: string[], sharedContext?: Context): Promise<void>;
199
+ /**
200
+ * This method soft deletes store credit accounts by their IDs. Soft-deleted accounts can be restored using the {@link restoreStoreCreditAccounts} method.
201
+ *
202
+ * @param {string[]} ids - The IDs of the store credit accounts to soft delete.
203
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
204
+ * @returns {Promise<void>} Resolves when the store credit accounts are soft deleted successfully.
205
+ *
206
+ * @example
207
+ * await storeCreditModuleService.softDeleteStoreCreditAccounts(["sca_123"])
208
+ */
209
+ softDeleteStoreCreditAccounts(ids: string[], sharedContext?: Context): Promise<void>;
210
+ /**
211
+ * This method restores soft-deleted store credit accounts by their IDs.
212
+ *
213
+ * @param {string[]} ids - The IDs of the store credit accounts to restore.
214
+ * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore and return.
215
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
216
+ * @returns {Promise<Record<TReturnableLinkableKeys, string[]> | void>} The IDs of restored linked records, or void if no linkable keys are requested.
217
+ *
218
+ * @example
219
+ * await storeCreditModuleService.restoreStoreCreditAccounts(["sca_123"])
220
+ */
221
+ restoreStoreCreditAccounts<TReturnableLinkableKeys extends string = string>(ids: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<TReturnableLinkableKeys, string[]> | void>;
222
+ /**
223
+ * This method retrieves a list of account transactions based on the provided filters.
224
+ *
225
+ * @param {ModuleListAccountTransactions} filters - The filters to apply on the retrieved transactions.
226
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
227
+ * @returns {Promise<ModuleAccountTransaction[]>} The list of account transactions.
228
+ *
229
+ * @example
230
+ * To retrieve a list of account transactions by ID:
231
+ *
232
+ * ```ts
233
+ * const transactions = await storeCreditModuleService.listAccountTransactions({
234
+ * id: ["txn_123", "txn_321"],
235
+ * })
236
+ * ```
237
+ *
238
+ * To specify relations that should be retrieved within the account transactions:
239
+ *
240
+ * :::note
241
+ *
242
+ * You can only retrieve data models defined in the same module. To retrieve linked data models
243
+ * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
244
+ *
245
+ * :::
246
+ *
247
+ * ```ts
248
+ * const transactions = await storeCreditModuleService.listAccountTransactions({
249
+ * id: ["txn_123", "txn_321"],
250
+ * }, {
251
+ * relations: ["account"],
252
+ * })
253
+ * ```
254
+ *
255
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
256
+ *
257
+ * ```ts
258
+ * const transactions = await storeCreditModuleService.listAccountTransactions(
259
+ * { id: ["txn_123", "txn_321"] },
260
+ * { take: 20, skip: 2 }
261
+ * )
262
+ * ```
263
+ */
264
+ listAccountTransactions(filters: ModuleListAccountTransactions, sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
265
+ /**
266
+ * This method retrieves the balance statistics for a store credit account.
267
+ *
268
+ * @param {ModuleRetrieveAccountStats} filters - The filters to identify the account to retrieve stats for.
269
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
270
+ * @returns {Promise<ModuleAccountStats>} The account statistics including balance, credits, and debits.
271
+ *
272
+ * @example
273
+ * const stats = await storeCreditModuleService.retrieveAccountStats({
274
+ * account_id: "sca_123",
275
+ * })
276
+ */
277
+ retrieveAccountStats(filters: ModuleRetrieveAccountStats, sharedContext?: Context): Promise<ModuleAccountStats>;
278
+ /**
279
+ * This method credits one or more store credit accounts by creating credit transactions.
280
+ *
281
+ * @param {ModuleCreditAccount[]} data - The credit transactions to create.
282
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
283
+ * @returns {Promise<ModuleAccountTransaction[]>} The created credit transactions.
284
+ *
285
+ * @example
286
+ * const transactions = await storeCreditModuleService.creditAccounts([
287
+ * {
288
+ * account_id: "sca_123",
289
+ * amount: 100,
290
+ * reference: "order",
291
+ * reference_id: "order_123",
292
+ * },
293
+ * ])
294
+ */
295
+ creditAccounts(data: ModuleCreditAccount[], sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
296
+ /**
297
+ * This method debits one or more store credit accounts by creating debit transactions.
298
+ *
299
+ * @param {ModuleDebitAccount[]} data - The debit transactions to create.
300
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
301
+ * @returns {Promise<ModuleAccountTransaction[]>} The created debit transactions.
302
+ *
303
+ * @example
304
+ * const transactions = await storeCreditModuleService.debitAccounts([
305
+ * {
306
+ * account_id: "sca_123",
307
+ * amount: 50,
308
+ * reference: "cart",
309
+ * reference_id: "cart_123",
310
+ * },
311
+ * ])
312
+ */
313
+ debitAccounts(data: ModuleDebitAccount[], sharedContext?: Context): Promise<ModuleAccountTransaction[]>;
314
+ /**
315
+ * This method deletes account transactions by their IDs.
316
+ *
317
+ * @param {string[]} ids - The IDs of the transactions to delete.
318
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
319
+ * @returns {Promise<void>} Resolves when the transactions are deleted successfully.
320
+ *
321
+ * @example
322
+ * await storeCreditModuleService.deleteTransactions(["txn_123", "txn_456"])
323
+ */
324
+ deleteTransactions(ids: string[], sharedContext?: Context): Promise<void>;
325
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy90eXBlcy9zdG9yZS1jcmVkaXQvc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1 @@
1
+ export declare function generateCode(prefix?: string, sections?: number): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateCode = generateCode;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ function generateCode(prefix = "GIFT", sections = 4) {
9
+ // Characters to use (excluding similar-looking characters like 0/O, 1/I)
10
+ const characters = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
11
+ // Calculate how many bytes we need for generating our code
12
+ // We need enough random bytes to select from our character set
13
+ const length = sections * 4;
14
+ const byteLength = Math.ceil((length * Math.log2(characters.length)) / 8);
15
+ // Generate random bytes
16
+ const randomBytes = crypto_1.default.randomBytes(byteLength);
17
+ // Generate the code
18
+ let code = "";
19
+ for (let i = 0; i < length; i++) {
20
+ // Use a modulo operation to select a character from our set
21
+ const randomIndex = randomBytes[i % randomBytes.length] % characters.length;
22
+ code += characters.charAt(randomIndex);
23
+ }
24
+ // Split into chunks of 4 characters
25
+ const chunks = [];
26
+ for (let i = 0; i < code.length; i += 4) {
27
+ chunks.push(code.slice(i, i + 4));
28
+ }
29
+ // Format with prefix
30
+ return prefix ? `${prefix}-${chunks.join("-")}` : chunks.join("-");
31
+ }
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29kZS1nZW5lcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvY29kZS1nZW5lcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFFQSxvQ0FrQ0M7QUFwQ0Qsb0RBQTRCO0FBRTVCLFNBQWdCLFlBQVksQ0FDMUIsU0FBaUIsTUFBTSxFQUN2QixXQUFtQixDQUFDO0lBRXBCLHlFQUF5RTtJQUN6RSxNQUFNLFVBQVUsR0FBVyxrQ0FBa0MsQ0FBQztJQUU5RCwyREFBMkQ7SUFDM0QsK0RBQStEO0lBQy9ELE1BQU0sTUFBTSxHQUFXLFFBQVEsR0FBRyxDQUFDLENBQUM7SUFDcEMsTUFBTSxVQUFVLEdBQVcsSUFBSSxDQUFDLElBQUksQ0FDbEMsQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQzVDLENBQUM7SUFFRix3QkFBd0I7SUFDeEIsTUFBTSxXQUFXLEdBQVcsZ0JBQU0sQ0FBQyxXQUFXLENBQUMsVUFBVSxDQUFDLENBQUM7SUFFM0Qsb0JBQW9CO0lBQ3BCLElBQUksSUFBSSxHQUFXLEVBQUUsQ0FBQztJQUN0QixLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7UUFDaEMsNERBQTREO1FBQzVELE1BQU0sV0FBVyxHQUNmLFdBQVcsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLE1BQU0sQ0FBQyxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7UUFDMUQsSUFBSSxJQUFJLFVBQVUsQ0FBQyxNQUFNLENBQUMsV0FBVyxDQUFDLENBQUM7SUFDekMsQ0FBQztJQUVELG9DQUFvQztJQUNwQyxNQUFNLE1BQU0sR0FBYSxFQUFFLENBQUM7SUFDNUIsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDO1FBQ3hDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLEVBQUUsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEMsQ0FBQztJQUVELHFCQUFxQjtJQUNyQixPQUFPLE1BQU0sQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLElBQUksTUFBTSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ3JFLENBQUMifQ==
@@ -0,0 +1,5 @@
1
+ export * from "./workflows/add-gift-card-to-cart";
2
+ export * from "./workflows/add-store-credits-to-cart";
3
+ export * from "./workflows/confirm-cart-credit-lines";
4
+ export * from "./workflows/refresh-cart-gift-cards";
5
+ export * from "./workflows/remove-gift-cart-from-cart";
@@ -0,0 +1,22 @@
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("./workflows/add-gift-card-to-cart"), exports);
18
+ __exportStar(require("./workflows/add-store-credits-to-cart"), exports);
19
+ __exportStar(require("./workflows/confirm-cart-credit-lines"), exports);
20
+ __exportStar(require("./workflows/refresh-cart-gift-cards"), exports);
21
+ __exportStar(require("./workflows/remove-gift-cart-from-cart"), exports);
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2NhcnRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxvRUFBaUQ7QUFDakQsd0VBQXFEO0FBQ3JELHdFQUFxRDtBQUNyRCxzRUFBbUQ7QUFDbkQseUVBQXNEIn0=
@@ -0,0 +1,37 @@
1
+ import { ModuleAccountStats, ModuleGiftCard } from "../../../types";
2
+ /**
3
+ * Input to validate that all gift cards in a collection have a positive balance.
4
+ */
5
+ export interface ValidateGiftCardBalancesStepInput {
6
+ /**
7
+ * The gift cards to validate.
8
+ */
9
+ giftCards: ModuleGiftCard[];
10
+ /**
11
+ * A map of gift card codes to their account statistics, including the current balance.
12
+ */
13
+ giftCardsBalanceMap: Record<string, ModuleAccountStats>;
14
+ }
15
+ /**
16
+ * This step validates that all gift cards in a collection have a positive balance.
17
+ * It throws an error for any gift card with zero or negative balance.
18
+ *
19
+ * @example
20
+ * const data = validateGiftCardBalancesStep({
21
+ * giftCards: [
22
+ * {
23
+ * id: "gc_123",
24
+ * code: "GC-XXXX",
25
+ * // other gift card properties...
26
+ * }
27
+ * ],
28
+ * giftCardsBalanceMap: {
29
+ * "GC-XXXX": {
30
+ * balance: 100,
31
+ * credit: 150,
32
+ * debit: 50,
33
+ * }
34
+ * },
35
+ * })
36
+ */
37
+ export declare const validateGiftCardBalancesStep: import("@medusajs/framework/workflows-sdk").StepFunction<ValidateGiftCardBalancesStepInput, unknown>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateGiftCardBalancesStep = void 0;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
6
+ /**
7
+ * This step validates that all gift cards in a collection have a positive balance.
8
+ * It throws an error for any gift card with zero or negative balance.
9
+ *
10
+ * @example
11
+ * const data = validateGiftCardBalancesStep({
12
+ * giftCards: [
13
+ * {
14
+ * id: "gc_123",
15
+ * code: "GC-XXXX",
16
+ * // other gift card properties...
17
+ * }
18
+ * ],
19
+ * giftCardsBalanceMap: {
20
+ * "GC-XXXX": {
21
+ * balance: 100,
22
+ * credit: 150,
23
+ * debit: 50,
24
+ * }
25
+ * },
26
+ * })
27
+ */
28
+ exports.validateGiftCardBalancesStep = (0, workflows_sdk_1.createStep)("validate-gift-card-balances", async function ({ giftCards, giftCardsBalanceMap, }) {
29
+ for (const giftCard of giftCards) {
30
+ const stats = giftCardsBalanceMap[giftCard.code];
31
+ if (utils_1.MathBN.convert(stats.balance).lte(0)) {
32
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Gift card (${giftCard.code}) has no balance`);
33
+ }
34
+ }
35
+ });
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGUtZ2lmdC1jYXJkLWJhbGFuY2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3dvcmtmbG93cy9jYXJ0cy9zdGVwcy92YWxpZGF0ZS1naWZ0LWNhcmQtYmFsYW5jZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscURBQWdFO0FBQ2hFLHFFQUErRDtBQWlCL0Q7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXFCRztBQUNVLFFBQUEsNEJBQTRCLEdBQUcsSUFBQSwwQkFBVSxFQUNwRCw2QkFBNkIsRUFDN0IsS0FBSyxXQUFXLEVBQ2QsU0FBUyxFQUNULG1CQUFtQixHQUNlO0lBQ2xDLEtBQUssTUFBTSxRQUFRLElBQUksU0FBUyxFQUFFLENBQUM7UUFDakMsTUFBTSxLQUFLLEdBQUcsbUJBQW1CLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBRWpELElBQUksY0FBTSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7WUFDekMsTUFBTSxJQUFJLG1CQUFXLENBQ25CLG1CQUFXLENBQUMsS0FBSyxDQUFDLFlBQVksRUFDOUIsY0FBYyxRQUFRLENBQUMsSUFBSSxrQkFBa0IsQ0FDOUMsQ0FBQztRQUNKLENBQUM7SUFDSCxDQUFDO0FBQ0gsQ0FBQyxDQUNGLENBQUMifQ==
@@ -0,0 +1,118 @@
1
+ import { PluginCartDTO } from "../../../types/cart";
2
+ import { ModuleGiftCard } from "../../../types/loyalty";
3
+ import { ModuleAccountStats, ModuleStoreCreditAccount } from "../../../types/store-credit";
4
+ /**
5
+ * Input to retrieve the balance of a single gift card from its associated store credit account.
6
+ */
7
+ export interface RetrieveGiftCardBalanceStepInput {
8
+ /**
9
+ * The store credit account linked to the gift card.
10
+ */
11
+ storeCreditAccount: ModuleStoreCreditAccount;
12
+ /**
13
+ * The gift card whose balance should be retrieved.
14
+ */
15
+ giftCard: ModuleGiftCard;
16
+ }
17
+ /**
18
+ * This step retrieves the balance of a single gift card from its associated store
19
+ * credit account. Returns a map of the gift card code to its account stats.
20
+ *
21
+ * @example
22
+ * const data = retrieveGiftCardBalanceStep({
23
+ * storeCreditAccount: {
24
+ * id: "sca_123",
25
+ * balance: 100,
26
+ * // other store credit account properties...
27
+ * },
28
+ * giftCard: {
29
+ * id: "gc_123",
30
+ * code: "GC-XXXX",
31
+ * // other gift card properties...
32
+ * },
33
+ * })
34
+ */
35
+ export declare const retrieveGiftCardBalanceStep: import("@medusajs/framework/workflows-sdk").StepFunction<RetrieveGiftCardBalanceStepInput, Record<string, ModuleAccountStats>>;
36
+ /**
37
+ * Input to validate that a gift card exists.
38
+ */
39
+ export interface ValidateGiftCardExistsStepInput {
40
+ /**
41
+ * The gift card to validate, or undefined if not found.
42
+ */
43
+ giftCard: ModuleGiftCard;
44
+ /**
45
+ * The lookup input containing the gift card code.
46
+ */
47
+ input: {
48
+ code: string;
49
+ };
50
+ }
51
+ /**
52
+ * Input to validate that gift cards can be added to a cart.
53
+ */
54
+ export interface ValidateCartGiftCardStepInput {
55
+ /**
56
+ * The cart to validate against, including its currently applied gift cards.
57
+ */
58
+ cart: PluginCartDTO;
59
+ /**
60
+ * The gift cards to apply to the cart.
61
+ */
62
+ giftCards: ModuleGiftCard[];
63
+ }
64
+ /**
65
+ * This step validates that gift cards can be added to a cart. It throws an error
66
+ * if a gift card is already applied to the cart or if the gift card currency does
67
+ * not match the cart's currency.
68
+ *
69
+ * @example
70
+ * const data = validateCartGiftCardStep({
71
+ * cart: {
72
+ * id: "cart_123",
73
+ * gift_cards: [
74
+ * { code: "GC-XXXX-XXXX" },
75
+ * // other gift cards applied to the cart...
76
+ * ],
77
+ * currency_code: "usd",
78
+ * // other cart properties...
79
+ * },
80
+ * giftCards: [...],
81
+ * })
82
+ */
83
+ export declare const validateCartGiftCardStep: import("@medusajs/framework/workflows-sdk").StepFunction<ValidateCartGiftCardStepInput, unknown>;
84
+ /**
85
+ * Input to apply a gift card to a cart.
86
+ */
87
+ export interface AddGiftCardToCartWorkflowInput {
88
+ /**
89
+ * The code of the gift card to apply.
90
+ */
91
+ code: string;
92
+ /**
93
+ * The ID of the cart to apply the gift card to.
94
+ */
95
+ cart_id: string;
96
+ }
97
+ /**
98
+ * This workflow applies a gift card to a cart by creating a credit line for the
99
+ * gift card's balance and linking the gift card to the cart. It validates that
100
+ * the gift card exists, has sufficient balance, and can be applied to the cart.
101
+ *
102
+ * You can use this workflow within your own customizations or custom workflows,
103
+ * allowing you to wrap custom logic around adding gift cards to carts.
104
+ *
105
+ * @example
106
+ * const { result } = await addGiftCardToCartWorkflow(container)
107
+ * .run({
108
+ * input: {
109
+ * code: "GC-XXXX-XXXX",
110
+ * cart_id: "cart_123",
111
+ * },
112
+ * })
113
+ *
114
+ * @summary
115
+ *
116
+ * Apply a gift card to a cart.
117
+ */
118
+ export declare const addGiftCardToCartWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<AddGiftCardToCartWorkflowInput, import("@medusajs/framework/types").CartCreditLineDTO[], []>;