@medusajs/types 1.12.0-snapshot-20240403120107 → 1.12.0-snapshot-20240405154416

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. package/dist/auth/common/auth-user.d.ts +21 -16
  2. package/dist/auth/common/auth-user.d.ts.map +1 -1
  3. package/dist/auth/common/provider.d.ts +28 -15
  4. package/dist/auth/common/provider.d.ts.map +1 -1
  5. package/dist/auth/service.d.ts +137 -75
  6. package/dist/auth/service.d.ts.map +1 -1
  7. package/dist/bundles.d.ts +2 -0
  8. package/dist/bundles.d.ts.map +1 -1
  9. package/dist/bundles.js +3 -1
  10. package/dist/bundles.js.map +1 -1
  11. package/dist/cart/common.d.ts +443 -62
  12. package/dist/cart/common.d.ts.map +1 -1
  13. package/dist/cart/mutations.d.ts +483 -0
  14. package/dist/cart/mutations.d.ts.map +1 -1
  15. package/dist/cart/mutations.js.map +1 -1
  16. package/dist/cart/service.d.ts +1607 -0
  17. package/dist/cart/service.d.ts.map +1 -1
  18. package/dist/common/index.d.ts +1 -0
  19. package/dist/common/index.d.ts.map +1 -1
  20. package/dist/common/index.js +1 -0
  21. package/dist/common/index.js.map +1 -1
  22. package/dist/common/rule.d.ts +2 -0
  23. package/dist/common/rule.d.ts.map +1 -0
  24. package/dist/common/rule.js +3 -0
  25. package/dist/common/rule.js.map +1 -0
  26. package/dist/customer/service.d.ts +445 -197
  27. package/dist/customer/service.d.ts.map +1 -1
  28. package/dist/file/common.d.ts +14 -0
  29. package/dist/file/common.d.ts.map +1 -0
  30. package/dist/file/common.js +3 -0
  31. package/dist/file/common.js.map +1 -0
  32. package/dist/file/index.d.ts +4 -0
  33. package/dist/file/index.d.ts.map +1 -0
  34. package/dist/file/index.js +20 -0
  35. package/dist/file/index.js.map +1 -0
  36. package/dist/file/mutations.d.ts +18 -0
  37. package/dist/file/mutations.d.ts.map +1 -0
  38. package/dist/file/mutations.js +3 -0
  39. package/dist/file/mutations.js.map +1 -0
  40. package/dist/file/service.d.ts +76 -0
  41. package/dist/file/service.d.ts.map +1 -0
  42. package/dist/file/service.js +3 -0
  43. package/dist/file/service.js.map +1 -0
  44. package/dist/fulfillment/mutations/shipping-option-rule.d.ts +2 -2
  45. package/dist/fulfillment/mutations/shipping-option-rule.d.ts.map +1 -1
  46. package/dist/http/fulfillment/admin/fulfillment-address.d.ts +22 -0
  47. package/dist/http/fulfillment/admin/fulfillment-address.d.ts.map +1 -0
  48. package/dist/http/fulfillment/admin/fulfillment-address.js +3 -0
  49. package/dist/http/fulfillment/admin/fulfillment-address.js.map +1 -0
  50. package/dist/http/fulfillment/admin/fulfillment-item.d.ts +17 -0
  51. package/dist/http/fulfillment/admin/fulfillment-item.d.ts.map +1 -0
  52. package/dist/http/fulfillment/admin/fulfillment-item.js +3 -0
  53. package/dist/http/fulfillment/admin/fulfillment-item.js.map +1 -0
  54. package/dist/http/fulfillment/admin/fulfillment-label.d.ts +14 -0
  55. package/dist/http/fulfillment/admin/fulfillment-label.d.ts.map +1 -0
  56. package/dist/http/fulfillment/admin/fulfillment-label.js +3 -0
  57. package/dist/http/fulfillment/admin/fulfillment-label.js.map +1 -0
  58. package/dist/http/fulfillment/admin/fulfillment-provider.d.ts +12 -0
  59. package/dist/http/fulfillment/admin/fulfillment-provider.d.ts.map +1 -0
  60. package/dist/http/fulfillment/admin/fulfillment-provider.js +3 -0
  61. package/dist/http/fulfillment/admin/fulfillment-provider.js.map +1 -0
  62. package/dist/http/fulfillment/admin/fulfillment-set.d.ts +15 -0
  63. package/dist/http/fulfillment/admin/fulfillment-set.d.ts.map +1 -0
  64. package/dist/http/fulfillment/admin/fulfillment-set.js +3 -0
  65. package/dist/http/fulfillment/admin/fulfillment-set.js.map +1 -0
  66. package/dist/http/fulfillment/admin/fulfillment.d.ts +27 -0
  67. package/dist/http/fulfillment/admin/fulfillment.d.ts.map +1 -0
  68. package/dist/http/fulfillment/admin/fulfillment.js +3 -0
  69. package/dist/http/fulfillment/admin/fulfillment.js.map +1 -0
  70. package/dist/http/fulfillment/admin/geo-zone.d.ts +17 -0
  71. package/dist/http/fulfillment/admin/geo-zone.d.ts.map +1 -0
  72. package/dist/http/fulfillment/admin/geo-zone.js +3 -0
  73. package/dist/http/fulfillment/admin/geo-zone.js.map +1 -0
  74. package/dist/http/fulfillment/admin/index.d.ts +13 -0
  75. package/dist/http/fulfillment/admin/index.d.ts.map +1 -0
  76. package/dist/http/fulfillment/admin/index.js +29 -0
  77. package/dist/http/fulfillment/admin/index.js.map +1 -0
  78. package/dist/http/fulfillment/admin/service-zone.d.ts +14 -0
  79. package/dist/http/fulfillment/admin/service-zone.d.ts.map +1 -0
  80. package/dist/http/fulfillment/admin/service-zone.js +3 -0
  81. package/dist/http/fulfillment/admin/service-zone.js.map +1 -0
  82. package/dist/http/fulfillment/admin/shipping-option-rule.d.ts +16 -0
  83. package/dist/http/fulfillment/admin/shipping-option-rule.d.ts.map +1 -0
  84. package/dist/http/fulfillment/admin/shipping-option-rule.js +3 -0
  85. package/dist/http/fulfillment/admin/shipping-option-rule.js.map +1 -0
  86. package/dist/http/fulfillment/admin/shipping-option-type.d.ts +14 -0
  87. package/dist/http/fulfillment/admin/shipping-option-type.d.ts.map +1 -0
  88. package/dist/http/fulfillment/admin/shipping-option-type.js +3 -0
  89. package/dist/http/fulfillment/admin/shipping-option-type.js.map +1 -0
  90. package/dist/http/fulfillment/admin/shipping-option.d.ts +31 -0
  91. package/dist/http/fulfillment/admin/shipping-option.d.ts.map +1 -0
  92. package/dist/http/fulfillment/admin/shipping-option.js +3 -0
  93. package/dist/http/fulfillment/admin/shipping-option.js.map +1 -0
  94. package/dist/http/fulfillment/admin/shipping-profile.d.ts +13 -0
  95. package/dist/http/fulfillment/admin/shipping-profile.d.ts.map +1 -0
  96. package/dist/http/fulfillment/admin/shipping-profile.js +3 -0
  97. package/dist/http/fulfillment/admin/shipping-profile.js.map +1 -0
  98. package/dist/http/fulfillment/index.d.ts +2 -0
  99. package/dist/http/fulfillment/index.d.ts.map +1 -0
  100. package/dist/http/fulfillment/index.js +18 -0
  101. package/dist/http/fulfillment/index.js.map +1 -0
  102. package/dist/http/index.d.ts +2 -0
  103. package/dist/http/index.d.ts.map +1 -0
  104. package/dist/http/index.js +18 -0
  105. package/dist/http/index.js.map +1 -0
  106. package/dist/index.d.ts +2 -0
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +2 -0
  109. package/dist/index.js.map +1 -1
  110. package/dist/inventory/common/inventory-item.d.ts +55 -64
  111. package/dist/inventory/common/inventory-item.d.ts.map +1 -1
  112. package/dist/inventory/common/inventory-level.d.ts +37 -37
  113. package/dist/inventory/common/inventory-level.d.ts.map +1 -1
  114. package/dist/inventory/common/reservation-item.d.ts +34 -44
  115. package/dist/inventory/common/reservation-item.d.ts.map +1 -1
  116. package/dist/inventory/service-next.d.ts +596 -534
  117. package/dist/inventory/service-next.d.ts.map +1 -1
  118. package/dist/payment/common.d.ts +175 -54
  119. package/dist/payment/common.d.ts.map +1 -1
  120. package/dist/payment/common.js +3 -3
  121. package/dist/payment/common.js.map +1 -1
  122. package/dist/payment/mutations.d.ts +58 -17
  123. package/dist/payment/mutations.d.ts.map +1 -1
  124. package/dist/payment/provider.d.ts +128 -43
  125. package/dist/payment/provider.d.ts.map +1 -1
  126. package/dist/payment/provider.js.map +1 -1
  127. package/dist/payment/service.d.ts +460 -39
  128. package/dist/payment/service.d.ts.map +1 -1
  129. package/dist/pricing/common/price-list.d.ts +2 -2
  130. package/dist/pricing/common/price-set.d.ts +6 -4
  131. package/dist/pricing/common/price-set.d.ts.map +1 -1
  132. package/dist/pricing/service.d.ts +731 -1695
  133. package/dist/pricing/service.d.ts.map +1 -1
  134. package/dist/promotion/common/application-method.d.ts +153 -0
  135. package/dist/promotion/common/application-method.d.ts.map +1 -1
  136. package/dist/promotion/common/campaign-budget.d.ts +37 -0
  137. package/dist/promotion/common/campaign-budget.d.ts.map +1 -1
  138. package/dist/promotion/common/campaign.d.ts +36 -0
  139. package/dist/promotion/common/campaign.d.ts.map +1 -1
  140. package/dist/promotion/common/compute-actions.d.ts +135 -0
  141. package/dist/promotion/common/compute-actions.d.ts.map +1 -1
  142. package/dist/promotion/common/promotion-rule-value.d.ts +30 -0
  143. package/dist/promotion/common/promotion-rule-value.d.ts.map +1 -1
  144. package/dist/promotion/common/promotion-rule.d.ts +77 -0
  145. package/dist/promotion/common/promotion-rule.d.ts.map +1 -1
  146. package/dist/promotion/common/promotion.d.ts +100 -0
  147. package/dist/promotion/common/promotion.d.ts.map +1 -1
  148. package/dist/promotion/mutations.d.ts +84 -0
  149. package/dist/promotion/mutations.d.ts.map +1 -1
  150. package/dist/promotion/service.d.ts +786 -0
  151. package/dist/promotion/service.d.ts.map +1 -1
  152. package/dist/region/common.d.ts +1 -1
  153. package/dist/region/common.d.ts.map +1 -1
  154. package/dist/region/service.d.ts +1 -1
  155. package/dist/stock-location/common.d.ts +14 -0
  156. package/dist/stock-location/common.d.ts.map +1 -1
  157. package/dist/stock-location/service-next.d.ts +178 -186
  158. package/dist/stock-location/service-next.d.ts.map +1 -1
  159. package/dist/store/common/store.d.ts +42 -0
  160. package/dist/store/common/store.d.ts.map +1 -1
  161. package/dist/store/mutations/store.d.ts +75 -0
  162. package/dist/store/mutations/store.d.ts.map +1 -1
  163. package/dist/store/service.d.ts +113 -75
  164. package/dist/store/service.d.ts.map +1 -1
  165. package/dist/tax/common.d.ts +298 -10
  166. package/dist/tax/common.d.ts.map +1 -1
  167. package/dist/tax/mutations.d.ts +157 -0
  168. package/dist/tax/mutations.d.ts.map +1 -1
  169. package/dist/tax/provider.d.ts +126 -0
  170. package/dist/tax/provider.d.ts.map +1 -1
  171. package/dist/tax/service.d.ts +600 -0
  172. package/dist/tax/service.d.ts.map +1 -1
  173. package/dist/workflow/index.d.ts +1 -0
  174. package/dist/workflow/index.d.ts.map +1 -1
  175. package/dist/workflow/index.js +2 -1
  176. package/dist/workflow/index.js.map +1 -1
  177. package/dist/workflow/region/create-regions.d.ts +8 -0
  178. package/dist/workflow/region/create-regions.d.ts.map +1 -0
  179. package/dist/workflow/region/create-regions.js +3 -0
  180. package/dist/workflow/region/create-regions.js.map +1 -0
  181. package/dist/workflow/region/index.d.ts +3 -0
  182. package/dist/workflow/region/index.d.ts.map +1 -0
  183. package/dist/workflow/region/index.js +19 -0
  184. package/dist/workflow/region/index.js.map +1 -0
  185. package/dist/workflow/region/update-regions.d.ts +9 -0
  186. package/dist/workflow/region/update-regions.d.ts.map +1 -0
  187. package/dist/workflow/region/update-regions.js +3 -0
  188. package/dist/workflow/region/update-regions.js.map +1 -0
  189. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { RestoreReturn, SoftDeleteReturn } from "../dal";
4
4
  import { IModuleService } from "../modules-sdk";
5
5
  import { Context } from "../shared-context";
6
6
  /**
7
- * The main service interface for the pricing module.
7
+ * The main service interface for the Pricing Module.
8
8
  */
9
9
  export interface IPricingModuleService extends IModuleService {
10
10
  /**
@@ -21,69 +21,48 @@ export interface IPricingModuleService extends IModuleService {
21
21
  * When you calculate prices, you must at least specify the currency code:
22
22
  *
23
23
  * ```ts
24
- * import {
25
- * initialize as initializePricingModule,
26
- * } from "@medusajs/pricing"
27
- * async function calculatePrice (priceSetId: string, currencyCode: string) {
28
- * const pricingService = await initializePricingModule()
29
- *
30
- * const price = await pricingService.calculatePrices(
31
- * { id: [priceSetId] },
32
- * {
33
- * context: {
34
- * currency_code: currencyCode
35
- * }
36
- * }
37
- * )
38
- *
39
- * // do something with the price or return it
40
- * }
24
+ * const price = await pricingModuleService.calculatePrices(
25
+ * {
26
+ * id: ["pset_123", "pset_321"],
27
+ * },
28
+ * {
29
+ * context: {
30
+ * currency_code: "usd",
31
+ * },
32
+ * }
33
+ * )
41
34
  * ```
42
35
  *
43
36
  * To calculate prices for specific minimum and/or maximum quantity:
44
37
  *
45
38
  * ```ts
46
- * import {
47
- * initialize as initializePricingModule,
48
- * } from "@medusajs/pricing"
49
- * async function calculatePrice (priceSetId: string, currencyCode: string) {
50
- * const pricingService = await initializePricingModule()
51
- *
52
- * const price = await pricingService.calculatePrices(
53
- * { id: [priceSetId] },
54
- * {
55
- * context: {
56
- * currency_code: currencyCode,
57
- * min_quantity: 4
58
- * }
59
- * }
60
- * )
61
- *
62
- * // do something with the price or return it
63
- * }
39
+ * const price = await pricingModuleService.calculatePrices(
40
+ * {
41
+ * id: ["pset_123", "pset_321"],
42
+ * },
43
+ * {
44
+ * context: {
45
+ * currency_code: "usd",
46
+ * min_quantity: 4,
47
+ * },
48
+ * }
49
+ * )
64
50
  * ```
65
51
  *
66
52
  * To calculate prices for custom rule types:
67
53
  *
68
54
  * ```ts
69
- * import {
70
- * initialize as initializePricingModule,
71
- * } from "@medusajs/pricing"
72
- * async function calculatePrice (priceSetId: string, currencyCode: string) {
73
- * const pricingService = await initializePricingModule()
74
- *
75
- * const price = await pricingService.calculatePrices(
76
- * { id: [priceSetId] },
77
- * {
78
- * context: {
79
- * currency_code: currencyCode,
80
- * region_id: "US"
81
- * }
82
- * }
83
- * )
84
- *
85
- * // do something with the price or return it
86
- * }
55
+ * const price = await pricingModuleService.calculatePrices(
56
+ * {
57
+ * id: ["pset_123", "pset_321"],
58
+ * },
59
+ * {
60
+ * context: {
61
+ * currency_code: "usd",
62
+ * region_id: "US",
63
+ * },
64
+ * }
65
+ * )
87
66
  * ```
88
67
  */
89
68
  calculatePrices(filters: PricingFilters, context?: PricingContext, sharedContext?: Context): Promise<CalculatedPriceSet[]>;
@@ -101,40 +80,19 @@ export interface IPricingModuleService extends IModuleService {
101
80
  * A simple example that retrieves a price set by its ID:
102
81
  *
103
82
  * ```ts
104
- * import {
105
- * initialize as initializePricingModule,
106
- * } from "@medusajs/pricing"
107
- *
108
- * async function retrievePriceSet (priceSetId: string) {
109
- * const pricingService = await initializePricingModule()
110
- *
111
- * const priceSet = await pricingService.retrieve(
112
- * priceSetId
113
- * )
114
- *
115
- * // do something with the price set or return it
116
- * }
83
+ * const priceSet =
84
+ * await pricingModuleService.retrieve("pset_123")
117
85
  * ```
118
86
  *
119
87
  * To specify relations that should be retrieved:
120
88
  *
121
89
  * ```ts
122
- * import {
123
- * initialize as initializePricingModule,
124
- * } from "@medusajs/pricing"
125
- *
126
- * async function retrievePriceSet (priceSetId: string) {
127
- * const pricingService = await initializePricingModule()
128
- *
129
- * const priceSet = await pricingService.retrieve(
130
- * priceSetId,
131
- * {
132
- * relations: ["prices"]
133
- * }
134
- * )
135
- *
136
- * // do something with the price set or return it
137
- * }
90
+ * const priceSet = await pricingModuleService.retrieve(
91
+ * "pset_123",
92
+ * {
93
+ * relations: ["prices"],
94
+ * }
95
+ * )
138
96
  * ```
139
97
  */
140
98
  retrieve(id: string, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO>;
@@ -153,103 +111,37 @@ export interface IPricingModuleService extends IModuleService {
153
111
  * To retrieve a list of price sets using their IDs:
154
112
  *
155
113
  * ```ts
156
- * import {
157
- * initialize as initializePricingModule,
158
- * } from "@medusajs/pricing"
159
- *
160
- * async function retrievePriceSets (priceSetIds: string[]) {
161
- * const pricingService = await initializePricingModule()
162
- *
163
- * const priceSets = await pricingService.list(
164
- * {
165
- * id: priceSetIds
166
- * },
167
- * )
168
- *
169
- * // do something with the price sets or return them
170
- * }
114
+ * const priceSets = await pricingModuleService.list({
115
+ * id: ["pset_123", "pset_321"],
116
+ * })
171
117
  * ```
172
118
  *
173
119
  * To specify relations that should be retrieved within the price sets:
174
120
  *
175
121
  * ```ts
176
- * import {
177
- * initialize as initializePricingModule,
178
- * } from "@medusajs/pricing"
179
- *
180
- * async function retrievePriceSets (priceSetIds: string[]) {
181
- * const pricingService = await initializePricingModule()
182
- *
183
- * const priceSets = await pricingService.list(
184
- * {
185
- * id: priceSetIds
186
- * },
187
- * {
188
- * relations: ["prices"]
189
- * }
190
- * )
191
- *
192
- * // do something with the price sets or return them
193
- * }
122
+ * const priceSets = await pricingModuleService.list(
123
+ * {
124
+ * id: ["pset_123", "pset_321"],
125
+ * },
126
+ * {
127
+ * relations: ["prices"],
128
+ * }
129
+ * )
194
130
  * ```
195
131
  *
196
132
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
197
133
  *
198
134
  * ```ts
199
- * import {
200
- * initialize as initializePricingModule,
201
- * } from "@medusajs/pricing"
202
- *
203
- * async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
204
- * const pricingService = await initializePricingModule()
205
- *
206
- * const priceSets = await pricingService.list(
207
- * {
208
- * id: priceSetIds
209
- * },
210
- * {
211
- * relations: ["prices"],
212
- * skip,
213
- * take
214
- * }
215
- * )
216
- *
217
- * // do something with the price sets or return them
218
- * }
219
- * ```
220
- *
221
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
222
- *
223
- * ```ts
224
- * import {
225
- * initialize as initializePricingModule,
226
- * } from "@medusajs/pricing"
227
- *
228
- * async function retrievePriceSets (priceSetIds: string[], priceIds: string[], skip: number, take: number) {
229
- * const pricingService = await initializePricingModule()
230
- *
231
- * const priceSets = await pricingService.list(
232
- * {
233
- * $and: [
234
- * {
235
- * id: priceSetIds
236
- * },
237
- * {
238
- * prices: {
239
- * id: priceIds
240
- * }
241
- * }
242
- * ]
243
- * },
244
- * {
245
- * relations: ["prices"],
246
- * skip,
247
- * take
248
- * }
249
- * )
250
- *
251
- * // do something with the price sets or return them
252
- * }
135
+ * const priceSets = await pricingModuleService.list(
136
+ * {
137
+ * id: ["pset_123", "pset_321"],
138
+ * },
139
+ * {
140
+ * relations: ["prices"],
141
+ * take: 20,
142
+ * skip: 2,
143
+ * }
144
+ * )
253
145
  * ```
254
146
  */
255
147
  list(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
@@ -268,103 +160,40 @@ export interface IPricingModuleService extends IModuleService {
268
160
  * To retrieve a list of prices sets using their IDs:
269
161
  *
270
162
  * ```ts
271
- * import {
272
- * initialize as initializePricingModule,
273
- * } from "@medusajs/pricing"
274
- *
275
- * async function retrievePriceSets (priceSetIds: string[]) {
276
- * const pricingService = await initializePricingModule()
277
- *
278
- * const [priceSets, count] = await pricingService.listAndCount(
279
- * {
280
- * id: priceSetIds
281
- * },
282
- * )
283
- *
284
- * // do something with the price sets or return them
285
- * }
163
+ * const [priceSets, count] =
164
+ * await pricingModuleService.listAndCount({
165
+ * id: ["pset_123", "pset_321"],
166
+ * })
286
167
  * ```
287
168
  *
288
169
  * To specify relations that should be retrieved within the price sets:
289
170
  *
290
171
  * ```ts
291
- * import {
292
- * initialize as initializePricingModule,
293
- * } from "@medusajs/pricing"
294
- *
295
- * async function retrievePriceSets (priceSetIds: string[]) {
296
- * const pricingService = await initializePricingModule()
297
- *
298
- * const [priceSets, count] = await pricingService.listAndCount(
172
+ * const [priceSets, count] =
173
+ * await pricingModuleService.listAndCount(
299
174
  * {
300
- * id: priceSetIds
175
+ * id: ["pset_123", "pset_321"],
301
176
  * },
302
177
  * {
303
- * relations: ["prices"]
178
+ * relations: ["prices"],
304
179
  * }
305
180
  * )
306
- *
307
- * // do something with the price sets or return them
308
- * }
309
181
  * ```
310
182
  *
311
183
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
312
184
  *
313
185
  * ```ts
314
- * import {
315
- * initialize as initializePricingModule,
316
- * } from "@medusajs/pricing"
317
- *
318
- * async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
319
- * const pricingService = await initializePricingModule()
320
- *
321
- * const [priceSets, count] = await pricingService.listAndCount(
186
+ * const [priceSets, count] =
187
+ * await pricingModuleService.listAndCount(
322
188
  * {
323
- * id: priceSetIds
189
+ * id: ["pset_123", "pset_321"],
324
190
  * },
325
191
  * {
326
192
  * relations: ["prices"],
327
- * skip,
328
- * take
193
+ * take: 20,
194
+ * skip: 2,
329
195
  * }
330
196
  * )
331
- *
332
- * // do something with the price sets or return them
333
- * }
334
- * ```
335
- *
336
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
337
- *
338
- * ```ts
339
- * import {
340
- * initialize as initializePricingModule,
341
- * } from "@medusajs/pricing"
342
- *
343
- * async function retrievePriceSets (priceSetIds: string[], priceIds: string[], skip: number, take: number) {
344
- * const pricingService = await initializePricingModule()
345
- *
346
- * const [priceSets, count] = await pricingService.listAndCount(
347
- * {
348
- * $and: [
349
- * {
350
- * id: priceSetIds
351
- * },
352
- * {
353
- * prices: {
354
- * id: priceIds
355
- * }
356
- * }
357
- * ]
358
- * },
359
- * {
360
- * relations: ["prices"],
361
- * skip,
362
- * take
363
- * }
364
- * )
365
- *
366
- * // do something with the price sets or return them
367
- * }
368
197
  * ```
369
198
  */
370
199
  listAndCount(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
@@ -379,87 +208,64 @@ export interface IPricingModuleService extends IModuleService {
379
208
  * To create a default price set, don't pass any rules. For example:
380
209
  *
381
210
  * ```ts
382
- * import {
383
- * initialize as initializePricingModule,
384
- * } from "@medusajs/pricing"
385
- *
386
- * async function createPriceSet () {
387
- * const pricingService = await initializePricingModule()
388
- *
389
- * const priceSet = await pricingService.create(
211
+ * const priceSet = await pricingModuleService.create({
212
+ * rules: [],
213
+ * prices: [
390
214
  * {
391
- * rules: [],
392
- * prices: [
393
- * {
394
- * amount: 500,
395
- * currency_code: "USD",
396
- * min_quantity: 0,
397
- * max_quantity: 4,
398
- * rules: {},
399
- * },
400
- * {
401
- * amount: 400,
402
- * currency_code: "USD",
403
- * min_quantity: 5,
404
- * max_quantity: 10,
405
- * rules: {},
406
- * },
407
- * ],
215
+ * amount: 500,
216
+ * currency_code: "USD",
217
+ * min_quantity: 0,
218
+ * max_quantity: 4,
219
+ * rules: {},
408
220
  * },
409
- * )
410
- *
411
- * // do something with the price set or return it
412
- * }
221
+ * {
222
+ * amount: 400,
223
+ * currency_code: "USD",
224
+ * min_quantity: 5,
225
+ * max_quantity: 10,
226
+ * rules: {},
227
+ * },
228
+ * ],
229
+ * })
413
230
  * ```
414
231
  *
415
232
  * To create a price set and associate it with rule types:
416
233
  *
417
234
  * ```ts
418
- * import {
419
- * initialize as initializePricingModule,
420
- * } from "@medusajs/pricing"
421
- *
422
- * async function createPriceSet () {
423
- * const pricingService = await initializePricingModule()
424
- *
425
- * const priceSet = await pricingService.create(
235
+ * const priceSet = await pricingModuleService.create({
236
+ * rules: [
237
+ * { rule_attribute: "region_id" },
238
+ * { rule_attribute: "city" },
239
+ * ],
240
+ * prices: [
426
241
  * {
427
- * rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
428
- * prices: [
429
- * {
430
- * amount: 300,
431
- * currency_code: "EUR",
432
- * rules: {
433
- * region_id: "PL",
434
- * city: "krakow"
435
- * },
436
- * },
437
- * {
438
- * amount: 400,
439
- * currency_code: "EUR",
440
- * rules: {
441
- * region_id: "PL"
442
- * },
443
- * },
444
- * {
445
- * amount: 450,
446
- * currency_code: "EUR",
447
- * rules: {
448
- * city: "krakow"
449
- * },
450
- * }
451
- * ],
242
+ * amount: 300,
243
+ * currency_code: "EUR",
244
+ * rules: {
245
+ * region_id: "PL",
246
+ * city: "krakow",
247
+ * },
452
248
  * },
453
- * )
454
- *
455
- * // do something with the price set or return it
456
- * }
249
+ * {
250
+ * amount: 400,
251
+ * currency_code: "EUR",
252
+ * rules: {
253
+ * region_id: "PL",
254
+ * },
255
+ * },
256
+ * {
257
+ * amount: 450,
258
+ * currency_code: "EUR",
259
+ * rules: {
260
+ * city: "krakow",
261
+ * },
262
+ * },
263
+ * ],
264
+ * })
457
265
  * ```
458
266
  */
459
267
  create(data: CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
460
268
  /**
461
- * @overload
462
- *
463
269
  * This method is used to create multiple price sets.
464
270
  *
465
271
  * @param {CreatePriceSetDTO[]} data - The price sets to create.
@@ -467,78 +273,59 @@ export interface IPricingModuleService extends IModuleService {
467
273
  * @returns {Promise<PriceSetDTO[]>} The list of created price sets.
468
274
  *
469
275
  * @example
470
- * To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example:
471
- *
472
- * ```ts
473
- * import {
474
- * initialize as initializePricingModule,
475
- * } from "@medusajs/pricing"
476
- *
477
- * async function createPriceSets () {
478
- * const pricingService = await initializePricingModule()
479
- *
480
- * const priceSets = await pricingService.create([
481
- * {
482
- * rules: [],
483
- * prices: [
484
- * {
485
- * amount: 500,
486
- * currency_code: "USD",
487
- * rules: {},
276
+ * const priceSets = await pricingModuleService.create([
277
+ * // default price set
278
+ * {
279
+ * rules: [],
280
+ * prices: [
281
+ * {
282
+ * amount: 500,
283
+ * currency_code: "USD",
284
+ * min_quantity: 0,
285
+ * max_quantity: 4,
286
+ * rules: {},
287
+ * },
288
+ * {
289
+ * amount: 400,
290
+ * currency_code: "USD",
291
+ * min_quantity: 5,
292
+ * max_quantity: 10,
293
+ * rules: {},
294
+ * },
295
+ * ],
296
+ * },
297
+ * // price set with rules
298
+ * {
299
+ * rules: [
300
+ * { rule_attribute: "region_id" },
301
+ * { rule_attribute: "city" },
302
+ * ],
303
+ * prices: [
304
+ * {
305
+ * amount: 300,
306
+ * currency_code: "EUR",
307
+ * rules: {
308
+ * region_id: "PL",
309
+ * city: "krakow",
488
310
  * },
489
- * ],
490
- * },
491
- * ])
492
- *
493
- * // do something with the price sets or return them
494
- * }
495
- * ```
496
- *
497
- * To create price sets and associate them with rule types:
498
- *
499
- * ```ts
500
- * import {
501
- * initialize as initializePricingModule,
502
- * } from "@medusajs/pricing"
503
- *
504
- * async function createPriceSets () {
505
- * const pricingService = await initializePricingModule()
506
- *
507
- * const priceSets = await pricingService.create([
508
- * {
509
- * rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
510
- * prices: [
511
- * {
512
- * amount: 300,
513
- * currency_code: "EUR",
514
- * rules: {
515
- * region_id: "PL",
516
- * city: "krakow"
517
- * },
311
+ * },
312
+ * {
313
+ * amount: 400,
314
+ * currency_code: "EUR",
315
+ * rules: {
316
+ * region_id: "PL",
518
317
  * },
519
- * {
520
- * amount: 400,
521
- * currency_code: "EUR",
522
- * min_quantity: 0,
523
- * max_quantity: 4,
524
- * rules: {
525
- * region_id: "PL"
526
- * },
318
+ * },
319
+ * {
320
+ * amount: 450,
321
+ * currency_code: "EUR",
322
+ * rules: {
323
+ * city: "krakow",
527
324
  * },
528
- * {
529
- * amount: 450,
530
- * currency_code: "EUR",
531
- * rules: {
532
- * city: "krakow"
533
- * },
534
- * }
535
- * ],
536
- * },
537
- * ])
538
- *
539
- * // do something with the price sets or return them
540
- * }
541
- * ```
325
+ * },
326
+ * ],
327
+ * },
328
+ * ])
542
329
  */
543
330
  create(data: CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
544
331
  /**
@@ -549,21 +336,20 @@ export interface IPricingModuleService extends IModuleService {
549
336
  * @returns {Promise<PriceSetDTO[]>} The updated and created price sets.
550
337
  *
551
338
  * @example
552
- * import {
553
- * initialize as initializePricingModule,
554
- * } from "@medusajs/pricing"
555
- *
556
- * async function upsertPriceSet (title: string) {
557
- * const pricingModule = await initializePricingModule()
558
- *
559
- * const createdPriceSets = await pricingModule.upsert([
560
- * {
561
- * prices: [{amount: 100, currency_code: "USD"}]
562
- * }
563
- * ])
564
- *
565
- * // do something with the price sets or return them
566
- * }
339
+ * const priceSets = await pricingModuleService.upsert([
340
+ * {
341
+ * prices: [
342
+ * {
343
+ * amount: 100,
344
+ * currency_code: "USD",
345
+ * },
346
+ * ],
347
+ * },
348
+ * {
349
+ * id: "pset_123",
350
+ * rules: [{ rule_attribute: "region_id" }],
351
+ * },
352
+ * ])
567
353
  */
568
354
  upsert(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
569
355
  /**
@@ -574,21 +360,10 @@ export interface IPricingModuleService extends IModuleService {
574
360
  * @returns {Promise<PriceSetDTO>} The updated or created price set.
575
361
  *
576
362
  * @example
577
- * import {
578
- * initialize as initializePricingModule,
579
- * } from "@medusajs/pricing"
580
- *
581
- * async function upsertPriceSet (title: string) {
582
- * const pricingModule = await initializePricingModule()
583
- *
584
- * const createdPriceSet = await pricingModule.upsert(
585
- * {
586
- * prices: [{amount: 100, currency_code: "USD"}]
587
- * }
588
- * )
589
- *
590
- * // do something with the price set or return it
591
- * }
363
+ * const priceSet = await pricingModuleService.upsert({
364
+ * id: "pset_123",
365
+ * rules: [{ rule_attribute: "region_id" }],
366
+ * })
592
367
  */
593
368
  upsert(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
594
369
  /**
@@ -600,20 +375,12 @@ export interface IPricingModuleService extends IModuleService {
600
375
  * @returns {Promise<PriceSetDTO>} The updated price set.
601
376
  *
602
377
  * @example
603
- * import {
604
- * initialize as initializePricingModule,
605
- * } from "@medusajs/pricing"
606
- *
607
- * async function updatePriceSet (id: string, title: string) {
608
- * const pricingtModule = await initializePricingModule()
609
- *
610
- * const priceSet = await pricingtModule.update(id, {
611
- * prices: [{amount: 100, currency_code: "USD"}]
612
- * }
613
- * )
614
- *
615
- * // do something with the price set or return it
616
- * }
378
+ * const priceSet = await pricingModuleService.update(
379
+ * "pset_123",
380
+ * {
381
+ * rules: [{ rule_attribute: "region_id" }],
382
+ * }
383
+ * )
617
384
  */
618
385
  update(id: string, data: UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
619
386
  /**
@@ -625,20 +392,14 @@ export interface IPricingModuleService extends IModuleService {
625
392
  * @returns {Promise<PriceSetDTO[]>} The updated price sets.
626
393
  *
627
394
  * @example
628
- * import {
629
- * initialize as initializePricingModule,
630
- * } from "@medusajs/pricing"
631
- *
632
- * async function updatePriceSet(id: string, title: string) {
633
- * const pricingModule = await initializePricingModule()
634
- *
635
- * const priceSets = await pricingModule.update({id}, {
636
- * prices: [{amount: 100, currency_code: "USD"}]
637
- * }
638
- * )
639
- *
640
- * // do something with the price sets or return them
641
- * }
395
+ * const priceSets = await pricingModuleService.update(
396
+ * {
397
+ * id: ["pset_123", "pset_321"],
398
+ * },
399
+ * {
400
+ * rules: [{ rule_attribute: "region_id" }],
401
+ * }
402
+ * )
642
403
  */
643
404
  update(selector: FilterablePriceSetProps, data: UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
644
405
  /**
@@ -649,20 +410,12 @@ export interface IPricingModuleService extends IModuleService {
649
410
  * @returns {Promise<void>} Resolves when rules are successfully removed.
650
411
  *
651
412
  * @example
652
- * import {
653
- * initialize as initializePricingModule,
654
- * } from "@medusajs/pricing"
655
- *
656
- * async function removePriceSetRule (priceSetId: string, ruleAttributes: []) {
657
- * const pricingService = await initializePricingModule()
658
- *
659
- * await pricingService.removeRules([
660
- * {
661
- * id: priceSetId,
662
- * rules: ruleAttributes
663
- * },
664
- * ])
665
- * }
413
+ * await pricingModuleService.removeRules([
414
+ * {
415
+ * id: "pset_123",
416
+ * rules: ["region_id"],
417
+ * },
418
+ * ])
666
419
  */
667
420
  removeRules(data: RemovePriceSetRulesDTO[], sharedContext?: Context): Promise<void>;
668
421
  /**
@@ -673,15 +426,7 @@ export interface IPricingModuleService extends IModuleService {
673
426
  * @returns {Promise<void>} Resolves when the price sets are successfully deleted.
674
427
  *
675
428
  * @example
676
- * import {
677
- * initialize as initializePricingModule,
678
- * } from "@medusajs/pricing"
679
- *
680
- * async function removePriceSetRule (priceSetIds: string[]) {
681
- * const pricingService = await initializePricingModule()
682
- *
683
- * await pricingService.delete(priceSetIds)
684
- * }
429
+ * await pricingModuleService.delete(["pset_123", "pset_321"])
685
430
  */
686
431
  delete(ids: string[], sharedContext?: Context): Promise<void>;
687
432
  /**
@@ -696,70 +441,50 @@ export interface IPricingModuleService extends IModuleService {
696
441
  * To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
697
442
  *
698
443
  * ```ts
699
- * import {
700
- * initialize as initializePricingModule,
701
- * } from "@medusajs/pricing"
702
- *
703
- * async function addPricesToPriceSet (priceSetId: string) {
704
- * const pricingService = await initializePricingModule()
705
- *
706
- * const priceSet = await pricingService.addPrices({
707
- * priceSetId,
708
- * prices: [
709
- * {
710
- * amount: 500,
711
- * currency_code: "USD",
712
- * rules: {},
713
- * },
714
- * ],
715
- * })
716
- *
717
- * // do something with the price set or return it
718
- * }
444
+ * const priceSet = await pricingModuleService.addPrices({
445
+ * priceSetId: "pset_123",
446
+ * prices: [
447
+ * {
448
+ * amount: 500,
449
+ * currency_code: "USD",
450
+ * rules: {},
451
+ * },
452
+ * ],
453
+ * })
719
454
  * ```
720
455
  *
721
456
  * To add prices with rules:
722
457
  *
723
458
  * ```ts
724
- * import {
725
- * initialize as initializePricingModule,
726
- * } from "@medusajs/pricing"
727
- *
728
- * async function addPricesToPriceSet (priceSetId: string) {
729
- * const pricingService = await initializePricingModule()
730
- *
731
- * const priceSet = await pricingService.addPrices({
732
- * priceSetId,
733
- * prices: [
734
- * {
735
- * amount: 300,
736
- * currency_code: "EUR",
737
- * rules: {
738
- * region_id: "PL",
739
- * city: "krakow"
740
- * },
459
+ * const priceSet = await pricingModuleService.addPrices({
460
+ * priceSetId: "pset_123",
461
+ * prices: [
462
+ * {
463
+ * amount: 300,
464
+ * currency_code: "EUR",
465
+ * rules: {
466
+ * region_id: "PL",
467
+ * city: "krakow",
741
468
  * },
742
- * {
743
- * amount: 400,
744
- * currency_code: "EUR",
745
- * min_quantity: 0,
746
- * max_quantity: 4,
747
- * rules: {
748
- * region_id: "PL"
749
- * },
469
+ * },
470
+ * {
471
+ * amount: 400,
472
+ * currency_code: "EUR",
473
+ * min_quantity: 0,
474
+ * max_quantity: 4,
475
+ * rules: {
476
+ * region_id: "PL",
750
477
  * },
751
- * {
752
- * amount: 450,
753
- * currency_code: "EUR",
754
- * rules: {
755
- * city: "krakow"
756
- * },
757
- * }
758
- * ],
759
- * })
760
- *
761
- * // do something with the price set or return it
762
- * }
478
+ * },
479
+ * {
480
+ * amount: 450,
481
+ * currency_code: "EUR",
482
+ * rules: {
483
+ * city: "krakow",
484
+ * },
485
+ * },
486
+ * ],
487
+ * })
763
488
  * ```
764
489
  */
765
490
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PriceSetDTO>;
@@ -771,75 +496,34 @@ export interface IPricingModuleService extends IModuleService {
771
496
  * @returns {Promise<PriceSetDTO[]>} The list of the price sets that prices were added to.
772
497
  *
773
498
  * @example
774
- *
775
- * To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
776
- *
777
- * ```ts
778
- * import {
779
- * initialize as initializePricingModule,
780
- * } from "@medusajs/pricing"
781
- *
782
- * async function addPricesToPriceSet (priceSetId: string) {
783
- * const pricingService = await initializePricingModule()
784
- *
785
- * const priceSets = await pricingService.addPrices([{
786
- * priceSetId,
499
+ * const priceSets = await pricingModuleService.addPrices([
500
+ * {
501
+ * priceSetId: "pset_123",
787
502
  * prices: [
788
- * {
503
+ * // default price because it doesn't
504
+ * // have rules
505
+ * {
789
506
  * amount: 500,
790
507
  * currency_code: "USD",
791
508
  * rules: {},
792
509
  * },
793
510
  * ],
794
- * }])
795
- *
796
- * // do something with the price sets or return them
797
- * }
798
- * ```
799
- *
800
- * To add prices with rules:
801
- *
802
- * ```ts
803
- * import {
804
- * initialize as initializePricingModule,
805
- * } from "@medusajs/pricing"
806
- *
807
- * async function addPricesToPriceSet (priceSetId: string) {
808
- * const pricingService = await initializePricingModule()
809
- *
810
- * const priceSets = await pricingService.addPrices([{
811
- * priceSetId,
511
+ * },
512
+ * {
513
+ * priceSetId: "pset_321",
812
514
  * prices: [
515
+ * // prices with rules
813
516
  * {
814
517
  * amount: 300,
815
518
  * currency_code: "EUR",
816
519
  * rules: {
817
520
  * region_id: "PL",
818
- * city: "krakow"
521
+ * city: "krakow",
819
522
  * },
820
523
  * },
821
- * {
822
- * amount: 400,
823
- * currency_code: "EUR",
824
- * min_quantity: 0,
825
- * max_quantity: 4,
826
- * rules: {
827
- * region_id: "PL"
828
- * },
829
- * },
830
- * {
831
- * amount: 450,
832
- * currency_code: "EUR",
833
- * rules: {
834
- * city: "krakow"
835
- * },
836
- * }
837
524
  * ],
838
- * }])
839
- *
840
- * // do something with the price sets or return them
841
- * }
842
- * ```
525
+ * },
526
+ * ])
843
527
  */
844
528
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
845
529
  /**
@@ -850,22 +534,14 @@ export interface IPricingModuleService extends IModuleService {
850
534
  * @returns {Promise<PriceSetDTO>} The price set that the rules were added to.
851
535
  *
852
536
  * @example
853
- * import {
854
- * initialize as initializePricingModule,
855
- * } from "@medusajs/pricing"
856
- *
857
- * async function addRulesToPriceSet (priceSetId: string) {
858
- * const pricingService = await initializePricingModule()
859
- *
860
- * const priceSet = await pricingService.addRules({
861
- * priceSetId,
862
- * rules: [{
863
- * attribute: "region_id"
864
- * }]
865
- * })
866
- *
867
- * // do something with the price set or return it
868
- * }
537
+ * const priceSet = await pricingModuleService.addRules({
538
+ * priceSetId: "pset_123",
539
+ * rules: [
540
+ * {
541
+ * attribute: "region_id",
542
+ * },
543
+ * ],
544
+ * })
869
545
  */
870
546
  addRules(data: AddRulesDTO, sharedContext?: Context): Promise<PriceSetDTO>;
871
547
  /**
@@ -876,22 +552,24 @@ export interface IPricingModuleService extends IModuleService {
876
552
  * @returns {Promise<PriceSetDTO[]>} The list of the price sets that the rules were added to.
877
553
  *
878
554
  * @example
879
- * import {
880
- * initialize as initializePricingModule,
881
- * } from "@medusajs/pricing"
882
- *
883
- * async function addRulesToPriceSet (priceSetId: string) {
884
- * const pricingService = await initializePricingModule()
885
- *
886
- * const priceSets = await pricingService.addRules([{
887
- * priceSetId,
888
- * rules: [{
889
- * attribute: "region_id"
890
- * }]
891
- * }])
892
- *
893
- * // do something with the price sets or return them
894
- * }
555
+ * const priceSets = await pricingModuleService.addRules([
556
+ * {
557
+ * priceSetId: "pset_123",
558
+ * rules: [
559
+ * {
560
+ * attribute: "region_id",
561
+ * },
562
+ * ],
563
+ * },
564
+ * {
565
+ * priceSetId: "pset_321",
566
+ * rules: [
567
+ * {
568
+ * attribute: "customer_group_id",
569
+ * },
570
+ * ],
571
+ * },
572
+ * ])
895
573
  */
896
574
  addRules(data: AddRulesDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
897
575
  /**
@@ -908,35 +586,19 @@ export interface IPricingModuleService extends IModuleService {
908
586
  * A simple example that retrieves a rule type by its code:
909
587
  *
910
588
  * ```ts
911
- * import {
912
- * initialize as initializePricingModule,
913
- * } from "@medusajs/pricing"
914
- *
915
- * async function retrieveRuleType (ruleTypeId: string) {
916
- * const pricingService = await initializePricingModule()
917
- *
918
- * const ruleType = await pricingService.retrieveRuleType(ruleTypeId)
919
- *
920
- * // do something with the rule type or return it
921
- * }
589
+ * const ruleType =
590
+ * await pricingModuleService.retrieveRuleType("rul-typ_123")
922
591
  * ```
923
592
  *
924
- * To specify attributes that should be retrieved:
593
+ * To specify relations that should be retrieved:
925
594
  *
926
595
  * ```ts
927
- * import {
928
- * initialize as initializePricingModule,
929
- * } from "@medusajs/pricing"
930
- *
931
- * async function retrieveRuleType (ruleTypeId: string) {
932
- * const pricingService = await initializePricingModule()
933
- *
934
- * const ruleType = await pricingService.retrieveRuleType(ruleTypeId, {
935
- * select: ["name"]
936
- * })
937
- *
938
- * // do something with the rule type or return it
939
- * }
596
+ * const ruleType = await pricingModuleService.retrieveRuleType(
597
+ * "rul-typ_123",
598
+ * {
599
+ * relations: ["price_sets"],
600
+ * }
601
+ * )
940
602
  * ```
941
603
  */
942
604
  retrieveRuleType(id: string, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context): Promise<RuleTypeDTO>;
@@ -955,96 +617,37 @@ export interface IPricingModuleService extends IModuleService {
955
617
  * To retrieve a list of rule types using their IDs:
956
618
  *
957
619
  * ```ts
958
- * import {
959
- * initialize as initializePricingModule,
960
- * } from "@medusajs/pricing"
961
- *
962
- * async function retrieveRuleTypes (ruleTypeId: string) {
963
- * const pricingService = await initializePricingModule()
964
- *
965
- * const ruleTypes = await pricingService.listRuleTypes({
966
- * id: [
967
- * ruleTypeId
968
- * ]
969
- * })
970
- *
971
- * // do something with the rule types or return them
972
- * }
620
+ * const ruleTypes = await pricingModuleService.listRuleTypes({
621
+ * id: ["rul-typ_123", "rul-typ_321"],
622
+ * })
973
623
  * ```
974
624
  *
975
- * To specify attributes that should be retrieved within the rule types:
625
+ * To specify relations that should be retrieved:
976
626
  *
977
627
  * ```ts
978
- * import {
979
- * initialize as initializePricingModule,
980
- * } from "@medusajs/pricing"
981
- *
982
- * async function retrieveRuleTypes (ruleTypeId: string) {
983
- * const pricingService = await initializePricingModule()
984
- *
985
- * const ruleTypes = await pricingService.listRuleTypes({
986
- * id: [
987
- * ruleTypeId
988
- * ]
989
- * }, {
990
- * select: ["name"]
991
- * })
992
- *
993
- * // do something with the rule types or return them
994
- * }
628
+ * const ruleTypes = await pricingModuleService.listRuleTypes(
629
+ * {
630
+ * id: ["rul-typ_123", "rul-typ_321"],
631
+ * },
632
+ * {
633
+ * relations: ["price_sets"],
634
+ * }
635
+ * )
995
636
  * ```
996
637
  *
997
638
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
998
639
  *
999
640
  * ```ts
1000
- * import {
1001
- * initialize as initializePricingModule,
1002
- * } from "@medusajs/pricing"
1003
- *
1004
- * async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
1005
- * const pricingService = await initializePricingModule()
1006
- *
1007
- * const ruleTypes = await pricingService.listRuleTypes({
1008
- * id: [
1009
- * ruleTypeId
1010
- * ]
1011
- * }, {
1012
- * select: ["name"],
1013
- * skip,
1014
- * take
1015
- * })
1016
- *
1017
- * // do something with the rule types or return them
1018
- * }
1019
- * ```
1020
- *
1021
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1022
- *
1023
- * ```ts
1024
- * import {
1025
- * initialize as initializePricingModule,
1026
- * } from "@medusajs/pricing"
1027
- *
1028
- * async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
1029
- * const pricingService = await initializePricingModule()
1030
- *
1031
- * const ruleTypes = await pricingService.listRuleTypes({
1032
- * $and: [
1033
- * {
1034
- * id: ruleTypeId
1035
- * },
1036
- * {
1037
- * name
1038
- * }
1039
- * ]
1040
- * }, {
1041
- * select: ["name"],
1042
- * skip,
1043
- * take
1044
- * })
1045
- *
1046
- * // do something with the rule types or return them
1047
- * }
641
+ * const ruleTypes = await pricingModuleService.listRuleTypes(
642
+ * {
643
+ * id: ["rul-typ_123", "rul-typ_321"],
644
+ * },
645
+ * {
646
+ * relations: ["price_sets"],
647
+ * take: 20,
648
+ * skip: 2,
649
+ * }
650
+ * )
1048
651
  * ```
1049
652
  */
1050
653
  listRuleTypes(filters?: FilterableRuleTypeProps, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context): Promise<RuleTypeDTO[]>;
@@ -1063,96 +666,40 @@ export interface IPricingModuleService extends IModuleService {
1063
666
  * To retrieve a list of rule types using their IDs:
1064
667
  *
1065
668
  * ```ts
1066
- * import {
1067
- * initialize as initializePricingModule,
1068
- * } from "@medusajs/pricing"
1069
- *
1070
- * async function retrieveRuleTypes (ruleTypeId: string) {
1071
- * const pricingService = await initializePricingModule()
1072
- *
1073
- * const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
1074
- * id: [
1075
- * ruleTypeId
1076
- * ]
669
+ * const [ruleTypes, count] =
670
+ * await pricingModuleService.listAndCountRuleTypes({
671
+ * id: ["rul-typ_123", "rul-typ_321"],
1077
672
  * })
1078
- *
1079
- * // do something with the rule types or return them
1080
- * }
1081
673
  * ```
1082
674
  *
1083
675
  * To specify attributes that should be retrieved within the rule types:
1084
676
  *
1085
677
  * ```ts
1086
- * import {
1087
- * initialize as initializePricingModule,
1088
- * } from "@medusajs/pricing"
1089
- *
1090
- * async function retrieveRuleTypes (ruleTypeId: string) {
1091
- * const pricingService = await initializePricingModule()
1092
- *
1093
- * const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
1094
- * id: [
1095
- * ruleTypeId
1096
- * ]
1097
- * }, {
1098
- * select: ["name"]
1099
- * })
1100
- *
1101
- * // do something with the rule types or return them
1102
- * }
678
+ * const [ruleTypes, count] =
679
+ * await pricingModuleService.listAndCountRuleTypes(
680
+ * {
681
+ * id: ["rul-typ_123", "rul-typ_321"],
682
+ * },
683
+ * {
684
+ * relations: ["price_sets"],
685
+ * }
686
+ * )
1103
687
  * ```
1104
688
  *
1105
689
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1106
690
  *
1107
691
  * ```ts
1108
- * import {
1109
- * initialize as initializePricingModule,
1110
- * } from "@medusajs/pricing"
1111
- *
1112
- * async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
1113
- * const pricingService = await initializePricingModule()
1114
- *
1115
- * const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
1116
- * id: [
1117
- * ruleTypeId
1118
- * ]
1119
- * }, {
1120
- * select: ["name"],
1121
- * skip,
1122
- * take
1123
- * })
1124
- *
1125
- * // do something with the rule types or return them
1126
- * }
1127
- * ```
1128
- *
1129
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1130
- *
1131
- * ```ts
1132
- * import {
1133
- * initialize as initializePricingModule,
1134
- * } from "@medusajs/pricing"
1135
- *
1136
- * async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
1137
- * const pricingService = await initializePricingModule()
1138
- *
1139
- * const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
1140
- * $and: [
1141
- * {
1142
- * id: ruleTypeId
1143
- * },
1144
- * {
1145
- * name
1146
- * }
1147
- * ]
1148
- * }, {
1149
- * select: ["name"],
1150
- * skip,
1151
- * take
1152
- * })
1153
- *
1154
- * // do something with the rule types or return them
1155
- * }
692
+ * const [ruleTypes, count] =
693
+ * await pricingModuleService.listAndCountRuleTypes(
694
+ * {
695
+ * id: ["rul-typ_123", "rul-typ_321"],
696
+ * },
697
+ * {
698
+ * relations: ["price_sets"],
699
+ * take: 20,
700
+ * skip: 2,
701
+ * }
702
+ * )
1156
703
  * ```
1157
704
  */
1158
705
  listAndCountRuleTypes(filters?: FilterableRuleTypeProps, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context): Promise<[RuleTypeDTO[], number]>;
@@ -1164,22 +711,16 @@ export interface IPricingModuleService extends IModuleService {
1164
711
  * @returns {Promise<RuleTypeDTO[]>} The list of created rule types.
1165
712
  *
1166
713
  * @example
1167
- * import {
1168
- * initialize as initializePricingModule,
1169
- * } from "@medusajs/pricing"
1170
- *
1171
- * async function createRuleTypes () {
1172
- * const pricingService = await initializePricingModule()
1173
- *
1174
- * const ruleTypes = await pricingService.createRuleTypes([
1175
- * {
1176
- * name: "Region",
1177
- * rule_attribute: "region_id"
1178
- * }
1179
- * ])
1180
- *
1181
- * // do something with the rule types or return them
1182
- * }
714
+ * const ruleTypes = await pricingModuleService.createRuleTypes([
715
+ * {
716
+ * name: "Region",
717
+ * rule_attribute: "region_id",
718
+ * },
719
+ * {
720
+ * name: "Customer Group",
721
+ * rule_attribute: "customer_group_id",
722
+ * },
723
+ * ])
1183
724
  */
1184
725
  createRuleTypes(data: CreateRuleTypeDTO[], sharedContext?: Context): Promise<RuleTypeDTO[]>;
1185
726
  /**
@@ -1190,22 +731,16 @@ export interface IPricingModuleService extends IModuleService {
1190
731
  * @returns {Promise<RuleTypeDTO[]>} The list of updated rule types.
1191
732
  *
1192
733
  * @example
1193
- * import {
1194
- * initialize as initializePricingModule,
1195
- * } from "@medusajs/pricing"
1196
- *
1197
- * async function updateRuleTypes (ruleTypeId: string) {
1198
- * const pricingService = await initializePricingModule()
1199
- *
1200
- * const ruleTypes = await pricingService.updateRuleTypes([
1201
- * {
1202
- * id: ruleTypeId,
1203
- * name: "Region",
1204
- * }
1205
- * ])
1206
- *
1207
- * // do something with the rule types or return them
1208
- * }
734
+ * const ruleTypes = await pricingModuleService.updateRuleTypes([
735
+ * {
736
+ * id: "rul-typ_123",
737
+ * name: "Region",
738
+ * },
739
+ * {
740
+ * id: "rul-typ_321",
741
+ * name: "Customer Group",
742
+ * },
743
+ * ])
1209
744
  */
1210
745
  updateRuleTypes(data: UpdateRuleTypeDTO[], sharedContext?: Context): Promise<RuleTypeDTO[]>;
1211
746
  /**
@@ -1216,15 +751,10 @@ export interface IPricingModuleService extends IModuleService {
1216
751
  * @returns {Promise<void>} Resolves once the rule types are deleted.
1217
752
  *
1218
753
  * @example
1219
- * import {
1220
- * initialize as initializePricingModule,
1221
- * } from "@medusajs/pricing"
1222
- *
1223
- * async function deleteRuleTypes (ruleTypeId: string) {
1224
- * const pricingService = await initializePricingModule()
1225
- *
1226
- * await pricingService.deleteRuleTypes([ruleTypeId])
1227
- * }
754
+ * const ruleTypes = await pricingModuleService.deleteRuleTypes([
755
+ * "rul-typ_123",
756
+ * "rul-typ_321",
757
+ * ])
1228
758
  */
1229
759
  deleteRuleTypes(ruleTypeIds: string[], sharedContext?: Context): Promise<void>;
1230
760
  /**
@@ -1242,94 +772,79 @@ export interface IPricingModuleService extends IModuleService {
1242
772
  * To retrieve a list of prices using their IDs:
1243
773
  *
1244
774
  * ```ts
1245
- * import {
1246
- * initialize as initializePricingModule,
1247
- * } from "@medusajs/pricing"
1248
- *
1249
- * async function retrievePrices (id: string) {
1250
- * const pricingService = await initializePricingModule()
1251
- *
1252
- * const prices = await pricingService.listPrices({
1253
- * id: [id]
1254
- * })
1255
- *
1256
- * // do something with the prices or return them
1257
- * }
775
+ * const prices = await pricingModuleService.listPrices({
776
+ * id: ["price_123", "price_321"],
777
+ * })
1258
778
  * ```
1259
779
  *
1260
780
  * To specify relations that should be retrieved within the prices:
1261
781
  *
1262
782
  * ```ts
1263
- * import {
1264
- * initialize as initializePricingModule,
1265
- * } from "@medusajs/pricing"
1266
- *
1267
- * async function retrievePrices (id: string) {
1268
- * const pricingService = await initializePricingModule()
1269
- *
1270
- * const prices = await pricingService.listPrices({
1271
- * id: [id]
1272
- * }, {
1273
- * relations: ["price_rules"]
1274
- * })
1275
- *
1276
- * // do something with the prices or return them
1277
- * }
783
+ * const prices = await pricingModuleService.listPrices(
784
+ * {
785
+ * id: ["price_123", "price_321"],
786
+ * },
787
+ * {
788
+ * relations: ["price_rules"],
789
+ * }
790
+ * )
1278
791
  * ```
1279
792
  *
1280
793
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1281
794
  *
1282
795
  * ```ts
1283
- * import {
1284
- * initialize as initializePricingModule,
1285
- * } from "@medusajs/pricing"
1286
- *
1287
- * async function retrievePrices (id: string, skip: number, take: number) {
1288
- * const pricingService = await initializePricingModule()
1289
- *
1290
- * const prices = await pricingService.listPrices({
1291
- * id: [id]
1292
- * }, {
796
+ * const prices = await pricingModuleService.listPrices(
797
+ * {
798
+ * id: ["price_123", "price_321"],
799
+ * },
800
+ * {
1293
801
  * relations: ["price_rules"],
1294
- * skip,
1295
- * take
1296
- * })
1297
- *
1298
- * // do something with the prices or return them
1299
- * }
802
+ * take: 20,
803
+ * skip: 2,
804
+ * }
805
+ * )
1300
806
  * ```
807
+ */
808
+ listPrices(filters?: FilterablePriceProps, config?: FindConfig<PriceDTO>, sharedContext?: Context): Promise<PriceDTO[]>;
809
+ /**
810
+ * This method soft deletes prices by their IDs.
1301
811
  *
1302
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
812
+ * @param {string[]} priceIds - The IDs of the prices.
813
+ * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
814
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
815
+ * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated price rules.
816
+ * The object's keys are the ID attribute names of the price entity's relations, such as `price_rule_id`, and its value is an array of strings, each being the ID of a record associated
817
+ * with the price through this relation, such as the IDs of associated price rule.
1303
818
  *
1304
- * ```ts
1305
- * import {
1306
- * initialize as initializePricingModule,
1307
- * } from "@medusajs/pricing"
819
+ * If there are no related records, the promise resolves to `void`.
1308
820
  *
1309
- * async function retrievePrices (ids: string[], titles: string[], skip: number, take: number) {
1310
- * const pricingService = await initializePricingModule()
821
+ * @example
822
+ * await pricingModuleService.softDeletePrices([
823
+ * "price_123",
824
+ * "price_321",
825
+ * ])
826
+ */
827
+ softDeletePrices<TReturnableLinkableKeys extends string = string>(priceIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
828
+ /**
829
+ * This method restores soft deleted prices by their IDs.
1311
830
  *
1312
- * const prices = await pricingService.listPrices({
1313
- * $and: [
1314
- * {
1315
- * id: ids
1316
- * },
1317
- * {
1318
- * title: titles
1319
- * }
1320
- * ]
1321
- * }, {
1322
- * relations: ["price_rules"],
1323
- * skip,
1324
- * take
1325
- * })
831
+ * @param {string[]} priceIds - The IDs of the prices.
832
+ * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore along with each of the prices. You can pass to its `returnLinkableKeys`
833
+ * property any of the price's relation attribute names, such as price_rules`.
834
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
835
+ * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were restored, such as the ID of associated price rules.
836
+ * The object's keys are the ID attribute names of the prices entity's relations, such as `price_rule_id`,
837
+ * and its value is an array of strings, each being the ID of the record associated with the prices through this relation,
838
+ * such as the IDs of associated price rules.
1326
839
  *
1327
- * // do something with the prices or return them
1328
- * }
1329
- * ```
840
+ * If there are no related records restored, the promise resolves to `void`.
841
+ *
842
+ * @example
843
+ * await pricingModuleService.restorePrices([
844
+ * "price_123",
845
+ * "price_321",
846
+ * ])
1330
847
  */
1331
- listPrices(filters?: FilterablePriceProps, config?: FindConfig<PriceDTO>, sharedContext?: Context): Promise<PriceDTO[]>;
1332
- softDeletePrices<TReturnableLinkableKeys extends string = string>(priceIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
1333
848
  restorePrices<TReturnableLinkableKeys extends string = string>(priceIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
1334
849
  /**
1335
850
  * This method is used to retrieve a paginated list of prices along with the total count of
@@ -1347,90 +862,39 @@ export interface IPricingModuleService extends IModuleService {
1347
862
  * To retrieve a list of prices using their IDs:
1348
863
  *
1349
864
  * ```ts
1350
- * import {
1351
- * initialize as initializePricingModule,
1352
- * } from "@medusajs/pricing"
1353
- *
1354
- * async function retrievePrices (id: string) {
1355
- * const pricingService = await initializePricingModule()
1356
- *
1357
- * const [prices, count] = await pricingService.listAndCountPrices({
1358
- * id: [id]
1359
- * })
1360
- *
1361
- * // do something with the prices or return them
1362
- * }
865
+ * const [prices, count] = await pricingModuleService.listPrices(
866
+ * {
867
+ * id: ["price_123", "price_321"],
868
+ * }
869
+ * )
1363
870
  * ```
1364
871
  *
1365
872
  * To specify relations that should be retrieved within the prices:
1366
873
  *
1367
874
  * ```ts
1368
- * import {
1369
- * initialize as initializePricingModule,
1370
- * } from "@medusajs/pricing"
1371
- *
1372
- * async function retrievePrices (id: string) {
1373
- * const pricingService = await initializePricingModule()
1374
- *
1375
- * const [prices, count] = await pricingService.listAndCountPrices({
1376
- * id: [id]
1377
- * }, {
875
+ * const [prices, count] = await pricingModuleService.listPrices(
876
+ * {
877
+ * id: ["price_123", "price_321"],
878
+ * },
879
+ * {
1378
880
  * relations: ["price_rules"],
1379
- * })
1380
- *
1381
- * // do something with the prices or return them
1382
- * }
881
+ * }
882
+ * )
1383
883
  * ```
1384
884
  *
1385
885
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1386
886
  *
1387
887
  * ```ts
1388
- * import {
1389
- * initialize as initializePricingModule,
1390
- * } from "@medusajs/pricing"
1391
- *
1392
- * async function retrievePrices (id: string, skip: number, take: number) {
1393
- * const pricingService = await initializePricingModule()
1394
- *
1395
- * const [prices, count] = await pricingService.listAndCountPrices({
1396
- * id: [id]
1397
- * }, {
1398
- * relations: ["price_rules"],
1399
- * skip,
1400
- * take
1401
- * })
1402
- *
1403
- * // do something with the prices or return them
1404
- * }
1405
- * ```
1406
- *
1407
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1408
- *
1409
- * ```ts
1410
- * import {
1411
- * initialize as initializePricingModule,
1412
- * } from "@medusajs/pricing"
1413
- *
1414
- * async function retrievePrices (ids: string[], titles: string[], skip: number, take: number) {
1415
- * const pricingService = await initializePricingModule()
1416
- *
1417
- * const [prices, count] = await pricingService.listAndCountPrices({
1418
- * $and: [
1419
- * {
1420
- * id: ids
1421
- * },
1422
- * {
1423
- * title: titles
1424
- * }
1425
- * ]
1426
- * }, {
888
+ * const [prices, count] = await pricingModuleService.listPrices(
889
+ * {
890
+ * id: ["price_123", "price_321"],
891
+ * },
892
+ * {
1427
893
  * relations: ["price_rules"],
1428
- * skip,
1429
- * take
1430
- * })
1431
- *
1432
- * // do something with the prices or return them
1433
- * }
894
+ * take: 20,
895
+ * skip: 2,
896
+ * }
897
+ * )
1434
898
  * ```
1435
899
  */
1436
900
  listAndCountPrices(filters?: FilterablePriceProps, config?: FindConfig<PriceDTO>, sharedContext?: Context): Promise<[PriceDTO[], number]>;
@@ -1448,35 +912,17 @@ export interface IPricingModuleService extends IModuleService {
1448
912
  * A simple example that retrieves a price rule by its ID:
1449
913
  *
1450
914
  * ```ts
1451
- * import {
1452
- * initialize as initializePricingModule,
1453
- * } from "@medusajs/pricing"
1454
- *
1455
- * async function retrievePriceRule (id: string) {
1456
- * const pricingService = await initializePricingModule()
1457
- *
1458
- * const priceRule = await pricingService.retrievePriceRule(id)
1459
- *
1460
- * // do something with the price rule or return it
1461
- * }
915
+ * const priceRule =
916
+ * await pricingModuleService.retrievePriceRule("prule_123")
1462
917
  * ```
1463
918
  *
1464
919
  * To specify relations that should be retrieved:
1465
920
  *
1466
921
  * ```ts
1467
- * import {
1468
- * initialize as initializePricingModule,
1469
- * } from "@medusajs/pricing"
1470
- *
1471
- * async function retrievePriceRule (id: string) {
1472
- * const pricingService = await initializePricingModule()
1473
- *
1474
- * const priceRule = await pricingService.retrievePriceRule(id, {
1475
- * relations: ["price_set"]
922
+ * const priceRule =
923
+ * await pricingModuleService.retrievePriceRule("prule_123", {
924
+ * relations: ["price_set"],
1476
925
  * })
1477
- *
1478
- * // do something with the price rule or return it
1479
- * }
1480
926
  * ```
1481
927
  */
1482
928
  retrievePriceRule(id: string, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context): Promise<PriceRuleDTO>;
@@ -1495,90 +941,37 @@ export interface IPricingModuleService extends IModuleService {
1495
941
  * To retrieve a list of price rules using their IDs:
1496
942
  *
1497
943
  * ```ts
1498
- * import {
1499
- * initialize as initializePricingModule,
1500
- * } from "@medusajs/pricing"
1501
- *
1502
- * async function retrievePriceRules (id: string) {
1503
- * const pricingService = await initializePricingModule()
1504
- *
1505
- * const priceRules = await pricingService.listPriceRules({
1506
- * id: [id]
1507
- * })
1508
- *
1509
- * // do something with the price rules or return them
1510
- * }
944
+ * const priceRules = await pricingModuleService.listPriceRules({
945
+ * id: ["prule_123", "prule_321"],
946
+ * })
1511
947
  * ```
1512
948
  *
1513
949
  * To specify relations that should be retrieved within the price rules:
1514
950
  *
1515
951
  * ```ts
1516
- * import {
1517
- * initialize as initializePricingModule,
1518
- * } from "@medusajs/pricing"
1519
- *
1520
- * async function retrievePriceRules (id: string) {
1521
- * const pricingService = await initializePricingModule()
1522
- *
1523
- * const priceRules = await pricingService.listPriceRules({
1524
- * id: [id],
1525
- * }, {
1526
- * relations: ["price_set"]
1527
- * })
1528
- *
1529
- * // do something with the price rules or return them
1530
- * }
952
+ * const priceRules = await pricingModuleService.listPriceRules(
953
+ * {
954
+ * id: ["prule_123", "prule_321"],
955
+ * },
956
+ * {
957
+ * relations: ["price_set"],
958
+ * }
959
+ * )
1531
960
  * ```
1532
961
  *
1533
962
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1534
963
  *
1535
964
  * ```ts
1536
- * import {
1537
- * initialize as initializePricingModule,
1538
- * } from "@medusajs/pricing"
1539
- *
1540
- * async function retrievePriceRules (id: string, skip: number, take: number) {
1541
- * const pricingService = await initializePricingModule()
1542
- *
1543
- * const priceRules = await pricingService.listPriceRules({
1544
- * id: [id],
1545
- * }, {
965
+ * const priceRules = await pricingModuleService.listPriceRules(
966
+ * {
967
+ * id: ["prule_123", "prule_321"],
968
+ * },
969
+ * {
1546
970
  * relations: ["price_set"],
1547
- * skip,
1548
- * take
1549
- * })
1550
- *
1551
- * // do something with the price rules or return them
1552
- * }
1553
- * ```
1554
- *
1555
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1556
- *
1557
- * ```ts
1558
- * import {
1559
- * initialize as initializePricingModule,
1560
- * } from "@medusajs/pricing"
1561
- *
1562
- * async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
1563
- * const pricingService = await initializePricingModule()
1564
- *
1565
- * const priceRules = await pricingService.listPriceRules({
1566
- * $and: [
1567
- * {
1568
- * id: ids
1569
- * },
1570
- * {
1571
- * name
1572
- * }
1573
- * ]
1574
- * }, {
1575
- * relations: ["price_set"],
1576
- * skip,
1577
- * take
1578
- * })
1579
- *
1580
- * // do something with the price rules or return them
1581
- * }
971
+ * take: 20,
972
+ * skip: 2,
973
+ * }
974
+ * )
1582
975
  * ```
1583
976
  */
1584
977
  listPriceRules(filters?: FilterablePriceRuleProps, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context): Promise<PriceRuleDTO[]>;
@@ -1590,97 +983,47 @@ export interface IPricingModuleService extends IModuleService {
1590
983
  * The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the
1591
984
  * attributes or relations associated with a price rule.
1592
985
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1593
- * @returns {Promise<PriceRuleDTO[]>} The list of price rules along with their total count.
1594
- *
1595
- * @example
1596
- *
1597
- * To retrieve a list of price rules using their IDs:
1598
- *
1599
- * ```ts
1600
- * import {
1601
- * initialize as initializePricingModule,
1602
- * } from "@medusajs/pricing"
1603
- *
1604
- * async function retrievePriceRules (id: string) {
1605
- * const pricingService = await initializePricingModule()
1606
- *
1607
- * const [priceRules, count] = await pricingService.listAndCountPriceRules({
1608
- * id: [id]
1609
- * })
1610
- *
1611
- * // do something with the price rules or return them
1612
- * }
1613
- * ```
1614
- *
1615
- * To specify relations that should be retrieved within the price rules:
1616
- *
1617
- * ```ts
1618
- * import {
1619
- * initialize as initializePricingModule,
1620
- * } from "@medusajs/pricing"
1621
- *
1622
- * async function retrievePriceRules (id: string) {
1623
- * const pricingService = await initializePricingModule()
1624
- *
1625
- * const [priceRules, count] = await pricingService.listAndCountPriceRules({
1626
- * id: [id],
1627
- * }, {
1628
- * relations: ["price_set"]
1629
- * })
1630
- *
1631
- * // do something with the price rules or return them
1632
- * }
1633
- * ```
1634
- *
1635
- * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
986
+ * @returns {Promise<PriceRuleDTO[]>} The list of price rules along with their total count.
1636
987
  *
1637
- * ```ts
1638
- * import {
1639
- * initialize as initializePricingModule,
1640
- * } from "@medusajs/pricing"
988
+ * @example
1641
989
  *
1642
- * async function retrievePriceRules (id: string, skip: number, take: number) {
1643
- * const pricingService = await initializePricingModule()
990
+ * To retrieve a list of price rules using their IDs:
1644
991
  *
1645
- * const [priceRules, count] = await pricingService.listAndCountPriceRules({
1646
- * id: [id],
1647
- * }, {
1648
- * relations: ["price_set"],
1649
- * skip,
1650
- * take
992
+ * ```ts
993
+ * const [priceRules, count] =
994
+ * await pricingModuleService.listAndCountPriceListRules({
995
+ * id: ["prule_123", "prule_321"],
1651
996
  * })
1652
- *
1653
- * // do something with the price rules or return them
1654
- * }
1655
997
  * ```
1656
998
  *
1657
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
999
+ * To specify relations that should be retrieved within the price rules:
1658
1000
  *
1659
1001
  * ```ts
1660
- * import {
1661
- * initialize as initializePricingModule,
1662
- * } from "@medusajs/pricing"
1663
- *
1664
- * async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
1665
- * const pricingService = await initializePricingModule()
1002
+ * const [priceRules, count] =
1003
+ * await pricingModuleService.listAndCountPriceListRules(
1004
+ * {
1005
+ * id: ["prule_123", "prule_321"],
1006
+ * },
1007
+ * {
1008
+ * relations: ["price_set"],
1009
+ * }
1010
+ * )
1011
+ * ```
1666
1012
  *
1667
- * const [priceRules, count] = await pricingService.listAndCountPriceRules({
1668
- * $and: [
1669
- * {
1670
- * id: ids
1671
- * },
1672
- * {
1673
- * name
1674
- * }
1675
- * ]
1676
- * }, {
1677
- * relations: ["price_set"],
1678
- * skip,
1679
- * take
1680
- * })
1013
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1681
1014
  *
1682
- * // do something with the price rules or return them
1683
- * }
1015
+ * ```ts
1016
+ * const [priceRules, count] =
1017
+ * await pricingModuleService.listAndCountPriceListRules(
1018
+ * {
1019
+ * id: ["prule_123", "prule_321"],
1020
+ * },
1021
+ * {
1022
+ * relations: ["price_set"],
1023
+ * take: 20,
1024
+ * skip: 2,
1025
+ * }
1026
+ * )
1684
1027
  * ```
1685
1028
  */
1686
1029
  listAndCountPriceRules(filters?: FilterablePriceRuleProps, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context): Promise<[PriceRuleDTO[], number]>;
@@ -1692,33 +1035,14 @@ export interface IPricingModuleService extends IModuleService {
1692
1035
  * @returns {Promise<PriceRuleDTO[]>} The list of created price rules.
1693
1036
  *
1694
1037
  * @example
1695
- * import {
1696
- * initialize as initializePricingModule,
1697
- * } from "@medusajs/pricing"
1698
- *
1699
- * async function createPriceRules (
1700
- * id: string,
1701
- * priceSetId: string,
1702
- * ruleTypeId: string,
1703
- * value: string,
1704
- * priceId: string,
1705
- * priceListId: string
1706
- * ) {
1707
- * const pricingService = await initializePricingModule()
1708
- *
1709
- * const priceRules = await pricingService.createPriceRules([
1038
+ * const priceRules =
1039
+ * await pricingModuleService.createPriceRules([
1710
1040
  * {
1711
- * id,
1712
- * price_set_id: priceSetId,
1713
- * rule_type_id: ruleTypeId,
1714
- * value,
1715
- * price_id: priceId,
1716
- * price_list_id: priceListId
1717
- * }
1041
+ * value: "VIP",
1042
+ * rule_type_id: "rul-typ_123",
1043
+ * price_set_id: "pset_123",
1044
+ * },
1718
1045
  * ])
1719
- *
1720
- * // do something with the price rules or return them
1721
- * }
1722
1046
  */
1723
1047
  createPriceRules(data: CreatePriceRuleDTO[], sharedContext?: Context): Promise<PriceRuleDTO[]>;
1724
1048
  /**
@@ -1729,25 +1053,13 @@ export interface IPricingModuleService extends IModuleService {
1729
1053
  * @returns {Promise<PriceRuleDTO[]>} The list of updated price rules.
1730
1054
  *
1731
1055
  * @example
1732
- * import {
1733
- * initialize as initializePricingModule,
1734
- * } from "@medusajs/pricing"
1735
- *
1736
- * async function updatePriceRules (
1737
- * id: string,
1738
- * priceSetId: string,
1739
- * ) {
1740
- * const pricingService = await initializePricingModule()
1741
- *
1742
- * const priceRules = await pricingService.updatePriceRules([
1056
+ * const priceRules =
1057
+ * await pricingModuleService.updatePriceRules([
1743
1058
  * {
1744
- * id,
1745
- * price_set_id: priceSetId,
1746
- * }
1059
+ * id: "prule_123",
1060
+ * price_id: "price_123",
1061
+ * },
1747
1062
  * ])
1748
- *
1749
- * // do something with the price rules or return them
1750
- * }
1751
1063
  */
1752
1064
  updatePriceRules(data: UpdatePriceRuleDTO[], sharedContext?: Context): Promise<PriceRuleDTO[]>;
1753
1065
  /**
@@ -1758,17 +1070,10 @@ export interface IPricingModuleService extends IModuleService {
1758
1070
  * @returns {Promise<void>} Resolves once the price rules are deleted.
1759
1071
  *
1760
1072
  * @example
1761
- * import {
1762
- * initialize as initializePricingModule,
1763
- * } from "@medusajs/pricing"
1764
- *
1765
- * async function deletePriceRules (
1766
- * id: string,
1767
- * ) {
1768
- * const pricingService = await initializePricingModule()
1769
- *
1770
- * await pricingService.deletePriceRules([id])
1771
- * }
1073
+ * await pricingModuleService.deletePriceRules([
1074
+ * "prule_123",
1075
+ * "prule_321",
1076
+ * ])
1772
1077
  */
1773
1078
  deletePriceRules(priceRuleIds: string[], sharedContext?: Context): Promise<void>;
1774
1079
  /**
@@ -1785,40 +1090,17 @@ export interface IPricingModuleService extends IModuleService {
1785
1090
  * A simple example that retrieves a price list by its ID:
1786
1091
  *
1787
1092
  * ```ts
1788
- * import {
1789
- * initialize as initializePricingModule,
1790
- * } from "@medusajs/pricing"
1791
- *
1792
- * async function retrievePriceList (priceListId: string) {
1793
- * const pricingService = await initializePricingModule()
1794
- *
1795
- * const priceList = await pricingService.retrievePriceList(
1796
- * priceListId
1797
- * )
1798
- *
1799
- * // do something with the price list or return it
1800
- * }
1093
+ * const priceList =
1094
+ * await pricingModuleService.retrievePriceList("plist_123")
1801
1095
  * ```
1802
1096
  *
1803
1097
  * To specify relations that should be retrieved:
1804
1098
  *
1805
1099
  * ```ts
1806
- * import {
1807
- * initialize as initializePricingModule,
1808
- * } from "@medusajs/pricing"
1809
- *
1810
- * async function retrievePriceList (priceListId: string) {
1811
- * const pricingService = await initializePricingModule()
1812
- *
1813
- * const priceList = await pricingService.retrievePriceList(
1814
- * priceListId,
1815
- * {
1816
- * relations: ["prices"]
1817
- * }
1818
- * )
1819
- *
1820
- * // do something with the price list or return it
1821
- * }
1100
+ * const priceList =
1101
+ * await pricingModuleService.retrievePriceList("plist_123", {
1102
+ * relations: ["prices"],
1103
+ * })
1822
1104
  * ```
1823
1105
  */
1824
1106
  retrievePriceList(id: string, config?: FindConfig<PriceListDTO>, sharedContext?: Context): Promise<PriceListDTO>;
@@ -1837,101 +1119,37 @@ export interface IPricingModuleService extends IModuleService {
1837
1119
  * To retrieve a list of price lists using their IDs:
1838
1120
  *
1839
1121
  * ```ts
1840
- * import {
1841
- * initialize as initializePricingModule,
1842
- * } from "@medusajs/pricing"
1843
- *
1844
- * async function listPriceLists (priceListIds: string[]) {
1845
- * const pricingService = await initializePricingModule()
1846
- *
1847
- * const priceLists = await pricingService.listPriceLists(
1848
- * {
1849
- * id: priceListIds
1850
- * },
1851
- * )
1852
- *
1853
- * // do something with the price lists or return them
1854
- * }
1122
+ * const priceLists = await pricingModuleService.listPriceLists({
1123
+ * id: ["plist_123", "plist_321"],
1124
+ * })
1855
1125
  * ```
1856
1126
  *
1857
1127
  * To specify relations that should be retrieved within the price lists:
1858
1128
  *
1859
1129
  * ```ts
1860
- * import {
1861
- * initialize as initializePricingModule,
1862
- * } from "@medusajs/pricing"
1863
- *
1864
- * async function listPriceLists (priceListIds: string[]) {
1865
- * const pricingService = await initializePricingModule()
1866
- *
1867
- * const priceLists = await pricingService.listPriceLists(
1868
- * {
1869
- * id: priceListIds
1870
- * },
1871
- * {
1872
- * relations: ["prices"]
1873
- * }
1874
- * )
1875
- *
1876
- * // do something with the price lists or return them
1877
- * }
1130
+ * const priceLists = await pricingModuleService.listPriceLists(
1131
+ * {
1132
+ * id: ["plist_123", "plist_321"],
1133
+ * },
1134
+ * {
1135
+ * relations: ["prices"],
1136
+ * }
1137
+ * )
1878
1138
  * ```
1879
1139
  *
1880
1140
  * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1881
1141
  *
1882
1142
  * ```ts
1883
- * import {
1884
- * initialize as initializePricingModule,
1885
- * } from "@medusajs/pricing"
1886
- *
1887
- * async function listPriceLists (priceListIds: string[], skip: number, take: number) {
1888
- * const pricingService = await initializePricingModule()
1889
- *
1890
- * const priceLists = await pricingService.listPriceLists(
1891
- * {
1892
- * id: priceListIds
1893
- * },
1894
- * {
1895
- * relations: ["prices"],
1896
- * skip,
1897
- * take
1898
- * }
1899
- * )
1900
- *
1901
- * // do something with the price lists or return them
1902
- * }
1903
- * ```
1904
- *
1905
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1906
- *
1907
- * ```ts
1908
- * import {
1909
- * initialize as initializePricingModule,
1910
- * } from "@medusajs/pricing"
1911
- *
1912
- * async function listPriceLists (priceListIds: string[], titles: string[], skip: number, take: number) {
1913
- * const pricingService = await initializePricingModule()
1914
- *
1915
- * const priceLists = await pricingService.listPriceLists(
1916
- * {
1917
- * $and: [
1918
- * {
1919
- * id: priceListIds
1920
- * },
1921
- * {
1922
- * title: titles
1923
- * }
1924
- * ]
1925
- * },
1926
- * {
1927
- * relations: ["prices"],
1928
- * skip,
1929
- * take
1930
- * }
1931
- * )
1932
- *
1933
- * // do something with the price lists or return them
1934
- * }
1143
+ * const priceLists = await pricingModuleService.listPriceLists(
1144
+ * {
1145
+ * id: ["plist_123", "plist_321"],
1146
+ * },
1147
+ * {
1148
+ * relations: ["prices"],
1149
+ * take: 20,
1150
+ * skip: 2,
1151
+ * }
1152
+ * )
1935
1153
  * ```
1936
1154
  */
1937
1155
  listPriceLists(filters?: FilterablePriceListProps, config?: FindConfig<PriceListDTO>, sharedContext?: Context): Promise<PriceListDTO[]>;
@@ -1950,101 +1168,40 @@ export interface IPricingModuleService extends IModuleService {
1950
1168
  * To retrieve a list of price lists using their IDs:
1951
1169
  *
1952
1170
  * ```ts
1953
- * import {
1954
- * initialize as initializePricingModule,
1955
- * } from "@medusajs/pricing"
1956
- *
1957
- * async function retrievePriceLists (priceListIds: string[]) {
1958
- * const pricingService = await initializePricingModule()
1959
- *
1960
- * const [priceLists, count] = await pricingService.listPriceLists(
1961
- * {
1962
- * id: priceListIds
1963
- * },
1964
- * )
1965
- *
1966
- * // do something with the price lists or return them
1967
- * }
1171
+ * const [priceLists, count] =
1172
+ * await pricingModuleService.listAndCountPriceLists({
1173
+ * id: ["plist_123", "plist_321"],
1174
+ * })
1968
1175
  * ```
1969
1176
  *
1970
1177
  * To specify relations that should be retrieved within the price lists:
1971
1178
  *
1972
1179
  * ```ts
1973
- * import {
1974
- * initialize as initializePricingModule,
1975
- * } from "@medusajs/pricing"
1976
- *
1977
- * async function retrievePriceLists (priceListIds: string[]) {
1978
- * const pricingService = await initializePricingModule()
1979
- *
1980
- * const [priceLists, count] = await pricingService.listPriceLists(
1981
- * {
1982
- * id: priceListIds
1983
- * },
1984
- * {
1985
- * relations: ["prices"]
1986
- * }
1987
- * )
1988
- *
1989
- * // do something with the price lists or return them
1990
- * }
1991
- * ```
1992
- *
1993
- * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1994
- *
1995
- * ```ts
1996
- * import {
1997
- * initialize as initializePricingModule,
1998
- * } from "@medusajs/pricing"
1999
- *
2000
- * async function retrievePriceLists (priceListIds: string[], skip: number, take: number) {
2001
- * const pricingService = await initializePricingModule()
2002
- *
2003
- * const [priceLists, count] = await pricingService.listPriceLists(
1180
+ * const [priceLists, count] =
1181
+ * await pricingModuleService.listAndCountPriceLists(
2004
1182
  * {
2005
- * id: priceListIds
1183
+ * id: ["plist_123", "plist_321"],
2006
1184
  * },
2007
1185
  * {
2008
1186
  * relations: ["prices"],
2009
- * skip,
2010
- * take
2011
1187
  * }
2012
1188
  * )
2013
- *
2014
- * // do something with the price lists or return them
2015
- * }
2016
1189
  * ```
2017
1190
  *
2018
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1191
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
2019
1192
  *
2020
1193
  * ```ts
2021
- * import {
2022
- * initialize as initializePricingModule,
2023
- * } from "@medusajs/pricing"
2024
- *
2025
- * async function retrievePriceLists (priceListIds: string[], titles: string[], skip: number, take: number) {
2026
- * const pricingService = await initializePricingModule()
2027
- *
2028
- * const [priceLists, count] = await pricingService.listPriceLists(
1194
+ * const [priceLists, count] =
1195
+ * await pricingModuleService.listAndCountPriceLists(
2029
1196
  * {
2030
- * $and: [
2031
- * {
2032
- * id: priceListIds
2033
- * },
2034
- * {
2035
- * title: titles
2036
- * }
2037
- * ]
1197
+ * id: ["plist_123", "plist_321"],
2038
1198
  * },
2039
1199
  * {
2040
1200
  * relations: ["prices"],
2041
- * skip,
2042
- * take
1201
+ * take: 20,
1202
+ * skip: 2,
2043
1203
  * }
2044
1204
  * )
2045
- *
2046
- * // do something with the price lists or return them
2047
- * }
2048
1205
  * ```
2049
1206
  */
2050
1207
  listAndCountPriceLists(filters?: FilterablePriceListProps, config?: FindConfig<PriceListDTO>, sharedContext?: Context): Promise<[PriceListDTO[], number]>;
@@ -2056,49 +1213,39 @@ export interface IPricingModuleService extends IModuleService {
2056
1213
  * @returns {Promise<PriceListDTO[]>} The created price lists.
2057
1214
  *
2058
1215
  * @example
2059
- * import {
2060
- * initialize as initializePricingModule,
2061
- * } from "@medusajs/pricing"
2062
- *
2063
- * async function createPriceList (items: {
2064
- * title: string
2065
- * description: string
2066
- * starts_at?: string
2067
- * ends_at?: string
2068
- * }[]) {
2069
- * const pricingService = await initializePricingModule()
2070
- *
2071
- * const priceList = await pricingService.createPriceLists(items)
2072
- *
2073
- * // do something with the price lists or return them
2074
- * }
1216
+ * const priceLists =
1217
+ * await pricingModuleService.createPriceLists([
1218
+ * {
1219
+ * title: "Sale 1",
1220
+ * description: "Summer sale",
1221
+ * },
1222
+ * {
1223
+ * title: "Sale 2",
1224
+ * description: "Winter sale",
1225
+ * starts_at: "2024-12-21",
1226
+ * },
1227
+ * ])
2075
1228
  */
2076
1229
  createPriceLists(data: CreatePriceListDTO[], sharedContext?: Context): Promise<PriceListDTO[]>;
2077
1230
  /**
2078
1231
  * This method is used to update price lists.
2079
1232
  *
2080
- * @param {UpdatePriceListDTO[]} data - The attributes to update in each price list.
1233
+ * @param {UpdatePriceListDTO[]} data - The attributes to update in each price list. The price list is identifed by the `id` field.
2081
1234
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2082
1235
  * @returns {Promise<PriceListDTO[]>} The updated price lists.
2083
1236
  *
2084
1237
  * @example
2085
- * import {
2086
- * initialize as initializePricingModule,
2087
- * } from "@medusajs/pricing"
2088
- *
2089
- * async function updatePriceLists (items: {
2090
- * id: string
2091
- * title: string
2092
- * description: string
2093
- * starts_at?: string
2094
- * ends_at?: string
2095
- * }[]) {
2096
- * const pricingService = await initializePricingModule()
2097
- *
2098
- * const priceList = await pricingService.updatePriceLists(items)
2099
- *
2100
- * // do something with the price lists or return them
2101
- * }
1238
+ * const priceLists =
1239
+ * await pricingModuleService.updatePriceLists([
1240
+ * {
1241
+ * id: "plist_123",
1242
+ * title: "Sale 1",
1243
+ * },
1244
+ * {
1245
+ * id: "plist_321",
1246
+ * description: "Winter sale",
1247
+ * },
1248
+ * ])
2102
1249
  */
2103
1250
  updatePriceLists(data: UpdatePriceListDTO[], sharedContext?: Context): Promise<PriceListDTO[]>;
2104
1251
  /**
@@ -2109,18 +1256,51 @@ export interface IPricingModuleService extends IModuleService {
2109
1256
  * @returns {Promise<void>} Resolves when the price lists are deleted successfully.
2110
1257
  *
2111
1258
  * @example
2112
- * import {
2113
- * initialize as initializePricingModule,
2114
- * } from "@medusajs/pricing"
1259
+ * await pricingModuleService.deletePriceLists([
1260
+ * "plist_123",
1261
+ * "plist_321",
1262
+ * ])
1263
+ */
1264
+ deletePriceLists(priceListIds: string[], sharedContext?: Context): Promise<void>;
1265
+ /**
1266
+ * This method soft deletes price lists by their IDs.
1267
+ *
1268
+ * @param {string[]} priceListIds - The IDs of the price lists.
1269
+ * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
1270
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1271
+ * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated price list rules.
1272
+ * The object's keys are the ID attribute names of the price list entity's relations, such as `price_list_rule_id`, and its value is an array of strings, each being the ID of a record associated
1273
+ * with the price list through this relation, such as the IDs of associated price list rule.
2115
1274
  *
2116
- * async function deletePriceLists (ids: string[]) {
2117
- * const pricingService = await initializePricingModule()
1275
+ * If there are no related records, the promise resolves to `void`.
2118
1276
  *
2119
- * await pricingService.deletePriceLists(ids)
2120
- * }
1277
+ * @example
1278
+ * await pricingModuleService.softDeletePriceLists([
1279
+ * "plist_123",
1280
+ * "plist_321",
1281
+ * ])
2121
1282
  */
2122
- deletePriceLists(priceListIds: string[], sharedContext?: Context): Promise<void>;
2123
1283
  softDeletePriceLists<TReturnableLinkableKeys extends string = string>(priceListIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
1284
+ /**
1285
+ * This method restores a soft deleted price lists by its IDs.
1286
+ *
1287
+ * @param {string[]} priceListIds - The list of {summary}
1288
+ * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore along with each of the price lists. You can pass to its `returnLinkableKeys`
1289
+ * property any of the price list's relation attribute names, such as `price_list_rules`.
1290
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1291
+ * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were restored, such as the ID of associated price list rules.
1292
+ * The object's keys are the ID attribute names of the price list entity's relations, such as `price_list_rule_id`,
1293
+ * and its value is an array of strings, each being the ID of the record associated with the price list through this relation,
1294
+ * such as the IDs of associated price list rules.
1295
+ *
1296
+ * If there are no related records restored, the promise resolves to `void`.
1297
+ *
1298
+ * @example
1299
+ * await pricingModuleService.restorePriceLists([
1300
+ * "plist_123",
1301
+ * "plist_321",
1302
+ * ])
1303
+ */
2124
1304
  restorePriceLists<TReturnableLinkableKeys extends string = string>(priceListIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2125
1305
  /**
2126
1306
  * This method is used to retrieve a price list rule by its ID.
@@ -2136,40 +1316,22 @@ export interface IPricingModuleService extends IModuleService {
2136
1316
  * A simple example that retrieves a price list rule by its ID:
2137
1317
  *
2138
1318
  * ```ts
2139
- * import {
2140
- * initialize as initializePricingModule,
2141
- * } from "@medusajs/pricing"
2142
- *
2143
- * async function retrievePriceListRule (priceListRuleId: string) {
2144
- * const pricingService = await initializePricingModule()
2145
- *
2146
- * const priceListRule = await pricingService.retrievePriceListRule(
2147
- * priceListRuleId
1319
+ * const priceListRule =
1320
+ * await pricingModuleService.retrievePriceListRule(
1321
+ * "plrule_123"
2148
1322
  * )
2149
- *
2150
- * // do something with the price list rule or return it
2151
- * }
2152
1323
  * ```
2153
1324
  *
2154
1325
  * To specify relations that should be retrieved:
2155
1326
  *
2156
1327
  * ```ts
2157
- * import {
2158
- * initialize as initializePricingModule,
2159
- * } from "@medusajs/pricing"
2160
- *
2161
- * async function retrievePriceListRule (priceListRuleId: string) {
2162
- * const pricingService = await initializePricingModule()
2163
- *
2164
- * const priceListRule = await pricingService.retrievePriceListRule(
2165
- * priceListRuleId,
1328
+ * const priceListRule =
1329
+ * await pricingModuleService.retrievePriceListRule(
1330
+ * "plrule_123",
2166
1331
  * {
2167
- * relations: ["price_list"]
1332
+ * relations: ["price_list"],
2168
1333
  * }
2169
1334
  * )
2170
- *
2171
- * // do something with the price list rule or return it
2172
- * }
2173
1335
  * ```
2174
1336
  */
2175
1337
  retrievePriceListRule(id: string, config?: FindConfig<PriceListRuleDTO>, sharedContext?: Context): Promise<PriceListRuleDTO>;
@@ -2188,101 +1350,40 @@ export interface IPricingModuleService extends IModuleService {
2188
1350
  * To retrieve a list of price list vs using their IDs:
2189
1351
  *
2190
1352
  * ```ts
2191
- * import {
2192
- * initialize as initializePricingModule,
2193
- * } from "@medusajs/pricing"
2194
- *
2195
- * async function listPriceListRules (priceListRuleIds: string[]) {
2196
- * const pricingService = await initializePricingModule()
2197
- *
2198
- * const priceListRules = await pricingService.listPriceListRules(
2199
- * {
2200
- * id: priceListRuleIds
2201
- * },
2202
- * )
2203
- *
2204
- * // do something with the price list rules or return them
2205
- * }
1353
+ * const priceListRules =
1354
+ * await pricingModuleService.listPriceListRules({
1355
+ * id: ["plrule_123", "plrule_321"],
1356
+ * })
2206
1357
  * ```
2207
1358
  *
2208
1359
  * To specify relations that should be retrieved within the price list rules:
2209
1360
  *
2210
1361
  * ```ts
2211
- * import {
2212
- * initialize as initializePricingModule,
2213
- * } from "@medusajs/pricing"
2214
- *
2215
- * async function listPriceListRules (priceListRuleIds: string[]) {
2216
- * const pricingService = await initializePricingModule()
2217
- *
2218
- * const priceListRules = await pricingService.listPriceListRules(
2219
- * {
2220
- * id: priceListRuleIds
2221
- * },
2222
- * {
2223
- * relations: ["price_list_rule_values"]
2224
- * }
2225
- * )
2226
- *
2227
- * // do something with the price list rules or return them
2228
- * }
2229
- * ```
2230
- *
2231
- * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
2232
- *
2233
- * ```ts
2234
- * import {
2235
- * initialize as initializePricingModule,
2236
- * } from "@medusajs/pricing"
2237
- *
2238
- * async function listPriceListRules (priceListRuleIds: string[], skip: number, take: number) {
2239
- * const pricingService = await initializePricingModule()
2240
- *
2241
- * const priceListRules = await pricingService.listPriceListRules(
1362
+ * const priceListRules =
1363
+ * await pricingModuleService.listPriceListRules(
2242
1364
  * {
2243
- * id: priceListRuleIds
1365
+ * id: ["plrule_123", "plrule_321"],
2244
1366
  * },
2245
1367
  * {
2246
1368
  * relations: ["price_list_rule_values"],
2247
- * skip,
2248
- * take
2249
1369
  * }
2250
1370
  * )
2251
- *
2252
- * // do something with the price list rules or return them
2253
- * }
2254
1371
  * ```
2255
1372
  *
2256
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1373
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
2257
1374
  *
2258
1375
  * ```ts
2259
- * import {
2260
- * initialize as initializePricingModule,
2261
- * } from "@medusajs/pricing"
2262
- *
2263
- * async function listPriceListRules (priceListRuleIds: string[], ruleTypeIDs: string[], skip: number, take: number) {
2264
- * const pricingService = await initializePricingModule()
2265
- *
2266
- * const priceListRules = await pricingService.listPriceListRules(
1376
+ * const priceListRules =
1377
+ * await pricingModuleService.listPriceListRules(
2267
1378
  * {
2268
- * $and: [
2269
- * {
2270
- * id: priceListRuleIds
2271
- * },
2272
- * {
2273
- * rule_types: ruleTypeIDs
2274
- * }
2275
- * ]
1379
+ * id: ["plrule_123", "plrule_321"],
2276
1380
  * },
2277
1381
  * {
2278
1382
  * relations: ["price_list_rule_values"],
2279
- * skip,
2280
- * take
1383
+ * take: 20,
1384
+ * skip: 2,
2281
1385
  * }
2282
1386
  * )
2283
- *
2284
- * // do something with the price list rules or return them
2285
- * }
2286
1387
  * ```
2287
1388
  */
2288
1389
  listPriceListRules(filters?: FilterablePriceListRuleProps, config?: FindConfig<PriceListRuleDTO>, sharedContext?: Context): Promise<PriceListRuleDTO[]>;
@@ -2301,101 +1402,40 @@ export interface IPricingModuleService extends IModuleService {
2301
1402
  * To retrieve a list of price list vs using their IDs:
2302
1403
  *
2303
1404
  * ```ts
2304
- * import {
2305
- * initialize as initializePricingModule,
2306
- * } from "@medusajs/pricing"
2307
- *
2308
- * async function listAndCountPriceListRules (priceListRuleIds: string[]) {
2309
- * const pricingService = await initializePricingModule()
2310
- *
2311
- * const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
2312
- * {
2313
- * id: priceListRuleIds
2314
- * },
2315
- * )
2316
- *
2317
- * // do something with the price list rules or return them
2318
- * }
1405
+ * const [priceListRules, count] =
1406
+ * await pricingModuleService.listAndCountPriceListRules({
1407
+ * id: ["plrule_123", "plrule_321"],
1408
+ * })
2319
1409
  * ```
2320
1410
  *
2321
1411
  * To specify relations that should be retrieved within the price list rules:
2322
1412
  *
2323
1413
  * ```ts
2324
- * import {
2325
- * initialize as initializePricingModule,
2326
- * } from "@medusajs/pricing"
2327
- *
2328
- * async function listAndCountPriceListRules (priceListRuleIds: string[]) {
2329
- * const pricingService = await initializePricingModule()
2330
- *
2331
- * const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
2332
- * {
2333
- * id: priceListRuleIds
2334
- * },
2335
- * {
2336
- * relations: ["price_list_rule_values"]
2337
- * }
2338
- * )
2339
- *
2340
- * // do something with the price list rules or return them
2341
- * }
2342
- * ```
2343
- *
2344
- * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
2345
- *
2346
- * ```ts
2347
- * import {
2348
- * initialize as initializePricingModule,
2349
- * } from "@medusajs/pricing"
2350
- *
2351
- * async function listAndCountPriceListRules (priceListRuleIds: string[], skip: number, take: number) {
2352
- * const pricingService = await initializePricingModule()
2353
- *
2354
- * const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
1414
+ * const [priceListRules, count] =
1415
+ * await pricingModuleService.listAndCountPriceListRules(
2355
1416
  * {
2356
- * id: priceListRuleIds
1417
+ * id: ["plrule_123", "plrule_321"],
2357
1418
  * },
2358
1419
  * {
2359
1420
  * relations: ["price_list_rule_values"],
2360
- * skip,
2361
- * take
2362
1421
  * }
2363
1422
  * )
2364
- *
2365
- * // do something with the price list rules or return them
2366
- * }
2367
1423
  * ```
2368
1424
  *
2369
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1425
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
2370
1426
  *
2371
1427
  * ```ts
2372
- * import {
2373
- * initialize as initializePricingModule,
2374
- * } from "@medusajs/pricing"
2375
- *
2376
- * async function listAndCountPriceListRules (priceListRuleIds: string[], ruleTypeIDs: string[], skip: number, take: number) {
2377
- * const pricingService = await initializePricingModule()
2378
- *
2379
- * const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
1428
+ * const [priceListRules, count] =
1429
+ * await pricingModuleService.listAndCountPriceListRules(
2380
1430
  * {
2381
- * $and: [
2382
- * {
2383
- * id: priceListRuleIds
2384
- * },
2385
- * {
2386
- * rule_types: ruleTypeIDs
2387
- * }
2388
- * ]
1431
+ * id: ["plrule_123", "plrule_321"],
2389
1432
  * },
2390
1433
  * {
2391
1434
  * relations: ["price_list_rule_values"],
2392
- * skip,
2393
- * take
1435
+ * take: 20,
1436
+ * skip: 2,
2394
1437
  * }
2395
1438
  * )
2396
- *
2397
- * // do something with the price list rules or return them
2398
- * }
2399
1439
  * ```
2400
1440
  */
2401
1441
  listAndCountPriceListRules(filters?: FilterablePriceListRuleProps, config?: FindConfig<PriceListRuleDTO>, sharedContext?: Context): Promise<[PriceListRuleDTO[], number]>;
@@ -2407,45 +1447,30 @@ export interface IPricingModuleService extends IModuleService {
2407
1447
  * @returns {Promise<PriceListRuleDTO[]>} The created price list rules.
2408
1448
  *
2409
1449
  * @example
2410
- * import {
2411
- * initialize as initializePricingModule,
2412
- * } from "@medusajs/pricing"
2413
- *
2414
- * async function createPriceListRules (items: {
2415
- * rule_type_id: string
2416
- * price_list_id: string
2417
- * }[]) {
2418
- * const pricingService = await initializePricingModule()
2419
- *
2420
- * const priceListRules = await pricingService.createPriceListRules(items)
2421
- *
2422
- * // do something with the price list rule or return them
2423
- * }
1450
+ * const priceListRules =
1451
+ * await pricingModuleService.createPriceListRules([
1452
+ * {
1453
+ * rule_type_id: "rul-typ_123",
1454
+ * price_list_id: "plist_123",
1455
+ * },
1456
+ * ])
2424
1457
  */
2425
1458
  createPriceListRules(data: CreatePriceListRuleDTO[], sharedContext?: Context): Promise<PriceListRuleDTO[]>;
2426
1459
  /**
2427
1460
  * This method is used to update price list rules.
2428
1461
  *
2429
- * @param {UpdatePriceListRuleDTO[]} data - The attributes to update for each price list rule.
1462
+ * @param {UpdatePriceListRuleDTO[]} data - The attributes to update for each price list rule. The price list rule is identified by the `id` property.
2430
1463
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2431
1464
  * @returns {Promise<PriceListRuleDTO[]>} The updated price list rules.
2432
1465
  *
2433
1466
  * @example
2434
- * import {
2435
- * initialize as initializePricingModule,
2436
- * } from "@medusajs/pricing"
2437
- *
2438
- * async function updatePriceListRules (items: {
2439
- * id: string
2440
- * rule_type_id?: string
2441
- * price_list_id?: string
2442
- * }[]) {
2443
- * const pricingService = await initializePricingModule()
2444
- *
2445
- * const priceListRules = await pricingService.updatePriceListRules(items)
2446
- *
2447
- * // do something with the price list rule or return them
2448
- * }
1467
+ * const priceListRules =
1468
+ * await pricingModuleService.updatePriceListRules([
1469
+ * {
1470
+ * id: "plrule_123",
1471
+ * rule_type_id: "rul-typ_123",
1472
+ * },
1473
+ * ])
2449
1474
  */
2450
1475
  updatePriceListRules(data: UpdatePriceListRuleDTO[], sharedContext?: Context): Promise<PriceListRuleDTO[]>;
2451
1476
  /**
@@ -2456,15 +1481,10 @@ export interface IPricingModuleService extends IModuleService {
2456
1481
  * @returns {Promise<void>} Resolves successfully when the price list rules are deleted.
2457
1482
  *
2458
1483
  * @example
2459
- * import {
2460
- * initialize as initializePricingModule,
2461
- * } from "@medusajs/pricing"
2462
- *
2463
- * async function deletePriceListRules (priceListRuleIds: string[]) {
2464
- * const pricingService = await initializePricingModule()
2465
- *
2466
- * await pricingService.deletePriceListRules(priceListRuleIds)
2467
- * }
1484
+ * await pricingModuleService.deletePriceListRules([
1485
+ * "plrule_123",
1486
+ * "plrule_321",
1487
+ * ])
2468
1488
  */
2469
1489
  deletePriceListRules(priceListRuleIds: string[], sharedContext?: Context): Promise<void>;
2470
1490
  /**
@@ -2475,77 +1495,93 @@ export interface IPricingModuleService extends IModuleService {
2475
1495
  * @returns {Promise<PriceListDTO[]>} The updated price lists.
2476
1496
  *
2477
1497
  * @example
2478
- * import {
2479
- * initialize as initializePricingModule,
2480
- * } from "@medusajs/pricing"
2481
- *
2482
- * async function addPriceListPrices (items: {
2483
- * priceListId: string,
2484
- * prices: {
2485
- * currency_code: string,
2486
- * amount: number,
2487
- * price_set_id: string
2488
- * }[]
2489
- * }[]) {
2490
- * const pricingService = await initializePricingModule()
2491
- *
2492
- * const priceLists = await pricingService.addPriceListPrices(items)
2493
- *
2494
- * // do something with the price lists or return them
2495
- * }
1498
+ * const priceLists =
1499
+ * await pricingModuleService.addPriceListPrices([
1500
+ * {
1501
+ * price_list_id: "plist_123",
1502
+ * prices: [
1503
+ * {
1504
+ * currency_code: "usd",
1505
+ * amount: 500,
1506
+ * price_set_id: "pset_123",
1507
+ * },
1508
+ * ],
1509
+ * },
1510
+ * ])
2496
1511
  */
2497
1512
  addPriceListPrices(data: AddPriceListPricesDTO[], sharedContext?: Context): Promise<PriceListDTO[]>;
2498
- updatePriceListPrices(data: UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PriceListDTO[]>;
2499
1513
  /**
2500
- * This method is used to set the rules of a price list.
1514
+ * This method updates existing price list's prices.
2501
1515
  *
2502
- * @param {SetPriceListRulesDTO} data - The rules to set for a price list.
1516
+ * @param {UpdatePriceListPricesDTO[]} data - The attributes to update in a price list's prices. The price list's ID is specified
1517
+ * in the `price_list_id` field.
2503
1518
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2504
- * @returns {Promise<PriceListDTO>} The updated price lists.
1519
+ * @returns {Promise<PriceListDTO[]>} The updated price list's prices.
2505
1520
  *
2506
1521
  * @example
2507
- * import {
2508
- * initialize as initializePricingModule,
2509
- * } from "@medusajs/pricing"
1522
+ * const priceLists =
1523
+ * await pricingModuleService.updatePriceListPrices([
1524
+ * {
1525
+ * price_list_id: "plist_123",
1526
+ * prices: [
1527
+ * {
1528
+ * id: "price_123",
1529
+ * currency_code: "usd",
1530
+ * amount: 500,
1531
+ * price_set_id: "pset_123",
1532
+ * },
1533
+ * ],
1534
+ * },
1535
+ * ])
1536
+ */
1537
+ updatePriceListPrices(data: UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PriceListDTO[]>;
1538
+ /**
1539
+ * This method is used to set the rules of a price list. Previous rules are removed.
2510
1540
  *
2511
- * async function setPriceListRules (priceListId: string) {
2512
- * const pricingService = await initializePricingModule()
1541
+ * @param {SetPriceListRulesDTO} data - The rules to set for a price list. The price list is identified by the
1542
+ * `price_list_id` property.
1543
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1544
+ * @returns {Promise<PriceListDTO>} The updated price list.
2513
1545
  *
2514
- * const priceList = await pricingService.setPriceListRules({
2515
- * priceListId,
1546
+ * @example
1547
+ * const priceList =
1548
+ * await pricingModuleService.setPriceListRules({
1549
+ * price_list_id: "plist_123",
2516
1550
  * rules: {
2517
- * region_id: "US"
2518
- * }
1551
+ * region_id: "reg_123",
1552
+ * },
2519
1553
  * })
2520
- *
2521
- * // do something with the price list or return it
2522
- * }
2523
1554
  */
2524
1555
  setPriceListRules(data: SetPriceListRulesDTO, sharedContext?: Context): Promise<PriceListDTO>;
2525
1556
  /**
2526
1557
  * This method is used to remove rules from a price list.
2527
1558
  *
2528
- * @param {RemovePriceListRulesDTO} data - The rules to remove from a price list.
1559
+ * @param {RemovePriceListRulesDTO} data - The rules to remove from a price list. The price list is identified by the
1560
+ * `price_list_id` property.
2529
1561
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2530
1562
  * @returns {Promise<PriceListDTO>} The updated price lists.
2531
1563
  *
2532
1564
  * @example
2533
- * import {
2534
- * initialize as initializePricingModule,
2535
- * } from "@medusajs/pricing"
2536
- *
2537
- * async function setPriceListRules (priceListId: string) {
2538
- * const pricingService = await initializePricingModule()
2539
- *
2540
- * const priceList = await pricingService.removePriceListRules({
2541
- * priceListId,
2542
- * rules: ["region_id"]
1565
+ * const priceList =
1566
+ * await pricingModuleService.removePriceListRules({
1567
+ * price_list_id: "plist_123",
1568
+ * rules: ["region_id"],
2543
1569
  * })
2544
- *
2545
- * // do something with the price list or return it
2546
- * }
2547
1570
  */
2548
1571
  removePriceListRules(data: RemovePriceListRulesDTO, sharedContext?: Context): Promise<PriceListDTO>;
1572
+ /**
1573
+ * This method deletes prices by their IDs.
1574
+ *
1575
+ * @param {string[]} ids - The IDs of the prices.
1576
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1577
+ * @returns {Promise<void>} Resolves when the prices are deleted successfully.
1578
+ *
1579
+ * @example
1580
+ * await pricingModuleService.removePrices([
1581
+ * "price_123",
1582
+ * "price_321",
1583
+ * ])
1584
+ */
2549
1585
  removePrices(ids: string[], sharedContext?: Context): Promise<void>;
2550
1586
  }
2551
1587
  //# sourceMappingURL=service.d.ts.map