@medusajs/types 1.12.0-snapshot-20240401075323 → 1.12.0-snapshot-20240402145055
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/common/config-module.d.ts +48 -0
- package/dist/common/config-module.d.ts.map +1 -1
- package/dist/modules-sdk/index.d.ts +1 -0
- package/dist/modules-sdk/index.d.ts.map +1 -1
- package/dist/product/common.d.ts +82 -15
- package/dist/product/common.d.ts.map +1 -1
- package/dist/product/service.d.ts +648 -1899
- package/dist/product/service.d.ts.map +1 -1
- package/package.json +1 -1
@@ -4,7 +4,7 @@ import { FindConfig } from "../common";
|
|
4
4
|
import { IModuleService } from "../modules-sdk";
|
5
5
|
import { Context } from "../shared-context";
|
6
6
|
/**
|
7
|
-
* The main service interface for the
|
7
|
+
* The main service interface for the Product Module.
|
8
8
|
*/
|
9
9
|
export interface IProductModuleService extends IModuleService {
|
10
10
|
/**
|
@@ -21,35 +21,19 @@ export interface IProductModuleService extends IModuleService {
|
|
21
21
|
* A simple example that retrieves a product by its ID:
|
22
22
|
*
|
23
23
|
* ```ts
|
24
|
-
*
|
25
|
-
*
|
26
|
-
* } from "@medusajs/product"
|
27
|
-
*
|
28
|
-
* async function retrieveProduct (id: string) {
|
29
|
-
* const productModule = await initializeProductModule()
|
30
|
-
*
|
31
|
-
* const product = await productModule.retrieve(id)
|
32
|
-
*
|
33
|
-
* // do something with the product or return it
|
34
|
-
* }
|
24
|
+
* const product =
|
25
|
+
* await productModuleService.retrieve("prod_123")
|
35
26
|
* ```
|
36
27
|
*
|
37
28
|
* To specify relations that should be retrieved:
|
38
29
|
*
|
39
30
|
* ```ts
|
40
|
-
*
|
41
|
-
*
|
42
|
-
*
|
43
|
-
*
|
44
|
-
*
|
45
|
-
*
|
46
|
-
*
|
47
|
-
* const product = await productModule.retrieve(id, {
|
48
|
-
* relations: ["categories"]
|
49
|
-
* })
|
50
|
-
*
|
51
|
-
* // do something with the product or return it
|
52
|
-
* }
|
31
|
+
* const product = await productModuleService.retrieve(
|
32
|
+
* "prod_123",
|
33
|
+
* {
|
34
|
+
* relations: ["categories"],
|
35
|
+
* }
|
36
|
+
* )
|
53
37
|
* ```
|
54
38
|
*/
|
55
39
|
retrieve(productId: string, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO>;
|
@@ -67,90 +51,37 @@ export interface IProductModuleService extends IModuleService {
|
|
67
51
|
* To retrieve a list of products using their IDs:
|
68
52
|
*
|
69
53
|
* ```ts
|
70
|
-
*
|
71
|
-
*
|
72
|
-
* }
|
73
|
-
*
|
74
|
-
* async function retrieveProducts (ids: string[]) {
|
75
|
-
* const productModule = await initializeProductModule()
|
76
|
-
*
|
77
|
-
* const products = await productModule.list({
|
78
|
-
* id: ids
|
79
|
-
* })
|
80
|
-
*
|
81
|
-
* // do something with the products or return them
|
82
|
-
* }
|
54
|
+
* const products = await productModuleService.list({
|
55
|
+
* id: ["prod_123", "prod_321"],
|
56
|
+
* })
|
83
57
|
* ```
|
84
58
|
*
|
85
59
|
* To specify relations that should be retrieved within the products:
|
86
60
|
*
|
87
61
|
* ```ts
|
88
|
-
*
|
89
|
-
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
93
|
-
* const productModule = await initializeProductModule()
|
94
|
-
*
|
95
|
-
* const products = await productModule.list({
|
96
|
-
* id: ids
|
97
|
-
* }, {
|
98
|
-
* relations: ["categories"]
|
99
|
-
* })
|
100
|
-
*
|
101
|
-
* // do something with the products or return them
|
102
|
-
* }
|
103
|
-
* ```
|
104
|
-
*
|
105
|
-
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
106
|
-
*
|
107
|
-
* ```ts
|
108
|
-
* import {
|
109
|
-
* initialize as initializeProductModule,
|
110
|
-
* } from "@medusajs/product"
|
111
|
-
*
|
112
|
-
* async function retrieveProducts (ids: string[], skip: number, take: number) {
|
113
|
-
* const productModule = await initializeProductModule()
|
114
|
-
*
|
115
|
-
* const products = await productModule.list({
|
116
|
-
* id: ids
|
117
|
-
* }, {
|
62
|
+
* const products = await productModuleService.list(
|
63
|
+
* {
|
64
|
+
* id: ["prod_123", "prod_321"],
|
65
|
+
* },
|
66
|
+
* {
|
118
67
|
* relations: ["categories"],
|
119
|
-
*
|
120
|
-
*
|
121
|
-
* })
|
122
|
-
*
|
123
|
-
* // do something with the products or return them
|
124
|
-
* }
|
68
|
+
* }
|
69
|
+
* )
|
125
70
|
* ```
|
126
71
|
*
|
127
|
-
* You can
|
72
|
+
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
128
73
|
*
|
129
74
|
* ```ts
|
130
|
-
*
|
131
|
-
*
|
132
|
-
*
|
133
|
-
*
|
134
|
-
*
|
135
|
-
* const productModule = await initializeProductModule()
|
136
|
-
*
|
137
|
-
* const products = await productModule.list({
|
138
|
-
* $and: [
|
139
|
-
* {
|
140
|
-
* id: ids
|
141
|
-
* },
|
142
|
-
* {
|
143
|
-
* q: title
|
144
|
-
* }
|
145
|
-
* ]
|
146
|
-
* }, {
|
75
|
+
* const products = await productModuleService.list(
|
76
|
+
* {
|
77
|
+
* id: ["prod_123", "prod_321"],
|
78
|
+
* },
|
79
|
+
* {
|
147
80
|
* relations: ["categories"],
|
148
|
-
*
|
149
|
-
*
|
150
|
-
* }
|
151
|
-
*
|
152
|
-
* // do something with the products or return them
|
153
|
-
* }
|
81
|
+
* take: 20,
|
82
|
+
* skip: 2,
|
83
|
+
* }
|
84
|
+
* )
|
154
85
|
* ```
|
155
86
|
*/
|
156
87
|
list(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO[]>;
|
@@ -168,90 +99,40 @@ export interface IProductModuleService extends IModuleService {
|
|
168
99
|
* To retrieve a list of products using their IDs:
|
169
100
|
*
|
170
101
|
* ```ts
|
171
|
-
*
|
172
|
-
*
|
173
|
-
*
|
174
|
-
*
|
175
|
-
* async function retrieveProducts (ids: string[]) {
|
176
|
-
* const productModule = await initializeProductModule()
|
177
|
-
*
|
178
|
-
* const [products, count] = await productModule.listAndCount({
|
179
|
-
* id: ids
|
102
|
+
* const [products, count] =
|
103
|
+
* await productModuleService.listAndCount({
|
104
|
+
* id: ["prod_123", "prod_321"],
|
180
105
|
* })
|
181
|
-
*
|
182
|
-
* // do something with the products or return them
|
183
|
-
* }
|
184
106
|
* ```
|
185
107
|
*
|
186
108
|
* To specify relations that should be retrieved within the products:
|
187
109
|
*
|
188
110
|
* ```ts
|
189
|
-
*
|
190
|
-
*
|
191
|
-
*
|
192
|
-
*
|
193
|
-
*
|
194
|
-
*
|
195
|
-
*
|
196
|
-
*
|
197
|
-
*
|
198
|
-
* }, {
|
199
|
-
* relations: ["categories"]
|
200
|
-
* })
|
201
|
-
*
|
202
|
-
* // do something with the products or return them
|
203
|
-
* }
|
111
|
+
* const [products, count] =
|
112
|
+
* await productModuleService.listAndCount(
|
113
|
+
* {
|
114
|
+
* id: ["prod_123", "prod_321"],
|
115
|
+
* },
|
116
|
+
* {
|
117
|
+
* relations: ["categories"],
|
118
|
+
* }
|
119
|
+
* )
|
204
120
|
* ```
|
205
121
|
*
|
206
122
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
207
123
|
*
|
208
124
|
* ```ts
|
209
|
-
*
|
210
|
-
*
|
211
|
-
*
|
212
|
-
*
|
213
|
-
*
|
214
|
-
*
|
215
|
-
*
|
216
|
-
*
|
217
|
-
*
|
218
|
-
*
|
219
|
-
*
|
220
|
-
* skip,
|
221
|
-
* take
|
222
|
-
* })
|
223
|
-
*
|
224
|
-
* // do something with the products or return them
|
225
|
-
* }
|
226
|
-
* ```
|
227
|
-
*
|
228
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
229
|
-
*
|
230
|
-
* ```ts
|
231
|
-
* import {
|
232
|
-
* initialize as initializeProductModule,
|
233
|
-
* } from "@medusajs/product"
|
234
|
-
*
|
235
|
-
* async function retrieveProducts (ids: string[], title: string, skip: number, take: number) {
|
236
|
-
* const productModule = await initializeProductModule()
|
237
|
-
*
|
238
|
-
* const [products, count] = await productModule.listAndCount({
|
239
|
-
* $and: [
|
240
|
-
* {
|
241
|
-
* id: ids
|
242
|
-
* },
|
243
|
-
* {
|
244
|
-
* q: title
|
245
|
-
* }
|
246
|
-
* ]
|
247
|
-
* }, {
|
248
|
-
* relations: ["categories"],
|
249
|
-
* skip,
|
250
|
-
* take
|
251
|
-
* })
|
252
|
-
*
|
253
|
-
* // do something with the products or return them
|
254
|
-
* }
|
125
|
+
* const [products, count] =
|
126
|
+
* await productModuleService.listAndCount(
|
127
|
+
* {
|
128
|
+
* id: ["prod_123", "prod_321"],
|
129
|
+
* },
|
130
|
+
* {
|
131
|
+
* relations: ["categories"],
|
132
|
+
* take: 20,
|
133
|
+
* skip: 2,
|
134
|
+
* }
|
135
|
+
* )
|
255
136
|
* ```
|
256
137
|
*/
|
257
138
|
listAndCount(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<[ProductDTO[], number]>;
|
@@ -263,21 +144,15 @@ export interface IProductModuleService extends IModuleService {
|
|
263
144
|
* @returns {Promise<ProductDTO[]>} The list of created products.
|
264
145
|
*
|
265
146
|
* @example
|
266
|
-
*
|
267
|
-
*
|
268
|
-
*
|
269
|
-
*
|
270
|
-
*
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
274
|
-
*
|
275
|
-
* title
|
276
|
-
* }
|
277
|
-
* ])
|
278
|
-
*
|
279
|
-
* // do something with the products or return them
|
280
|
-
* }
|
147
|
+
* const products = await productModuleService.create([
|
148
|
+
* {
|
149
|
+
* title: "Shirt",
|
150
|
+
* },
|
151
|
+
* {
|
152
|
+
* title: "Pants",
|
153
|
+
* handle: "pants",
|
154
|
+
* },
|
155
|
+
* ])
|
281
156
|
*/
|
282
157
|
create(data: CreateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
|
283
158
|
/**
|
@@ -288,73 +163,43 @@ export interface IProductModuleService extends IModuleService {
|
|
288
163
|
* @returns {Promise<ProductDTO>} The created product.
|
289
164
|
*
|
290
165
|
* @example
|
291
|
-
*
|
292
|
-
*
|
293
|
-
* }
|
294
|
-
*
|
295
|
-
* async function createProduct (title: string) {
|
296
|
-
* const productModule = await initializeProductModule()
|
297
|
-
*
|
298
|
-
* const product = await productModule.create(
|
299
|
-
* {
|
300
|
-
* title
|
301
|
-
* }
|
302
|
-
* )
|
303
|
-
*
|
304
|
-
* // do something with the product or return it
|
305
|
-
* }
|
166
|
+
* const product = await productModuleService.create({
|
167
|
+
* title: "Shirt",
|
168
|
+
* })
|
306
169
|
*/
|
307
170
|
create(data: CreateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
|
308
171
|
/**
|
309
172
|
* This method updates existing products, or creates new ones if they don't exist.
|
310
173
|
*
|
311
|
-
* @param {
|
174
|
+
* @param {UpsertProductDTO[]} data - The attributes to update or create for each product.
|
312
175
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
313
176
|
* @returns {Promise<ProductDTO[]>} The updated and created products.
|
314
177
|
*
|
315
178
|
* @example
|
316
|
-
*
|
317
|
-
*
|
318
|
-
*
|
319
|
-
*
|
320
|
-
*
|
321
|
-
*
|
322
|
-
*
|
323
|
-
*
|
324
|
-
*
|
325
|
-
* title
|
326
|
-
* }
|
327
|
-
* ])
|
328
|
-
*
|
329
|
-
* // do something with the products or return them
|
330
|
-
* }
|
179
|
+
* const products = await productModuleService.upsert([
|
180
|
+
* {
|
181
|
+
* id: "prod_123",
|
182
|
+
* handle: "pant",
|
183
|
+
* },
|
184
|
+
* {
|
185
|
+
* title: "Shirt",
|
186
|
+
* },
|
187
|
+
* ])
|
331
188
|
*/
|
332
189
|
upsert(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
|
333
190
|
/**
|
334
191
|
* This method updates the product if it exists, or creates a new ones if it doesn't.
|
335
192
|
*
|
336
|
-
* @param {
|
193
|
+
* @param {UpsertProductDTO} data - The attributes to update or create for the new product.
|
337
194
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
338
195
|
* @returns {Promise<ProductDTO>} The updated or created product.
|
339
196
|
*
|
340
197
|
* @example
|
341
|
-
*
|
342
|
-
*
|
343
|
-
* }
|
344
|
-
*
|
345
|
-
* async function upserProduct (title: string) {
|
346
|
-
* const productModule = await initializeProductModule()
|
347
|
-
*
|
348
|
-
* const createdProduct = await productModule.upsert(
|
349
|
-
* {
|
350
|
-
* title
|
351
|
-
* }
|
352
|
-
* )
|
353
|
-
*
|
354
|
-
* // do something with the product or return it
|
355
|
-
* }
|
198
|
+
* const product = await productModuleService.upsert({
|
199
|
+
* title: "Shirt",
|
200
|
+
* })
|
356
201
|
*/
|
357
|
-
upsert(data: UpsertProductDTO
|
202
|
+
upsert(data: UpsertProductDTO, sharedContext?: Context): Promise<ProductDTO>;
|
358
203
|
/**
|
359
204
|
* This method is used to update a product.
|
360
205
|
*
|
@@ -364,45 +209,31 @@ export interface IProductModuleService extends IModuleService {
|
|
364
209
|
* @returns {Promise<ProductDTO>} The updated product.
|
365
210
|
*
|
366
211
|
* @example
|
367
|
-
*
|
368
|
-
*
|
369
|
-
*
|
370
|
-
*
|
371
|
-
*
|
372
|
-
*
|
373
|
-
*
|
374
|
-
* const product = await productModule.update(id, {
|
375
|
-
* title
|
376
|
-
* }
|
377
|
-
* )
|
378
|
-
*
|
379
|
-
* // do something with the product or return it
|
380
|
-
* }
|
212
|
+
* const product = await productModuleService.update(
|
213
|
+
* "prod_123",
|
214
|
+
* {
|
215
|
+
* handle: "pant",
|
216
|
+
* }
|
217
|
+
* )
|
381
218
|
*/
|
382
219
|
update(id: string, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
|
383
220
|
/**
|
384
|
-
* This method is used to update a list of products
|
221
|
+
* This method is used to update a list of products matching the specified filters.
|
385
222
|
*
|
386
|
-
* @param {FilterableProductProps} selector - The filters
|
223
|
+
* @param {FilterableProductProps} selector - The filters specifying which products to update.
|
387
224
|
* @param {UpdateProductDTO} data - The attributes to be updated on the selected products
|
388
225
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
389
226
|
* @returns {Promise<ProductDTO[]>} The updated products.
|
390
227
|
*
|
391
228
|
* @example
|
392
|
-
*
|
393
|
-
*
|
394
|
-
*
|
395
|
-
*
|
396
|
-
*
|
397
|
-
*
|
398
|
-
*
|
399
|
-
*
|
400
|
-
* title
|
401
|
-
* }
|
402
|
-
* )
|
403
|
-
*
|
404
|
-
* // do something with the products or return them
|
405
|
-
* }
|
229
|
+
* const products = await productModuleService.update(
|
230
|
+
* {
|
231
|
+
* title: "Pant",
|
232
|
+
* },
|
233
|
+
* {
|
234
|
+
* handle: "pant",
|
235
|
+
* }
|
236
|
+
* )
|
406
237
|
*/
|
407
238
|
update(selector: FilterableProductProps, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO[]>;
|
408
239
|
/**
|
@@ -413,15 +244,7 @@ export interface IProductModuleService extends IModuleService {
|
|
413
244
|
* @returns {Promise<void>} Resolves when the products are successfully deleted.
|
414
245
|
*
|
415
246
|
* @example
|
416
|
-
*
|
417
|
-
* initialize as initializeProductModule,
|
418
|
-
* } from "@medusajs/product"
|
419
|
-
*
|
420
|
-
* async function deleteProducts (ids: string[]) {
|
421
|
-
* const productModule = await initializeProductModule()
|
422
|
-
*
|
423
|
-
* await productModule.delete(ids)
|
424
|
-
* }
|
247
|
+
* await productModuleService.delete(["prod_123", "prod_321"])
|
425
248
|
*/
|
426
249
|
delete(productIds: string[], sharedContext?: Context): Promise<void>;
|
427
250
|
/**
|
@@ -440,17 +263,10 @@ export interface IProductModuleService extends IModuleService {
|
|
440
263
|
* If there are no related records, the promise resolved to `void`.
|
441
264
|
*
|
442
265
|
* @example
|
443
|
-
*
|
444
|
-
*
|
445
|
-
*
|
446
|
-
*
|
447
|
-
* async function deleteProducts (ids: string[]) {
|
448
|
-
* const productModule = await initializeProductModule()
|
449
|
-
*
|
450
|
-
* const cascadedEntities = await productModule.softDelete(ids)
|
451
|
-
*
|
452
|
-
* // do something with the returned cascaded entity IDs or return them
|
453
|
-
* }
|
266
|
+
* await productModuleService.softDelete([
|
267
|
+
* "prod_123",
|
268
|
+
* "prod_321",
|
269
|
+
* ])
|
454
270
|
*/
|
455
271
|
softDelete<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
456
272
|
/**
|
@@ -467,19 +283,7 @@ export interface IProductModuleService extends IModuleService {
|
|
467
283
|
* If there are no related records that were restored, the promise resolved to `void`.
|
468
284
|
*
|
469
285
|
* @example
|
470
|
-
*
|
471
|
-
* initialize as initializeProductModule,
|
472
|
-
* } from "@medusajs/product"
|
473
|
-
*
|
474
|
-
* async function restoreProducts (ids: string[]) {
|
475
|
-
* const productModule = await initializeProductModule()
|
476
|
-
*
|
477
|
-
* const cascadedEntities = await productModule.restore(ids, {
|
478
|
-
* returnLinkableKeys: ["variant_id"]
|
479
|
-
* })
|
480
|
-
*
|
481
|
-
* // do something with the returned cascaded entity IDs or return them
|
482
|
-
* }
|
286
|
+
* await productModuleService.restore(["prod_123", "prod_321"])
|
483
287
|
*/
|
484
288
|
restore<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
485
289
|
/**
|
@@ -496,35 +300,18 @@ export interface IProductModuleService extends IModuleService {
|
|
496
300
|
* A simple example that retrieves a product tag by its ID:
|
497
301
|
*
|
498
302
|
* ```ts
|
499
|
-
*
|
500
|
-
* initialize as initializeProductModule,
|
501
|
-
* } from "@medusajs/product"
|
502
|
-
*
|
503
|
-
* async function retrieveProductTag (tagId: string) {
|
504
|
-
* const productModule = await initializeProductModule()
|
505
|
-
*
|
506
|
-
* const productTag = await productModule.retrieveTag(tagId)
|
507
|
-
*
|
508
|
-
* // do something with the product tag or return it
|
509
|
-
* }
|
303
|
+
* const tag = await productModuleService.retrieveTag("ptag_123")
|
510
304
|
* ```
|
511
305
|
*
|
512
306
|
* To specify relations that should be retrieved:
|
513
307
|
*
|
514
308
|
* ```ts
|
515
|
-
*
|
516
|
-
*
|
517
|
-
*
|
518
|
-
*
|
519
|
-
*
|
520
|
-
*
|
521
|
-
*
|
522
|
-
* const productTag = await productModule.retrieveTag(tagId, {
|
523
|
-
* relations: ["products"]
|
524
|
-
* })
|
525
|
-
*
|
526
|
-
* // do something with the product tag or return it
|
527
|
-
* }
|
309
|
+
* const tag = await productModuleService.retrieveTag(
|
310
|
+
* "ptag_123",
|
311
|
+
* {
|
312
|
+
* relations: ["products"],
|
313
|
+
* }
|
314
|
+
* )
|
528
315
|
* ```
|
529
316
|
*/
|
530
317
|
retrieveTag(tagId: string, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO>;
|
@@ -542,90 +329,37 @@ export interface IProductModuleService extends IModuleService {
|
|
542
329
|
* To retrieve a list of product tags using their IDs:
|
543
330
|
*
|
544
331
|
* ```ts
|
545
|
-
*
|
546
|
-
*
|
547
|
-
* }
|
548
|
-
*
|
549
|
-
* async function retrieveProductTag (tagIds: string[]) {
|
550
|
-
* const productModule = await initializeProductModule()
|
551
|
-
*
|
552
|
-
* const productTags = await productModule.listTags({
|
553
|
-
* id: tagIds
|
554
|
-
* })
|
555
|
-
*
|
556
|
-
* // do something with the product tags or return them
|
557
|
-
* }
|
332
|
+
* const tags = await productModuleService.listTags({
|
333
|
+
* id: ["ptag_123", "ptag_321"],
|
334
|
+
* })
|
558
335
|
* ```
|
559
336
|
*
|
560
337
|
* To specify relations that should be retrieved within the product tags:
|
561
338
|
*
|
562
339
|
* ```ts
|
563
|
-
*
|
564
|
-
*
|
565
|
-
*
|
566
|
-
*
|
567
|
-
*
|
568
|
-
* const productModule = await initializeProductModule()
|
569
|
-
*
|
570
|
-
* const productTags = await productModule.listTags({
|
571
|
-
* id: tagIds
|
572
|
-
* }, {
|
573
|
-
* relations: ["products"]
|
574
|
-
* })
|
575
|
-
*
|
576
|
-
* // do something with the product tags or return them
|
577
|
-
* }
|
578
|
-
* ```
|
579
|
-
*
|
580
|
-
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
581
|
-
*
|
582
|
-
* ```ts
|
583
|
-
* import {
|
584
|
-
* initialize as initializeProductModule,
|
585
|
-
* } from "@medusajs/product"
|
586
|
-
*
|
587
|
-
* async function retrieveProductTag (tagIds: string[], skip: number, take: number) {
|
588
|
-
* const productModule = await initializeProductModule()
|
589
|
-
*
|
590
|
-
* const productTags = await productModule.listTags({
|
591
|
-
* id: tagIds
|
592
|
-
* }, {
|
340
|
+
* const tags = await productModuleService.listTags(
|
341
|
+
* {
|
342
|
+
* id: ["ptag_123", "ptag_321"],
|
343
|
+
* },
|
344
|
+
* {
|
593
345
|
* relations: ["products"],
|
594
|
-
*
|
595
|
-
*
|
596
|
-
* })
|
597
|
-
*
|
598
|
-
* // do something with the product tags or return them
|
599
|
-
* }
|
346
|
+
* }
|
347
|
+
* )
|
600
348
|
* ```
|
601
349
|
*
|
602
|
-
* You can
|
350
|
+
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
603
351
|
*
|
604
352
|
* ```ts
|
605
|
-
*
|
606
|
-
*
|
607
|
-
*
|
608
|
-
*
|
609
|
-
*
|
610
|
-
* const productModule = await initializeProductModule()
|
611
|
-
*
|
612
|
-
* const productTags = await productModule.listTags({
|
613
|
-
* $and: [
|
614
|
-
* {
|
615
|
-
* id: tagIds
|
616
|
-
* },
|
617
|
-
* {
|
618
|
-
* value
|
619
|
-
* }
|
620
|
-
* ]
|
621
|
-
* }, {
|
353
|
+
* const tags = await productModuleService.listTags(
|
354
|
+
* {
|
355
|
+
* id: ["ptag_123", "ptag_321"],
|
356
|
+
* },
|
357
|
+
* {
|
622
358
|
* relations: ["products"],
|
623
|
-
*
|
624
|
-
*
|
625
|
-
* }
|
626
|
-
*
|
627
|
-
* // do something with the product tags or return them
|
628
|
-
* }
|
359
|
+
* take: 20,
|
360
|
+
* skip: 2,
|
361
|
+
* }
|
362
|
+
* )
|
629
363
|
* ```
|
630
364
|
*/
|
631
365
|
listTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO[]>;
|
@@ -643,90 +377,40 @@ export interface IProductModuleService extends IModuleService {
|
|
643
377
|
* To retrieve a list of product tags using their IDs:
|
644
378
|
*
|
645
379
|
* ```ts
|
646
|
-
*
|
647
|
-
*
|
648
|
-
*
|
649
|
-
*
|
650
|
-
* async function retrieveProductTag (tagIds: string[]) {
|
651
|
-
* const productModule = await initializeProductModule()
|
652
|
-
*
|
653
|
-
* const [productTags, count] = await productModule.listAndCountTags({
|
654
|
-
* id: tagIds
|
380
|
+
* const [tags, count] =
|
381
|
+
* await productModuleService.listAndCountTags({
|
382
|
+
* id: ["ptag_123", "ptag_321"],
|
655
383
|
* })
|
656
|
-
*
|
657
|
-
* // do something with the product tags or return them
|
658
|
-
* }
|
659
384
|
* ```
|
660
385
|
*
|
661
386
|
* To specify relations that should be retrieved within the product tags:
|
662
387
|
*
|
663
388
|
* ```ts
|
664
|
-
*
|
665
|
-
*
|
666
|
-
*
|
667
|
-
*
|
668
|
-
*
|
669
|
-
*
|
670
|
-
*
|
671
|
-
*
|
672
|
-
*
|
673
|
-
* }, {
|
674
|
-
* relations: ["products"]
|
675
|
-
* })
|
676
|
-
*
|
677
|
-
* // do something with the product tags or return them
|
678
|
-
* }
|
389
|
+
* const [tags, count] =
|
390
|
+
* await productModuleService.listAndCountTags(
|
391
|
+
* {
|
392
|
+
* id: ["ptag_123", "ptag_321"],
|
393
|
+
* },
|
394
|
+
* {
|
395
|
+
* relations: ["products"],
|
396
|
+
* }
|
397
|
+
* )
|
679
398
|
* ```
|
680
399
|
*
|
681
400
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
682
401
|
*
|
683
402
|
* ```ts
|
684
|
-
*
|
685
|
-
*
|
686
|
-
*
|
687
|
-
*
|
688
|
-
*
|
689
|
-
*
|
690
|
-
*
|
691
|
-
*
|
692
|
-
*
|
693
|
-
*
|
694
|
-
*
|
695
|
-
* skip,
|
696
|
-
* take
|
697
|
-
* })
|
698
|
-
*
|
699
|
-
* // do something with the product tags or return them
|
700
|
-
* }
|
701
|
-
* ```
|
702
|
-
*
|
703
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
704
|
-
*
|
705
|
-
* ```ts
|
706
|
-
* import {
|
707
|
-
* initialize as initializeProductModule,
|
708
|
-
* } from "@medusajs/product"
|
709
|
-
*
|
710
|
-
* async function retrieveProductTag (tagIds: string[], value: string, skip: number, take: number) {
|
711
|
-
* const productModule = await initializeProductModule()
|
712
|
-
*
|
713
|
-
* const [productTags, count] = await productModule.listAndCountTags({
|
714
|
-
* $and: [
|
715
|
-
* {
|
716
|
-
* id: tagIds
|
717
|
-
* },
|
718
|
-
* {
|
719
|
-
* value
|
720
|
-
* }
|
721
|
-
* ]
|
722
|
-
* }, {
|
723
|
-
* relations: ["products"],
|
724
|
-
* skip,
|
725
|
-
* take
|
726
|
-
* })
|
727
|
-
*
|
728
|
-
* // do something with the product tags or return them
|
729
|
-
* }
|
403
|
+
* const [tags, count] =
|
404
|
+
* await productModuleService.listAndCountTags(
|
405
|
+
* {
|
406
|
+
* id: ["ptag_123", "ptag_321"],
|
407
|
+
* },
|
408
|
+
* {
|
409
|
+
* relations: ["products"],
|
410
|
+
* take: 20,
|
411
|
+
* skip: 2,
|
412
|
+
* }
|
413
|
+
* )
|
730
414
|
* ```
|
731
415
|
*/
|
732
416
|
listAndCountTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<[ProductTagDTO[], number]>;
|
@@ -738,21 +422,14 @@ export interface IProductModuleService extends IModuleService {
|
|
738
422
|
* @returns {Promise<ProductTagDTO[]>} The list of product tags.
|
739
423
|
*
|
740
424
|
* @example
|
741
|
-
*
|
742
|
-
*
|
743
|
-
*
|
744
|
-
*
|
745
|
-
*
|
746
|
-
*
|
747
|
-
*
|
748
|
-
*
|
749
|
-
* values.map((value) => ({
|
750
|
-
* value
|
751
|
-
* }))
|
752
|
-
* )
|
753
|
-
*
|
754
|
-
* // do something with the product tags or return them
|
755
|
-
* }
|
425
|
+
* const tags = await productModuleService.createTags([
|
426
|
+
* {
|
427
|
+
* value: "Clothes",
|
428
|
+
* },
|
429
|
+
* {
|
430
|
+
* value: "Accessories",
|
431
|
+
* },
|
432
|
+
* ])
|
756
433
|
*/
|
757
434
|
createTags(data: CreateProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
|
758
435
|
/**
|
@@ -763,22 +440,19 @@ export interface IProductModuleService extends IModuleService {
|
|
763
440
|
* @returns {Promise<ProductTagDTO[]>} The list of updated product tags.
|
764
441
|
*
|
765
442
|
* @example
|
766
|
-
*
|
767
|
-
*
|
768
|
-
*
|
443
|
+
* const productTags = await productModule.updateTags([
|
444
|
+
* {
|
445
|
+
* id,
|
446
|
+
* value
|
447
|
+
* }
|
448
|
+
* ])
|
769
449
|
*
|
770
|
-
*
|
771
|
-
* const productModule = await initializeProductModule()
|
450
|
+
* @ignore
|
772
451
|
*
|
773
|
-
*
|
774
|
-
*
|
775
|
-
*
|
776
|
-
*
|
777
|
-
* }
|
778
|
-
* ])
|
779
|
-
*
|
780
|
-
* // do something with the product tags or return them
|
781
|
-
* }
|
452
|
+
* @privateRemarks
|
453
|
+
* This method needs an update as it doesn't allow passing an ID of the tag to update
|
454
|
+
* So, for now, we've added the `@\ignore` tag to not show it in the generated docs.
|
455
|
+
* Once fixed, the `@\ignore` tag (and this comment) can be removed safely.
|
782
456
|
*/
|
783
457
|
updateTags(data: UpdateProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
|
784
458
|
/**
|
@@ -789,16 +463,10 @@ export interface IProductModuleService extends IModuleService {
|
|
789
463
|
* @returns {Promise<void>} Resolves when the product tags are successfully deleted.
|
790
464
|
*
|
791
465
|
* @example
|
792
|
-
*
|
793
|
-
*
|
794
|
-
*
|
795
|
-
*
|
796
|
-
* async function deleteProductTags (ids: string[]) {
|
797
|
-
* const productModule = await initializeProductModule()
|
798
|
-
*
|
799
|
-
* await productModule.deleteTags(ids)
|
800
|
-
*
|
801
|
-
* }
|
466
|
+
* await productModuleService.deleteTags([
|
467
|
+
* "ptag_123",
|
468
|
+
* "ptag_321",
|
469
|
+
* ])
|
802
470
|
*/
|
803
471
|
deleteTags(productTagIds: string[], sharedContext?: Context): Promise<void>;
|
804
472
|
/**
|
@@ -812,39 +480,8 @@ export interface IProductModuleService extends IModuleService {
|
|
812
480
|
* @returns {Promise<ProductTypeDTO>} The retrieved product type.
|
813
481
|
*
|
814
482
|
* @example
|
815
|
-
*
|
816
|
-
*
|
817
|
-
* ```ts
|
818
|
-
* import {
|
819
|
-
* initialize as initializeProductModule,
|
820
|
-
* } from "@medusajs/product"
|
821
|
-
*
|
822
|
-
* async function retrieveProductType (id: string) {
|
823
|
-
* const productModule = await initializeProductModule()
|
824
|
-
*
|
825
|
-
* const productType = await productModule.retrieveType(id)
|
826
|
-
*
|
827
|
-
* // do something with the product type or return it
|
828
|
-
* }
|
829
|
-
* ```
|
830
|
-
*
|
831
|
-
* To specify attributes that should be retrieved:
|
832
|
-
*
|
833
|
-
* ```ts
|
834
|
-
* import {
|
835
|
-
* initialize as initializeProductModule,
|
836
|
-
* } from "@medusajs/product"
|
837
|
-
*
|
838
|
-
* async function retrieveProductType (id: string) {
|
839
|
-
* const productModule = await initializeProductModule()
|
840
|
-
*
|
841
|
-
* const productType = await productModule.retrieveType(id, {
|
842
|
-
* select: ["value"]
|
843
|
-
* })
|
844
|
-
*
|
845
|
-
* // do something with the product type or return it
|
846
|
-
* }
|
847
|
-
* ```
|
483
|
+
* const productType =
|
484
|
+
* await productModuleService.retrieveType("ptyp_123")
|
848
485
|
*/
|
849
486
|
retrieveType(typeId: string, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO>;
|
850
487
|
/**
|
@@ -861,90 +498,23 @@ export interface IProductModuleService extends IModuleService {
|
|
861
498
|
* To retrieve a list of product types using their IDs:
|
862
499
|
*
|
863
500
|
* ```ts
|
864
|
-
*
|
865
|
-
*
|
866
|
-
* }
|
867
|
-
*
|
868
|
-
* async function retrieveProductTypes (ids: string[]) {
|
869
|
-
* const productModule = await initializeProductModule()
|
870
|
-
*
|
871
|
-
* const productTypes = await productModule.listTypes({
|
872
|
-
* id: ids
|
873
|
-
* })
|
874
|
-
*
|
875
|
-
* // do something with the product types or return them
|
876
|
-
* }
|
877
|
-
* ```
|
878
|
-
*
|
879
|
-
* To specify attributes that should be retrieved within the product types:
|
880
|
-
*
|
881
|
-
* ```ts
|
882
|
-
* import {
|
883
|
-
* initialize as initializeProductModule,
|
884
|
-
* } from "@medusajs/product"
|
885
|
-
*
|
886
|
-
* async function retrieveProductTypes (ids: string[]) {
|
887
|
-
* const productModule = await initializeProductModule()
|
888
|
-
*
|
889
|
-
* const productTypes = await productModule.listTypes({
|
890
|
-
* id: ids
|
891
|
-
* }, {
|
892
|
-
* select: ["value"]
|
893
|
-
* })
|
894
|
-
*
|
895
|
-
* // do something with the product types or return them
|
896
|
-
* }
|
501
|
+
* const productTypes = await productModuleService.listTypes({
|
502
|
+
* id: ["ptyp_123", "ptyp_321"],
|
503
|
+
* })
|
897
504
|
* ```
|
898
505
|
*
|
899
506
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
900
507
|
*
|
901
508
|
* ```ts
|
902
|
-
*
|
903
|
-
*
|
904
|
-
*
|
905
|
-
*
|
906
|
-
*
|
907
|
-
*
|
908
|
-
*
|
909
|
-
*
|
910
|
-
*
|
911
|
-
* }, {
|
912
|
-
* select: ["value"],
|
913
|
-
* skip,
|
914
|
-
* take
|
915
|
-
* })
|
916
|
-
*
|
917
|
-
* // do something with the product types or return them
|
918
|
-
* }
|
919
|
-
* ```
|
920
|
-
*
|
921
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
922
|
-
*
|
923
|
-
* ```ts
|
924
|
-
* import {
|
925
|
-
* initialize as initializeProductModule,
|
926
|
-
* } from "@medusajs/product"
|
927
|
-
*
|
928
|
-
* async function retrieveProductTypes (ids: string[], value: string, skip: number, take: number) {
|
929
|
-
* const productModule = await initializeProductModule()
|
930
|
-
*
|
931
|
-
* const productTypes = await productModule.listTypes({
|
932
|
-
* $and: [
|
933
|
-
* {
|
934
|
-
* id: ids
|
935
|
-
* },
|
936
|
-
* {
|
937
|
-
* value
|
938
|
-
* }
|
939
|
-
* ]
|
940
|
-
* }, {
|
941
|
-
* select: ["value"],
|
942
|
-
* skip,
|
943
|
-
* take
|
944
|
-
* })
|
945
|
-
*
|
946
|
-
* // do something with the product types or return them
|
947
|
-
* }
|
509
|
+
* const productTypes = await productModuleService.listTypes(
|
510
|
+
* {
|
511
|
+
* id: ["ptyp_123", "ptyp_321"],
|
512
|
+
* },
|
513
|
+
* {
|
514
|
+
* take: 20,
|
515
|
+
* skip: 2,
|
516
|
+
* }
|
517
|
+
* )
|
948
518
|
* ```
|
949
519
|
*/
|
950
520
|
listTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
@@ -962,90 +532,25 @@ export interface IProductModuleService extends IModuleService {
|
|
962
532
|
* To retrieve a list of product types using their IDs:
|
963
533
|
*
|
964
534
|
* ```ts
|
965
|
-
*
|
966
|
-
*
|
967
|
-
*
|
968
|
-
*
|
969
|
-
* async function retrieveProductTypes (ids: string[]) {
|
970
|
-
* const productModule = await initializeProductModule()
|
971
|
-
*
|
972
|
-
* const [productTypes, count] = await productModule.listAndCountTypes({
|
973
|
-
* id: ids
|
974
|
-
* })
|
975
|
-
*
|
976
|
-
* // do something with the product types or return them
|
977
|
-
* }
|
978
|
-
* ```
|
979
|
-
*
|
980
|
-
* To specify attributes that should be retrieved within the product types:
|
981
|
-
*
|
982
|
-
* ```ts
|
983
|
-
* import {
|
984
|
-
* initialize as initializeProductModule,
|
985
|
-
* } from "@medusajs/product"
|
986
|
-
*
|
987
|
-
* async function retrieveProductTypes (ids: string[]) {
|
988
|
-
* const productModule = await initializeProductModule()
|
989
|
-
*
|
990
|
-
* const [productTypes, count] = await productModule.listAndCountTypes({
|
991
|
-
* id: ids
|
992
|
-
* }, {
|
993
|
-
* select: ["value"]
|
535
|
+
* const [productTypes, count] =
|
536
|
+
* await productModuleService.listAndCountTypes({
|
537
|
+
* id: ["ptyp_123", "ptyp_321"],
|
994
538
|
* })
|
995
|
-
*
|
996
|
-
* // do something with the product types or return them
|
997
|
-
* }
|
998
539
|
* ```
|
999
540
|
*
|
1000
541
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1001
542
|
*
|
1002
543
|
* ```ts
|
1003
|
-
*
|
1004
|
-
*
|
1005
|
-
*
|
1006
|
-
*
|
1007
|
-
*
|
1008
|
-
*
|
1009
|
-
*
|
1010
|
-
*
|
1011
|
-
*
|
1012
|
-
*
|
1013
|
-
* select: ["value"],
|
1014
|
-
* skip,
|
1015
|
-
* take
|
1016
|
-
* })
|
1017
|
-
*
|
1018
|
-
* // do something with the product types or return them
|
1019
|
-
* }
|
1020
|
-
* ```
|
1021
|
-
*
|
1022
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
1023
|
-
*
|
1024
|
-
* ```ts
|
1025
|
-
* import {
|
1026
|
-
* initialize as initializeProductModule,
|
1027
|
-
* } from "@medusajs/product"
|
1028
|
-
*
|
1029
|
-
* async function retrieveProductTypes (ids: string[], value: string, skip: number, take: number) {
|
1030
|
-
* const productModule = await initializeProductModule()
|
1031
|
-
*
|
1032
|
-
* const [productTypes, count] = await productModule.listAndCountTypes({
|
1033
|
-
* $and: [
|
1034
|
-
* {
|
1035
|
-
* id: ids
|
1036
|
-
* },
|
1037
|
-
* {
|
1038
|
-
* value
|
1039
|
-
* }
|
1040
|
-
* ]
|
1041
|
-
* }, {
|
1042
|
-
* select: ["value"],
|
1043
|
-
* skip,
|
1044
|
-
* take
|
1045
|
-
* })
|
1046
|
-
*
|
1047
|
-
* // do something with the product types or return them
|
1048
|
-
* }
|
544
|
+
* const [productTypes, count] =
|
545
|
+
* await productModuleService.listAndCountTypes(
|
546
|
+
* {
|
547
|
+
* id: ["ptyp_123", "ptyp_321"],
|
548
|
+
* },
|
549
|
+
* {
|
550
|
+
* take: 20,
|
551
|
+
* skip: 2,
|
552
|
+
* }
|
553
|
+
* )
|
1049
554
|
* ```
|
1050
555
|
*/
|
1051
556
|
listAndCountTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<[ProductTypeDTO[], number]>;
|
@@ -1057,21 +562,11 @@ export interface IProductModuleService extends IModuleService {
|
|
1057
562
|
* @return {Promise<ProductTypeDTO[]>} The list of created product types.
|
1058
563
|
*
|
1059
564
|
* @example
|
1060
|
-
*
|
1061
|
-
*
|
1062
|
-
*
|
1063
|
-
*
|
1064
|
-
*
|
1065
|
-
* const productModule = await initializeProductModule()
|
1066
|
-
*
|
1067
|
-
* const productTypes = await productModule.createTypes([
|
1068
|
-
* {
|
1069
|
-
* value
|
1070
|
-
* }
|
1071
|
-
* ])
|
1072
|
-
*
|
1073
|
-
* // do something with the product types or return them
|
1074
|
-
* }
|
565
|
+
* const productTypes = await productModuleService.createTypes([
|
566
|
+
* {
|
567
|
+
* value: "digital",
|
568
|
+
* },
|
569
|
+
* ])
|
1075
570
|
*/
|
1076
571
|
createTypes(data: CreateProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
1077
572
|
/**
|
@@ -1082,21 +577,9 @@ export interface IProductModuleService extends IModuleService {
|
|
1082
577
|
* @returns {Promise<ProductTypeDTO>} The created product type.
|
1083
578
|
*
|
1084
579
|
* @example
|
1085
|
-
*
|
1086
|
-
*
|
1087
|
-
* }
|
1088
|
-
*
|
1089
|
-
* async function createType (title: string) {
|
1090
|
-
* const productModule = await initializeProductModule()
|
1091
|
-
*
|
1092
|
-
* const type = await productModule.createTypes(
|
1093
|
-
* {
|
1094
|
-
* value
|
1095
|
-
* }
|
1096
|
-
* )
|
1097
|
-
*
|
1098
|
-
* // do something with the product type or return them
|
1099
|
-
* }
|
580
|
+
* const productType = await productModuleService.createTypes({
|
581
|
+
* value: "digital",
|
582
|
+
* })
|
1100
583
|
*
|
1101
584
|
*/
|
1102
585
|
createTypes(data: CreateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
|
@@ -1108,21 +591,17 @@ export interface IProductModuleService extends IModuleService {
|
|
1108
591
|
* @returns {Promise<ProductTypeDTO[]>} The updated and created types.
|
1109
592
|
*
|
1110
593
|
* @example
|
1111
|
-
*
|
1112
|
-
*
|
1113
|
-
*
|
1114
|
-
*
|
1115
|
-
*
|
1116
|
-
*
|
1117
|
-
*
|
1118
|
-
*
|
1119
|
-
*
|
1120
|
-
*
|
1121
|
-
*
|
1122
|
-
* ])
|
1123
|
-
*
|
1124
|
-
* // do something with the types or return them
|
1125
|
-
* }
|
594
|
+
* const productTypes = await productModuleService.upsertTypes([
|
595
|
+
* {
|
596
|
+
* id: "ptyp_123",
|
597
|
+
* metadata: {
|
598
|
+
* test: true,
|
599
|
+
* },
|
600
|
+
* },
|
601
|
+
* {
|
602
|
+
* value: "Digital",
|
603
|
+
* },
|
604
|
+
* ])
|
1126
605
|
*/
|
1127
606
|
upsertTypes(data: UpsertProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
1128
607
|
/**
|
@@ -1133,21 +612,12 @@ export interface IProductModuleService extends IModuleService {
|
|
1133
612
|
* @returns {Promise<ProductTypeDTO>} The updated or created type.
|
1134
613
|
*
|
1135
614
|
* @example
|
1136
|
-
*
|
1137
|
-
*
|
1138
|
-
*
|
1139
|
-
*
|
1140
|
-
*
|
1141
|
-
*
|
1142
|
-
*
|
1143
|
-
* const createdType = await productModule.upsertTypes(
|
1144
|
-
* {
|
1145
|
-
* value
|
1146
|
-
* }
|
1147
|
-
* )
|
1148
|
-
*
|
1149
|
-
* // do something with the type or return it
|
1150
|
-
* }
|
615
|
+
* const productType = await productModuleService.upsertTypes({
|
616
|
+
* id: "ptyp_123",
|
617
|
+
* metadata: {
|
618
|
+
* test: true,
|
619
|
+
* },
|
620
|
+
* })
|
1151
621
|
*/
|
1152
622
|
upsertTypes(data: UpsertProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
|
1153
623
|
/**
|
@@ -1159,45 +629,31 @@ export interface IProductModuleService extends IModuleService {
|
|
1159
629
|
* @returns {Promise<ProductTypeDTO>} The updated type.
|
1160
630
|
*
|
1161
631
|
* @example
|
1162
|
-
*
|
1163
|
-
*
|
1164
|
-
*
|
1165
|
-
*
|
1166
|
-
*
|
1167
|
-
*
|
1168
|
-
*
|
1169
|
-
* const type = await productModule.updateTypes(id, {
|
1170
|
-
* value
|
1171
|
-
* }
|
1172
|
-
* )
|
1173
|
-
*
|
1174
|
-
* // do something with the type or return it
|
1175
|
-
* }
|
632
|
+
* const productType = await productModuleService.updateTypes(
|
633
|
+
* "ptyp_123",
|
634
|
+
* {
|
635
|
+
* value: "Digital",
|
636
|
+
* }
|
637
|
+
* )
|
1176
638
|
*/
|
1177
639
|
updateTypes(id: string, data: UpdateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
|
1178
640
|
/**
|
1179
|
-
* This method is used to update a list of types
|
641
|
+
* This method is used to update a list of types matching the specified filters.
|
1180
642
|
*
|
1181
|
-
* @param {FilterableProductTypeProps} selector - The filters
|
643
|
+
* @param {FilterableProductTypeProps} selector - The filters specifying which types to update.
|
1182
644
|
* @param {UpdateProductTypeDTO} data - The attributes to be updated on the selected types
|
1183
645
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
1184
646
|
* @returns {Promise<ProductTypeDTO[]>} The updated types.
|
1185
647
|
*
|
1186
648
|
* @example
|
1187
|
-
*
|
1188
|
-
*
|
1189
|
-
*
|
1190
|
-
*
|
1191
|
-
*
|
1192
|
-
*
|
1193
|
-
*
|
1194
|
-
*
|
1195
|
-
* value
|
1196
|
-
* }
|
1197
|
-
* )
|
1198
|
-
*
|
1199
|
-
* // do something with the types or return them
|
1200
|
-
* }
|
649
|
+
* const productTypes = await productModuleService.updateTypes(
|
650
|
+
* {
|
651
|
+
* id: ["ptyp_123", "ptyp_321"],
|
652
|
+
* },
|
653
|
+
* {
|
654
|
+
* value: "Digital",
|
655
|
+
* }
|
656
|
+
* )
|
1201
657
|
*/
|
1202
658
|
updateTypes(selector: FilterableProductTypeProps, data: UpdateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO[]>;
|
1203
659
|
/**
|
@@ -1208,15 +664,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1208
664
|
* @returns {Promise<void>} Resolves when the product types are successfully deleted.
|
1209
665
|
*
|
1210
666
|
* @example
|
1211
|
-
*
|
1212
|
-
*
|
1213
|
-
*
|
1214
|
-
*
|
1215
|
-
* async function deleteProductTypes (ids: string[]) {
|
1216
|
-
* const productModule = await initializeProductModule()
|
1217
|
-
*
|
1218
|
-
* await productModule.deleteTypes(ids)
|
1219
|
-
* }
|
667
|
+
* await productModuleService.deleteTypes([
|
668
|
+
* "ptyp_123",
|
669
|
+
* "ptyp_321",
|
670
|
+
* ])
|
1220
671
|
*/
|
1221
672
|
deleteTypes(productTypeIds: string[], sharedContext?: Context): Promise<void>;
|
1222
673
|
/**
|
@@ -1235,17 +686,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1235
686
|
* If there are no related records, the promise resolved to `void`.
|
1236
687
|
*
|
1237
688
|
* @example
|
1238
|
-
*
|
1239
|
-
*
|
1240
|
-
*
|
1241
|
-
*
|
1242
|
-
* async function deleteTypes (ids: string[]) {
|
1243
|
-
* const productModule = await initializeProductModule()
|
1244
|
-
*
|
1245
|
-
* const cascadedEntities = await productModule.softDeleteTypes(ids)
|
1246
|
-
*
|
1247
|
-
* // do something with the returned cascaded entity IDs or return them
|
1248
|
-
* }
|
689
|
+
* await productModuleService.softDeleteTypes([
|
690
|
+
* "ptyp_123",
|
691
|
+
* "ptyp_321",
|
692
|
+
* ])
|
1249
693
|
*/
|
1250
694
|
softDeleteTypes<TReturnableLinkableKeys extends string = string>(typeIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
1251
695
|
/**
|
@@ -1262,19 +706,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1262
706
|
* If there are no related records that were restored, the promise resolved to `void`.
|
1263
707
|
*
|
1264
708
|
* @example
|
1265
|
-
*
|
1266
|
-
*
|
1267
|
-
*
|
1268
|
-
*
|
1269
|
-
* async function restoreTypes (ids: string[]) {
|
1270
|
-
* const productModule = await initializeProductModule()
|
1271
|
-
*
|
1272
|
-
* const cascadedEntities = await productModule.restoreTypes(ids, {
|
1273
|
-
* returnLinkableKeys: []
|
1274
|
-
* })
|
1275
|
-
*
|
1276
|
-
* // do something with the returned cascaded entity IDs or return them
|
1277
|
-
* }
|
709
|
+
* await productModuleService.restoreTypes([
|
710
|
+
* "ptyp_123",
|
711
|
+
* "ptyp_321",
|
712
|
+
* ])
|
1278
713
|
*/
|
1279
714
|
restoreTypes<TReturnableLinkableKeys extends string = string>(typeIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
1280
715
|
/**
|
@@ -1291,35 +726,19 @@ export interface IProductModuleService extends IModuleService {
|
|
1291
726
|
* A simple example that retrieves a product option by its ID:
|
1292
727
|
*
|
1293
728
|
* ```ts
|
1294
|
-
*
|
1295
|
-
*
|
1296
|
-
* } from "@medusajs/product"
|
1297
|
-
*
|
1298
|
-
* async function retrieveProductOption (id: string) {
|
1299
|
-
* const productModule = await initializeProductModule()
|
1300
|
-
*
|
1301
|
-
* const productOption = await productModule.retrieveOption(id)
|
1302
|
-
*
|
1303
|
-
* // do something with the product option or return it
|
1304
|
-
* }
|
729
|
+
* const option =
|
730
|
+
* await productModuleService.retrieveOption("opt_123")
|
1305
731
|
* ```
|
1306
732
|
*
|
1307
733
|
* To specify relations that should be retrieved:
|
1308
734
|
*
|
1309
735
|
* ```ts
|
1310
|
-
*
|
1311
|
-
*
|
1312
|
-
*
|
1313
|
-
*
|
1314
|
-
*
|
1315
|
-
*
|
1316
|
-
*
|
1317
|
-
* const productOption = await productModule.retrieveOption(id, {
|
1318
|
-
* relations: ["product"]
|
1319
|
-
* })
|
1320
|
-
*
|
1321
|
-
* // do something with the product option or return it
|
1322
|
-
* }
|
736
|
+
* const option = await productModuleService.retrieveOption(
|
737
|
+
* "opt_123",
|
738
|
+
* {
|
739
|
+
* relations: ["product"],
|
740
|
+
* }
|
741
|
+
* )
|
1323
742
|
* ```
|
1324
743
|
*/
|
1325
744
|
retrieveOption(optionId: string, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO>;
|
@@ -1337,91 +756,39 @@ export interface IProductModuleService extends IModuleService {
|
|
1337
756
|
* To retrieve a list of product options using their IDs:
|
1338
757
|
*
|
1339
758
|
* ```ts
|
1340
|
-
*
|
1341
|
-
|
1342
|
-
* }
|
1343
|
-
*
|
1344
|
-
* async function retrieveProductOptions (ids: string[]) {
|
1345
|
-
* const productModule = await initializeProductModule()
|
1346
|
-
*
|
1347
|
-
* const productOptions = await productModule.listOptions({
|
1348
|
-
* id: ids
|
1349
|
-
* })
|
1350
|
-
*
|
1351
|
-
* // do something with the product options or return them
|
1352
|
-
* }
|
759
|
+
* const options = await productModuleService.listOptions({
|
760
|
+
id: ["opt_123", "opt_321"],
|
761
|
+
* })
|
1353
762
|
* ```
|
1354
763
|
*
|
1355
|
-
* To specify relations that should be retrieved within the product
|
764
|
+
* To specify relations that should be retrieved within the product options:
|
1356
765
|
*
|
1357
766
|
* ```ts
|
1358
|
-
*
|
1359
|
-
*
|
1360
|
-
*
|
1361
|
-
*
|
1362
|
-
*
|
1363
|
-
*
|
1364
|
-
*
|
1365
|
-
*
|
1366
|
-
* id: ids
|
1367
|
-
* }, {
|
1368
|
-
* relations: ["product"]
|
1369
|
-
* })
|
1370
|
-
*
|
1371
|
-
* // do something with the product options or return them
|
1372
|
-
* }
|
767
|
+
* const options = await productModuleService.listOptions(
|
768
|
+
* {
|
769
|
+
* id: ["opt_123", "opt_321"],
|
770
|
+
* },
|
771
|
+
* {
|
772
|
+
* relations: ["product"],
|
773
|
+
* }
|
774
|
+
* )
|
1373
775
|
* ```
|
1374
776
|
*
|
1375
777
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1376
778
|
*
|
1377
779
|
* ```ts
|
1378
|
-
*
|
1379
|
-
*
|
1380
|
-
*
|
1381
|
-
*
|
1382
|
-
*
|
1383
|
-
* const productModule = await initializeProductModule()
|
1384
|
-
*
|
1385
|
-
* const productOptions = await productModule.listOptions({
|
1386
|
-
* id: ids
|
1387
|
-
* }, {
|
780
|
+
* const options = await productModuleService.listOptions(
|
781
|
+
* {
|
782
|
+
* id: ["opt_123", "opt_321"],
|
783
|
+
* },
|
784
|
+
* {
|
1388
785
|
* relations: ["product"],
|
1389
|
-
*
|
1390
|
-
*
|
1391
|
-
* }
|
1392
|
-
*
|
1393
|
-
* // do something with the product options or return them
|
1394
|
-
* }
|
786
|
+
* take: 20,
|
787
|
+
* skip: 2,
|
788
|
+
* }
|
789
|
+
* )
|
1395
790
|
* ```
|
1396
791
|
*
|
1397
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
1398
|
-
*
|
1399
|
-
* ```ts
|
1400
|
-
* import {
|
1401
|
-
* initialize as initializeProductModule,
|
1402
|
-
* } from "@medusajs/product"
|
1403
|
-
*
|
1404
|
-
* async function retrieveProductOptions (ids: string[], title: string, skip: number, take: number) {
|
1405
|
-
* const productModule = await initializeProductModule()
|
1406
|
-
*
|
1407
|
-
* const productOptions = await productModule.listOptions({
|
1408
|
-
* $and: [
|
1409
|
-
* {
|
1410
|
-
* id: ids
|
1411
|
-
* },
|
1412
|
-
* {
|
1413
|
-
* title
|
1414
|
-
* }
|
1415
|
-
* ]
|
1416
|
-
* }, {
|
1417
|
-
* relations: ["product"],
|
1418
|
-
* skip,
|
1419
|
-
* take
|
1420
|
-
* })
|
1421
|
-
*
|
1422
|
-
* // do something with the product options or return them
|
1423
|
-
* }
|
1424
|
-
* ```
|
1425
792
|
*/
|
1426
793
|
listOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
1427
794
|
/**
|
@@ -1438,90 +805,40 @@ export interface IProductModuleService extends IModuleService {
|
|
1438
805
|
* To retrieve a list of product options using their IDs:
|
1439
806
|
*
|
1440
807
|
* ```ts
|
1441
|
-
*
|
1442
|
-
*
|
1443
|
-
*
|
1444
|
-
*
|
1445
|
-
* async function retrieveProductOptions (ids: string[]) {
|
1446
|
-
* const productModule = await initializeProductModule()
|
1447
|
-
*
|
1448
|
-
* const [productOptions, count] = await productModule.listAndCountOptions({
|
1449
|
-
* id: ids
|
808
|
+
* const [options, count] =
|
809
|
+
* await productModuleService.listAndCountOptions({
|
810
|
+
* id: ["opt_123", "opt_321"],
|
1450
811
|
* })
|
1451
|
-
*
|
1452
|
-
* // do something with the product options or return them
|
1453
|
-
* }
|
1454
812
|
* ```
|
1455
813
|
*
|
1456
814
|
* To specify relations that should be retrieved within the product types:
|
1457
815
|
*
|
1458
816
|
* ```ts
|
1459
|
-
*
|
1460
|
-
*
|
1461
|
-
*
|
1462
|
-
*
|
1463
|
-
*
|
1464
|
-
*
|
1465
|
-
*
|
1466
|
-
*
|
1467
|
-
*
|
1468
|
-
* }, {
|
1469
|
-
* relations: ["product"]
|
1470
|
-
* })
|
1471
|
-
*
|
1472
|
-
* // do something with the product options or return them
|
1473
|
-
* }
|
817
|
+
* const [options, count] =
|
818
|
+
* await productModuleService.listAndCountOptions(
|
819
|
+
* {
|
820
|
+
* id: ["opt_123", "opt_321"],
|
821
|
+
* },
|
822
|
+
* {
|
823
|
+
* relations: ["product"],
|
824
|
+
* }
|
825
|
+
* )
|
1474
826
|
* ```
|
1475
827
|
*
|
1476
828
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1477
829
|
*
|
1478
830
|
* ```ts
|
1479
|
-
*
|
1480
|
-
*
|
1481
|
-
*
|
1482
|
-
*
|
1483
|
-
*
|
1484
|
-
*
|
1485
|
-
*
|
1486
|
-
*
|
1487
|
-
*
|
1488
|
-
*
|
1489
|
-
*
|
1490
|
-
* skip,
|
1491
|
-
* take
|
1492
|
-
* })
|
1493
|
-
*
|
1494
|
-
* // do something with the product options or return them
|
1495
|
-
* }
|
1496
|
-
* ```
|
1497
|
-
*
|
1498
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
1499
|
-
*
|
1500
|
-
* ```ts
|
1501
|
-
* import {
|
1502
|
-
* initialize as initializeProductModule,
|
1503
|
-
* } from "@medusajs/product"
|
1504
|
-
*
|
1505
|
-
* async function retrieveProductOptions (ids: string[], title: string, skip: number, take: number) {
|
1506
|
-
* const productModule = await initializeProductModule()
|
1507
|
-
*
|
1508
|
-
* const [productOptions, count] = await productModule.listAndCountOptions({
|
1509
|
-
* $and: [
|
1510
|
-
* {
|
1511
|
-
* id: ids
|
1512
|
-
* },
|
1513
|
-
* {
|
1514
|
-
* title
|
1515
|
-
* }
|
1516
|
-
* ]
|
1517
|
-
* }, {
|
1518
|
-
* relations: ["product"],
|
1519
|
-
* skip,
|
1520
|
-
* take
|
1521
|
-
* })
|
1522
|
-
*
|
1523
|
-
* // do something with the product options or return them
|
1524
|
-
* }
|
831
|
+
* const [options, count] =
|
832
|
+
* await productModuleService.listAndCountOptions(
|
833
|
+
* {
|
834
|
+
* id: ["opt_123", "opt_321"],
|
835
|
+
* },
|
836
|
+
* {
|
837
|
+
* relations: ["product"],
|
838
|
+
* take: 20,
|
839
|
+
* skip: 2,
|
840
|
+
* }
|
841
|
+
* )
|
1525
842
|
* ```
|
1526
843
|
*/
|
1527
844
|
listAndCountOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<[ProductOptionDTO[], number]>;
|
@@ -1533,21 +850,18 @@ export interface IProductModuleService extends IModuleService {
|
|
1533
850
|
* @returns {Promise<ProductOptionDTO[]>} The list of created product options.
|
1534
851
|
*
|
1535
852
|
* @example
|
1536
|
-
*
|
1537
|
-
*
|
1538
|
-
*
|
1539
|
-
*
|
1540
|
-
*
|
1541
|
-
*
|
1542
|
-
*
|
1543
|
-
*
|
1544
|
-
*
|
1545
|
-
*
|
1546
|
-
*
|
1547
|
-
*
|
1548
|
-
*
|
1549
|
-
* // do something with the product options or return them
|
1550
|
-
* }
|
853
|
+
* const options = await productModuleService.createOptions([
|
854
|
+
* {
|
855
|
+
* title: "Color",
|
856
|
+
* values: ["Blue", "Green"],
|
857
|
+
* product_id: "prod_123",
|
858
|
+
* },
|
859
|
+
* {
|
860
|
+
* title: "Size",
|
861
|
+
* values: ["Small", "Medium"],
|
862
|
+
* product_id: "prod_321",
|
863
|
+
* },
|
864
|
+
* ])
|
1551
865
|
*
|
1552
866
|
*/
|
1553
867
|
createOptions(data: CreateProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
@@ -1559,21 +873,11 @@ export interface IProductModuleService extends IModuleService {
|
|
1559
873
|
* @returns {Promise<ProductOptionDTO>} The created product option.
|
1560
874
|
*
|
1561
875
|
* @example
|
1562
|
-
*
|
1563
|
-
*
|
1564
|
-
*
|
1565
|
-
*
|
1566
|
-
*
|
1567
|
-
* const productModule = await initializeProductModule()
|
1568
|
-
*
|
1569
|
-
* const option = await productModule.createOptions(
|
1570
|
-
* {
|
1571
|
-
* title
|
1572
|
-
* }
|
1573
|
-
* )
|
1574
|
-
*
|
1575
|
-
* // do something with the product option or return them
|
1576
|
-
* }
|
876
|
+
* const option = await productModuleService.createOptions({
|
877
|
+
* title: "Color",
|
878
|
+
* values: ["Blue", "Green"],
|
879
|
+
* product_id: "prod_123",
|
880
|
+
* })
|
1577
881
|
*
|
1578
882
|
*/
|
1579
883
|
createOptions(data: CreateProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO>;
|
@@ -1585,21 +889,17 @@ export interface IProductModuleService extends IModuleService {
|
|
1585
889
|
* @returns {Promise<ProductOptionDTO[]>} The updated and created options.
|
1586
890
|
*
|
1587
891
|
* @example
|
1588
|
-
*
|
1589
|
-
*
|
1590
|
-
*
|
1591
|
-
*
|
1592
|
-
*
|
1593
|
-
*
|
1594
|
-
*
|
1595
|
-
*
|
1596
|
-
*
|
1597
|
-
*
|
1598
|
-
*
|
1599
|
-
* ])
|
1600
|
-
*
|
1601
|
-
* // do something with the options or return them
|
1602
|
-
* }
|
892
|
+
* const options = await productModuleService.upsertOptions([
|
893
|
+
* {
|
894
|
+
* id: "opt_123",
|
895
|
+
* title: "Color",
|
896
|
+
* },
|
897
|
+
* {
|
898
|
+
* title: "Color",
|
899
|
+
* values: ["Blue", "Green"],
|
900
|
+
* product_id: "prod_123",
|
901
|
+
* },
|
902
|
+
* ])
|
1603
903
|
*/
|
1604
904
|
upsertOptions(data: UpsertProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
1605
905
|
/**
|
@@ -1610,21 +910,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1610
910
|
* @returns {Promise<ProductOptionDTO>} The updated or created option.
|
1611
911
|
*
|
1612
912
|
* @example
|
1613
|
-
*
|
1614
|
-
*
|
1615
|
-
*
|
1616
|
-
*
|
1617
|
-
* async function upsertOption (title: string) {
|
1618
|
-
* const productModule = await initializeProductModule()
|
1619
|
-
*
|
1620
|
-
* const createdOption = await productModule.upsertOptions(
|
1621
|
-
* {
|
1622
|
-
* title
|
1623
|
-
* }
|
1624
|
-
* )
|
1625
|
-
*
|
1626
|
-
* // do something with the option or return it
|
1627
|
-
* }
|
913
|
+
* const option = await productModuleService.upsertOptions({
|
914
|
+
* id: "opt_123",
|
915
|
+
* title: "Color",
|
916
|
+
* })
|
1628
917
|
*/
|
1629
918
|
upsertOptions(data: UpsertProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO>;
|
1630
919
|
/**
|
@@ -1636,45 +925,31 @@ export interface IProductModuleService extends IModuleService {
|
|
1636
925
|
* @returns {Promise<ProductOptionDTO>} The updated option.
|
1637
926
|
*
|
1638
927
|
* @example
|
1639
|
-
*
|
1640
|
-
*
|
1641
|
-
*
|
1642
|
-
*
|
1643
|
-
*
|
1644
|
-
*
|
1645
|
-
*
|
1646
|
-
* const option = await productModule.updateOptions(id, {
|
1647
|
-
* title
|
1648
|
-
* }
|
1649
|
-
* )
|
1650
|
-
*
|
1651
|
-
* // do something with the option or return it
|
1652
|
-
* }
|
928
|
+
* const option = await productModuleService.updateOptions(
|
929
|
+
* "opt_123",
|
930
|
+
* {
|
931
|
+
* title: "Color",
|
932
|
+
* }
|
933
|
+
* )
|
1653
934
|
*/
|
1654
935
|
updateOptions(id: string, data: UpdateProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO>;
|
1655
936
|
/**
|
1656
|
-
* This method is used to update a list of options
|
937
|
+
* This method is used to update a list of options matching the specified filters.
|
1657
938
|
*
|
1658
|
-
* @param {FilterableProductOptionProps} selector - The filters
|
939
|
+
* @param {FilterableProductOptionProps} selector - The filters specifying which options to update.
|
1659
940
|
* @param {UpdateProductOptionDTO} data - The attributes to be updated on the selected options
|
1660
941
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
1661
942
|
* @returns {Promise<ProductOptionDTO[]>} The updated options.
|
1662
943
|
*
|
1663
944
|
* @example
|
1664
|
-
*
|
1665
|
-
*
|
1666
|
-
*
|
1667
|
-
*
|
1668
|
-
*
|
1669
|
-
*
|
1670
|
-
*
|
1671
|
-
*
|
1672
|
-
* title
|
1673
|
-
* }
|
1674
|
-
* )
|
1675
|
-
*
|
1676
|
-
* // do something with the options or return them
|
1677
|
-
* }
|
945
|
+
* const options = await productModuleService.updateOptions(
|
946
|
+
* {
|
947
|
+
* title: "Color",
|
948
|
+
* },
|
949
|
+
* {
|
950
|
+
* values: ["Blue", "Green"],
|
951
|
+
* }
|
952
|
+
* )
|
1678
953
|
*/
|
1679
954
|
updateOptions(selector: FilterableProductOptionProps, data: UpdateProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO[]>;
|
1680
955
|
/**
|
@@ -1685,15 +960,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1685
960
|
* @returns {Promise<void>} Resolves when the product options are successfully deleted.
|
1686
961
|
*
|
1687
962
|
* @example
|
1688
|
-
*
|
1689
|
-
*
|
1690
|
-
*
|
1691
|
-
*
|
1692
|
-
* async function deleteProductOptions (ids: string[]) {
|
1693
|
-
* const productModule = await initializeProductModule()
|
1694
|
-
*
|
1695
|
-
* await productModule.deleteOptions(ids)
|
1696
|
-
* }
|
963
|
+
* await productModuleService.deleteOptions([
|
964
|
+
* "opt_123",
|
965
|
+
* "opt_321",
|
966
|
+
* ])
|
1697
967
|
*/
|
1698
968
|
deleteOptions(productOptionIds: string[], sharedContext?: Context): Promise<void>;
|
1699
969
|
/**
|
@@ -1712,17 +982,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1712
982
|
* If there are no related records, the promise resolved to `void`.
|
1713
983
|
*
|
1714
984
|
* @example
|
1715
|
-
*
|
1716
|
-
*
|
1717
|
-
*
|
1718
|
-
*
|
1719
|
-
* async function deleteOptions (ids: string[]) {
|
1720
|
-
* const productModule = await initializeProductModule()
|
1721
|
-
*
|
1722
|
-
* const cascadedEntities = await productModule.softDeleteOptions(ids)
|
1723
|
-
*
|
1724
|
-
* // do something with the returned cascaded entity IDs or return them
|
1725
|
-
* }
|
985
|
+
* await productModuleService.softDeleteOptions([
|
986
|
+
* "opt_123",
|
987
|
+
* "opt_321",
|
988
|
+
* ])
|
1726
989
|
*/
|
1727
990
|
softDeleteOptions<TReturnableLinkableKeys extends string = string>(optionIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
1728
991
|
/**
|
@@ -1739,19 +1002,10 @@ export interface IProductModuleService extends IModuleService {
|
|
1739
1002
|
* If there are no related records that were restored, the promise resolved to `void`.
|
1740
1003
|
*
|
1741
1004
|
* @example
|
1742
|
-
*
|
1743
|
-
*
|
1744
|
-
*
|
1745
|
-
*
|
1746
|
-
* async function restoreOptions (ids: string[]) {
|
1747
|
-
* const productModule = await initializeProductModule()
|
1748
|
-
*
|
1749
|
-
* const cascadedEntities = await productModule.restoreOptions(ids, {
|
1750
|
-
* returnLinkableKeys: ["option_value_id"]
|
1751
|
-
* })
|
1752
|
-
*
|
1753
|
-
* // do something with the returned cascaded entity IDs or return them
|
1754
|
-
* }
|
1005
|
+
* await productModuleService.restoreOptions([
|
1006
|
+
* "opt_123",
|
1007
|
+
* "opt_321",
|
1008
|
+
* ])
|
1755
1009
|
*/
|
1756
1010
|
restoreOptions<TReturnableLinkableKeys extends string = string>(optionIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
1757
1011
|
/**
|
@@ -1768,35 +1022,19 @@ export interface IProductModuleService extends IModuleService {
|
|
1768
1022
|
* A simple example that retrieves a product variant by its ID:
|
1769
1023
|
*
|
1770
1024
|
* ```ts
|
1771
|
-
*
|
1772
|
-
*
|
1773
|
-
* } from "@medusajs/product"
|
1774
|
-
*
|
1775
|
-
* async function retrieveProductVariant (id: string) {
|
1776
|
-
* const productModule = await initializeProductModule()
|
1777
|
-
*
|
1778
|
-
* const variant = await productModule.retrieveVariant(id)
|
1779
|
-
*
|
1780
|
-
* // do something with the product variant or return it
|
1781
|
-
* }
|
1025
|
+
* const variant =
|
1026
|
+
* await productModuleService.retrieveVariant("variant_123")
|
1782
1027
|
* ```
|
1783
1028
|
*
|
1784
1029
|
* To specify relations that should be retrieved:
|
1785
1030
|
*
|
1786
|
-
* ```ts
|
1787
|
-
*
|
1788
|
-
*
|
1789
|
-
*
|
1790
|
-
*
|
1791
|
-
*
|
1792
|
-
*
|
1793
|
-
*
|
1794
|
-
* const variant = await productModule.retrieveVariant(id, {
|
1795
|
-
* relations: ["options"]
|
1796
|
-
* })
|
1797
|
-
*
|
1798
|
-
* // do something with the product variant or return it
|
1799
|
-
* }
|
1031
|
+
* ```ts
|
1032
|
+
* const variant = await productModuleService.retrieveVariant(
|
1033
|
+
* "variant_123",
|
1034
|
+
* {
|
1035
|
+
* relations: ["options"],
|
1036
|
+
* }
|
1037
|
+
* )
|
1800
1038
|
* ```
|
1801
1039
|
*/
|
1802
1040
|
retrieveVariant(productVariantId: string, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<ProductVariantDTO>;
|
@@ -1814,90 +1052,37 @@ export interface IProductModuleService extends IModuleService {
|
|
1814
1052
|
* To retrieve a list of product variants using their IDs:
|
1815
1053
|
*
|
1816
1054
|
* ```ts
|
1817
|
-
*
|
1818
|
-
*
|
1819
|
-
* }
|
1820
|
-
*
|
1821
|
-
* async function retrieveProductVariants (ids: string[]) {
|
1822
|
-
* const productModule = await initializeProductModule()
|
1823
|
-
*
|
1824
|
-
* const variants = await productModule.listVariants({
|
1825
|
-
* id: ids
|
1826
|
-
* })
|
1827
|
-
*
|
1828
|
-
* // do something with the product variants or return them
|
1829
|
-
* }
|
1055
|
+
* const variants = await productModuleService.listVariants({
|
1056
|
+
* id: ["variant_123", "variant_321"],
|
1057
|
+
* })
|
1830
1058
|
* ```
|
1831
1059
|
*
|
1832
1060
|
* To specify relations that should be retrieved within the product variants:
|
1833
1061
|
*
|
1834
1062
|
* ```ts
|
1835
|
-
*
|
1836
|
-
*
|
1837
|
-
*
|
1838
|
-
*
|
1839
|
-
*
|
1840
|
-
* const productModule = await initializeProductModule()
|
1841
|
-
*
|
1842
|
-
* const variants = await productModule.listVariants({
|
1843
|
-
* id: ids
|
1844
|
-
* }, {
|
1845
|
-
* relations: ["options"]
|
1846
|
-
* })
|
1847
|
-
*
|
1848
|
-
* // do something with the product variants or return them
|
1849
|
-
* }
|
1850
|
-
* ```
|
1851
|
-
*
|
1852
|
-
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1853
|
-
*
|
1854
|
-
* ```ts
|
1855
|
-
* import {
|
1856
|
-
* initialize as initializeProductModule,
|
1857
|
-
* } from "@medusajs/product"
|
1858
|
-
*
|
1859
|
-
* async function retrieveProductVariants (ids: string[], skip: number, take: number) {
|
1860
|
-
* const productModule = await initializeProductModule()
|
1861
|
-
*
|
1862
|
-
* const variants = await productModule.listVariants({
|
1863
|
-
* id: ids
|
1864
|
-
* }, {
|
1063
|
+
* const variants = await productModuleService.listVariants(
|
1064
|
+
* {
|
1065
|
+
* id: ["variant_123", "variant_321"],
|
1066
|
+
* },
|
1067
|
+
* {
|
1865
1068
|
* relations: ["options"],
|
1866
|
-
*
|
1867
|
-
*
|
1868
|
-
* })
|
1869
|
-
*
|
1870
|
-
* // do something with the product variants or return them
|
1871
|
-
* }
|
1069
|
+
* }
|
1070
|
+
* )
|
1872
1071
|
* ```
|
1873
1072
|
*
|
1874
|
-
* You can
|
1073
|
+
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1875
1074
|
*
|
1876
1075
|
* ```ts
|
1877
|
-
*
|
1878
|
-
*
|
1879
|
-
*
|
1880
|
-
*
|
1881
|
-
*
|
1882
|
-
* const productModule = await initializeProductModule()
|
1883
|
-
*
|
1884
|
-
* const variants = await productModule.listVariants({
|
1885
|
-
* $and: [
|
1886
|
-
* {
|
1887
|
-
* id: ids
|
1888
|
-
* },
|
1889
|
-
* {
|
1890
|
-
* sku
|
1891
|
-
* }
|
1892
|
-
* ]
|
1893
|
-
* }, {
|
1076
|
+
* const variants = await productModuleService.listVariants(
|
1077
|
+
* {
|
1078
|
+
* id: ["variant_123", "variant_321"],
|
1079
|
+
* },
|
1080
|
+
* {
|
1894
1081
|
* relations: ["options"],
|
1895
|
-
*
|
1896
|
-
*
|
1897
|
-
* }
|
1898
|
-
*
|
1899
|
-
* // do something with the product variants or return them
|
1900
|
-
* }
|
1082
|
+
* take: 20,
|
1083
|
+
* skip: 2,
|
1084
|
+
* }
|
1085
|
+
* )
|
1901
1086
|
* ```
|
1902
1087
|
*/
|
1903
1088
|
listVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<ProductVariantDTO[]>;
|
@@ -1915,90 +1100,40 @@ export interface IProductModuleService extends IModuleService {
|
|
1915
1100
|
* To retrieve a list of product variants using their IDs:
|
1916
1101
|
*
|
1917
1102
|
* ```ts
|
1918
|
-
*
|
1919
|
-
*
|
1920
|
-
*
|
1921
|
-
*
|
1922
|
-
* async function retrieveProductVariants (ids: string[]) {
|
1923
|
-
* const productModule = await initializeProductModule()
|
1924
|
-
*
|
1925
|
-
* const [variants, count] = await productModule.listAndCountVariants({
|
1926
|
-
* id: ids
|
1103
|
+
* const [variants, count] =
|
1104
|
+
* await productModuleService.listAndCountVariants({
|
1105
|
+
* id: ["variant_123", "variant_321"],
|
1927
1106
|
* })
|
1928
|
-
*
|
1929
|
-
* // do something with the product variants or return them
|
1930
|
-
* }
|
1931
1107
|
* ```
|
1932
1108
|
*
|
1933
1109
|
* To specify relations that should be retrieved within the product variants:
|
1934
1110
|
*
|
1935
1111
|
* ```ts
|
1936
|
-
*
|
1937
|
-
*
|
1938
|
-
*
|
1939
|
-
*
|
1940
|
-
*
|
1941
|
-
*
|
1942
|
-
*
|
1943
|
-
*
|
1944
|
-
*
|
1945
|
-
* }, {
|
1946
|
-
* relations: ["options"]
|
1947
|
-
* })
|
1948
|
-
*
|
1949
|
-
* // do something with the product variants or return them
|
1950
|
-
* }
|
1112
|
+
* const [variants, count] =
|
1113
|
+
* await productModuleService.listAndCountVariants(
|
1114
|
+
* {
|
1115
|
+
* id: ["variant_123", "variant_321"],
|
1116
|
+
* },
|
1117
|
+
* {
|
1118
|
+
* relations: ["options"],
|
1119
|
+
* }
|
1120
|
+
* )
|
1951
1121
|
* ```
|
1952
1122
|
*
|
1953
1123
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
1954
1124
|
*
|
1955
1125
|
* ```ts
|
1956
|
-
*
|
1957
|
-
*
|
1958
|
-
*
|
1959
|
-
*
|
1960
|
-
*
|
1961
|
-
*
|
1962
|
-
*
|
1963
|
-
*
|
1964
|
-
*
|
1965
|
-
*
|
1966
|
-
*
|
1967
|
-
* skip,
|
1968
|
-
* take
|
1969
|
-
* })
|
1970
|
-
*
|
1971
|
-
* // do something with the product variants or return them
|
1972
|
-
* }
|
1973
|
-
* ```
|
1974
|
-
*
|
1975
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
1976
|
-
*
|
1977
|
-
* ```ts
|
1978
|
-
* import {
|
1979
|
-
* initialize as initializeProductModule,
|
1980
|
-
* } from "@medusajs/product"
|
1981
|
-
*
|
1982
|
-
* async function retrieveProductVariants (ids: string[], sku: string, skip: number, take: number) {
|
1983
|
-
* const productModule = await initializeProductModule()
|
1984
|
-
*
|
1985
|
-
* const [variants, count] = await productModule.listAndCountVariants({
|
1986
|
-
* $and: [
|
1987
|
-
* {
|
1988
|
-
* id: ids
|
1989
|
-
* },
|
1990
|
-
* {
|
1991
|
-
* sku
|
1992
|
-
* }
|
1993
|
-
* ]
|
1994
|
-
* }, {
|
1995
|
-
* relations: ["options"],
|
1996
|
-
* skip,
|
1997
|
-
* take
|
1998
|
-
* })
|
1999
|
-
*
|
2000
|
-
* // do something with the product variants or return them
|
2001
|
-
* }
|
1126
|
+
* const [variants, count] =
|
1127
|
+
* await productModuleService.listAndCountVariants(
|
1128
|
+
* {
|
1129
|
+
* id: ["variant_123", "variant_321"],
|
1130
|
+
* },
|
1131
|
+
* {
|
1132
|
+
* relations: ["options"],
|
1133
|
+
* take: 20,
|
1134
|
+
* skip: 2,
|
1135
|
+
* }
|
1136
|
+
* )
|
2002
1137
|
* ```
|
2003
1138
|
*/
|
2004
1139
|
listAndCountVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<[ProductVariantDTO[], number]>;
|
@@ -2010,21 +1145,22 @@ export interface IProductModuleService extends IModuleService {
|
|
2010
1145
|
* @returns {Promise<ProductVariantDTO[]>} The list of created product variants.
|
2011
1146
|
*
|
2012
1147
|
* @example
|
2013
|
-
*
|
2014
|
-
*
|
2015
|
-
*
|
2016
|
-
*
|
2017
|
-
*
|
2018
|
-
*
|
2019
|
-
*
|
2020
|
-
*
|
2021
|
-
*
|
2022
|
-
*
|
2023
|
-
*
|
2024
|
-
*
|
2025
|
-
*
|
2026
|
-
*
|
2027
|
-
*
|
1148
|
+
* const variants = await productModuleService.createVariants([
|
1149
|
+
* {
|
1150
|
+
* title: "Blue Shirt",
|
1151
|
+
* product_id: "prod_123",
|
1152
|
+
* options: {
|
1153
|
+
* Color: "Blue",
|
1154
|
+
* },
|
1155
|
+
* },
|
1156
|
+
* {
|
1157
|
+
* title: "Green Shirt",
|
1158
|
+
* product_id: "prod_321",
|
1159
|
+
* options: {
|
1160
|
+
* Color: "Green",
|
1161
|
+
* },
|
1162
|
+
* },
|
1163
|
+
* ])
|
2028
1164
|
*
|
2029
1165
|
*/
|
2030
1166
|
createVariants(data: CreateProductVariantDTO[], sharedContext?: Context): Promise<ProductVariantDTO[]>;
|
@@ -2036,21 +1172,13 @@ export interface IProductModuleService extends IModuleService {
|
|
2036
1172
|
* @returns {Promise<ProductVariantDTO>} The created product variant.
|
2037
1173
|
*
|
2038
1174
|
* @example
|
2039
|
-
*
|
2040
|
-
*
|
2041
|
-
*
|
2042
|
-
*
|
2043
|
-
*
|
2044
|
-
*
|
2045
|
-
*
|
2046
|
-
* const variant = await productModule.createVariants(
|
2047
|
-
* {
|
2048
|
-
* title
|
2049
|
-
* }
|
2050
|
-
* )
|
2051
|
-
*
|
2052
|
-
* // do something with the product variant or return them
|
2053
|
-
* }
|
1175
|
+
* const variant = await productModuleService.createVariants({
|
1176
|
+
* title: "Blue Shirt",
|
1177
|
+
* product_id: "prod_123",
|
1178
|
+
* options: {
|
1179
|
+
* Color: "Blue",
|
1180
|
+
* },
|
1181
|
+
* })
|
2054
1182
|
*
|
2055
1183
|
*/
|
2056
1184
|
createVariants(data: CreateProductVariantDTO, sharedContext?: Context): Promise<ProductVariantDTO>;
|
@@ -2062,21 +1190,18 @@ export interface IProductModuleService extends IModuleService {
|
|
2062
1190
|
* @returns {Promise<ProductVariantDTO[]>} The updated and created variants.
|
2063
1191
|
*
|
2064
1192
|
* @example
|
2065
|
-
*
|
2066
|
-
*
|
2067
|
-
*
|
2068
|
-
*
|
2069
|
-
*
|
2070
|
-
*
|
2071
|
-
*
|
2072
|
-
*
|
2073
|
-
*
|
2074
|
-
*
|
2075
|
-
*
|
2076
|
-
*
|
2077
|
-
*
|
2078
|
-
* // do something with the variants or return them
|
2079
|
-
* }
|
1193
|
+
* const variants = await productModuleService.upsertVariants([
|
1194
|
+
* {
|
1195
|
+
* id: "variant_123",
|
1196
|
+
* title: "Green Shirt",
|
1197
|
+
* },
|
1198
|
+
* {
|
1199
|
+
* title: "Blue Shirt",
|
1200
|
+
* options: {
|
1201
|
+
* Color: "Blue",
|
1202
|
+
* },
|
1203
|
+
* },
|
1204
|
+
* ])
|
2080
1205
|
*/
|
2081
1206
|
upsertVariants(data: UpsertProductVariantDTO[], sharedContext?: Context): Promise<ProductVariantDTO[]>;
|
2082
1207
|
/**
|
@@ -2087,21 +1212,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2087
1212
|
* @returns {Promise<ProductVariantDTO>} The updated or created variant.
|
2088
1213
|
*
|
2089
1214
|
* @example
|
2090
|
-
*
|
2091
|
-
*
|
2092
|
-
*
|
2093
|
-
*
|
2094
|
-
* async function upsertVariant (title: string) {
|
2095
|
-
* const productModule = await initializeProductModule()
|
2096
|
-
*
|
2097
|
-
* const createdVariant = await productModule.upsertVariants(
|
2098
|
-
* {
|
2099
|
-
* title
|
2100
|
-
* }
|
2101
|
-
* )
|
2102
|
-
*
|
2103
|
-
* // do something with the variant or return it
|
2104
|
-
* }
|
1215
|
+
* const variant = await productModuleService.upsertVariants({
|
1216
|
+
* id: "variant_123",
|
1217
|
+
* title: "Green Shirt",
|
1218
|
+
* })
|
2105
1219
|
*/
|
2106
1220
|
upsertVariants(data: UpsertProductVariantDTO, sharedContext?: Context): Promise<ProductVariantDTO>;
|
2107
1221
|
/**
|
@@ -2113,45 +1227,31 @@ export interface IProductModuleService extends IModuleService {
|
|
2113
1227
|
* @returns {Promise<ProductVariantDTO>} The updated variant.
|
2114
1228
|
*
|
2115
1229
|
* @example
|
2116
|
-
*
|
2117
|
-
*
|
2118
|
-
*
|
2119
|
-
*
|
2120
|
-
*
|
2121
|
-
*
|
2122
|
-
*
|
2123
|
-
* const variant = await productModule.updateVariants(id, {
|
2124
|
-
* title
|
2125
|
-
* }
|
2126
|
-
* )
|
2127
|
-
*
|
2128
|
-
* // do something with the variant or return it
|
2129
|
-
* }
|
1230
|
+
* const variant = await productModuleService.updateVariants(
|
1231
|
+
* "variant_123",
|
1232
|
+
* {
|
1233
|
+
* title: "Blue Shirt",
|
1234
|
+
* }
|
1235
|
+
* )
|
2130
1236
|
*/
|
2131
1237
|
updateVariants(id: string, data: UpdateProductVariantDTO, sharedContext?: Context): Promise<ProductVariantDTO>;
|
2132
1238
|
/**
|
2133
|
-
* This method is used to update a list of variants
|
1239
|
+
* This method is used to update a list of variants matching the specified filters.
|
2134
1240
|
*
|
2135
|
-
* @param {FilterableProductVariantProps} selector - The filters
|
1241
|
+
* @param {FilterableProductVariantProps} selector - The filters specifying which variants to update.
|
2136
1242
|
* @param {UpdateProductVariantDTO} data - The attributes to be updated on the selected variants
|
2137
1243
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
2138
1244
|
* @returns {Promise<ProductVariantDTO[]>} The updated variants.
|
2139
1245
|
*
|
2140
1246
|
* @example
|
2141
|
-
*
|
2142
|
-
*
|
2143
|
-
*
|
2144
|
-
*
|
2145
|
-
*
|
2146
|
-
*
|
2147
|
-
*
|
2148
|
-
*
|
2149
|
-
* title
|
2150
|
-
* }
|
2151
|
-
* )
|
2152
|
-
*
|
2153
|
-
* // do something with the variants or return them
|
2154
|
-
* }
|
1247
|
+
* const variants = await productModuleService.updateVariants(
|
1248
|
+
* {
|
1249
|
+
* id: ["variant_123", "variant_321"],
|
1250
|
+
* },
|
1251
|
+
* {
|
1252
|
+
* title: "Blue Shirt",
|
1253
|
+
* }
|
1254
|
+
* )
|
2155
1255
|
*/
|
2156
1256
|
updateVariants(selector: FilterableProductVariantProps, data: UpdateProductVariantDTO, sharedContext?: Context): Promise<ProductVariantDTO[]>;
|
2157
1257
|
/**
|
@@ -2162,15 +1262,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2162
1262
|
* @returns {Promise<void>} Resolves when the ProductVariant are successfully deleted.
|
2163
1263
|
*
|
2164
1264
|
* @example
|
2165
|
-
*
|
2166
|
-
*
|
2167
|
-
*
|
2168
|
-
*
|
2169
|
-
* async function deleteProducts (ids: string[]) {
|
2170
|
-
* const productModule = await initializeProductModule()
|
2171
|
-
*
|
2172
|
-
* await productModule.deleteVariants(ids)
|
2173
|
-
* }
|
1265
|
+
* await productModuleService.deleteVariants([
|
1266
|
+
* "variant_123",
|
1267
|
+
* "variant_321",
|
1268
|
+
* ])
|
2174
1269
|
*/
|
2175
1270
|
deleteVariants(productVariantIds: string[], sharedContext?: Context): Promise<void>;
|
2176
1271
|
/**
|
@@ -2189,17 +1284,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2189
1284
|
* If there are no related records, the promise resolved to `void`.
|
2190
1285
|
*
|
2191
1286
|
* @example
|
2192
|
-
*
|
2193
|
-
*
|
2194
|
-
*
|
2195
|
-
*
|
2196
|
-
* async function deleteProductVariants (ids: string[]) {
|
2197
|
-
* const productModule = await initializeProductModule()
|
2198
|
-
*
|
2199
|
-
* const cascadedEntities = await productModule.softDeleteVariants(ids)
|
2200
|
-
*
|
2201
|
-
* // do something with the returned cascaded entity IDs or return them
|
2202
|
-
* }
|
1287
|
+
* await productModuleService.softDeleteVariants([
|
1288
|
+
* "variant_123",
|
1289
|
+
* "variant_321",
|
1290
|
+
* ])
|
2203
1291
|
*/
|
2204
1292
|
softDeleteVariants<TReturnableLinkableKeys extends string = string>(variantIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
2205
1293
|
/**
|
@@ -2216,19 +1304,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2216
1304
|
* If there are no related records that were restored, the promise resolved to `void`.
|
2217
1305
|
*
|
2218
1306
|
* @example
|
2219
|
-
*
|
2220
|
-
*
|
2221
|
-
*
|
2222
|
-
*
|
2223
|
-
* async function restoreVariants (ids: string[]) {
|
2224
|
-
* const productModule = await initializeProductModule()
|
2225
|
-
*
|
2226
|
-
* const cascadedEntities = await productModule.restoreVariants(ids, {
|
2227
|
-
* returnLinkableKeys: ["option_value_id"]
|
2228
|
-
* })
|
2229
|
-
*
|
2230
|
-
* // do something with the returned cascaded entity IDs or return them
|
2231
|
-
* }
|
1307
|
+
* await productModuleService.restoreVariants([
|
1308
|
+
* "variant_123",
|
1309
|
+
* "variant_321",
|
1310
|
+
* ])
|
2232
1311
|
*/
|
2233
1312
|
restoreVariants<TReturnableLinkableKeys extends string = string>(variantIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
2234
1313
|
/**
|
@@ -2245,35 +1324,17 @@ export interface IProductModuleService extends IModuleService {
|
|
2245
1324
|
* A simple example that retrieves a product collection by its ID:
|
2246
1325
|
*
|
2247
1326
|
* ```ts
|
2248
|
-
*
|
2249
|
-
*
|
2250
|
-
* } from "@medusajs/product"
|
2251
|
-
*
|
2252
|
-
* async function retrieveCollection (id: string) {
|
2253
|
-
* const productModule = await initializeProductModule()
|
2254
|
-
*
|
2255
|
-
* const collection = await productModule.retrieveCollection(id)
|
2256
|
-
*
|
2257
|
-
* // do something with the product collection or return it
|
2258
|
-
* }
|
1327
|
+
* const collection =
|
1328
|
+
* await productModuleService.retrieveCollection("pcol_123")
|
2259
1329
|
* ```
|
2260
1330
|
*
|
2261
1331
|
* To specify relations that should be retrieved:
|
2262
1332
|
*
|
2263
1333
|
* ```ts
|
2264
|
-
*
|
2265
|
-
*
|
2266
|
-
*
|
2267
|
-
*
|
2268
|
-
* async function retrieveCollection (id: string) {
|
2269
|
-
* const productModule = await initializeProductModule()
|
2270
|
-
*
|
2271
|
-
* const collection = await productModule.retrieveCollection(id, {
|
2272
|
-
* relations: ["products"]
|
1334
|
+
* const collection =
|
1335
|
+
* await productModuleService.retrieveCollection("pcol_123", {
|
1336
|
+
* relations: ["products"],
|
2273
1337
|
* })
|
2274
|
-
*
|
2275
|
-
* // do something with the product collection or return it
|
2276
|
-
* }
|
2277
1338
|
* ```
|
2278
1339
|
*/
|
2279
1340
|
retrieveCollection(productCollectionId: string, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<ProductCollectionDTO>;
|
@@ -2291,90 +1352,40 @@ export interface IProductModuleService extends IModuleService {
|
|
2291
1352
|
* To retrieve a list of product collections using their IDs:
|
2292
1353
|
*
|
2293
1354
|
* ```ts
|
2294
|
-
*
|
2295
|
-
*
|
2296
|
-
*
|
2297
|
-
*
|
2298
|
-
* async function retrieveCollections (ids: string[]) {
|
2299
|
-
* const productModule = await initializeProductModule()
|
2300
|
-
*
|
2301
|
-
* const collections = await productModule.listCollections({
|
2302
|
-
* id: ids
|
1355
|
+
* const collections =
|
1356
|
+
* await productModuleService.listCollections({
|
1357
|
+
* id: ["pcol_123", "pcol_321"],
|
2303
1358
|
* })
|
2304
|
-
*
|
2305
|
-
* // do something with the product collections or return them
|
2306
|
-
* }
|
2307
1359
|
* ```
|
2308
1360
|
*
|
2309
1361
|
* To specify relations that should be retrieved within the product collections:
|
2310
1362
|
*
|
2311
1363
|
* ```ts
|
2312
|
-
*
|
2313
|
-
*
|
2314
|
-
*
|
2315
|
-
*
|
2316
|
-
*
|
2317
|
-
*
|
2318
|
-
*
|
2319
|
-
*
|
2320
|
-
*
|
2321
|
-
* }, {
|
2322
|
-
* relations: ["products"]
|
2323
|
-
* })
|
2324
|
-
*
|
2325
|
-
* // do something with the product collections or return them
|
2326
|
-
* }
|
1364
|
+
* const collections =
|
1365
|
+
* await productModuleService.listCollections(
|
1366
|
+
* {
|
1367
|
+
* id: ["pcol_123", "pcol_321"],
|
1368
|
+
* },
|
1369
|
+
* {
|
1370
|
+
* relations: ["products"],
|
1371
|
+
* }
|
1372
|
+
* )
|
2327
1373
|
* ```
|
2328
1374
|
*
|
2329
1375
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
2330
1376
|
*
|
2331
1377
|
* ```ts
|
2332
|
-
*
|
2333
|
-
*
|
2334
|
-
*
|
2335
|
-
*
|
2336
|
-
*
|
2337
|
-
*
|
2338
|
-
*
|
2339
|
-
*
|
2340
|
-
*
|
2341
|
-
*
|
2342
|
-
*
|
2343
|
-
* skip,
|
2344
|
-
* take
|
2345
|
-
* })
|
2346
|
-
*
|
2347
|
-
* // do something with the product collections or return them
|
2348
|
-
* }
|
2349
|
-
* ```
|
2350
|
-
*
|
2351
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
2352
|
-
*
|
2353
|
-
* ```ts
|
2354
|
-
* import {
|
2355
|
-
* initialize as initializeProductModule,
|
2356
|
-
* } from "@medusajs/product"
|
2357
|
-
*
|
2358
|
-
* async function retrieveCollections (ids: string[], title: string, skip: number, take: number) {
|
2359
|
-
* const productModule = await initializeProductModule()
|
2360
|
-
*
|
2361
|
-
* const collections = await productModule.listCollections({
|
2362
|
-
* $and: [
|
2363
|
-
* {
|
2364
|
-
* id: ids
|
2365
|
-
* },
|
2366
|
-
* {
|
2367
|
-
* title
|
2368
|
-
* }
|
2369
|
-
* ]
|
2370
|
-
* }, {
|
2371
|
-
* relations: ["products"],
|
2372
|
-
* skip,
|
2373
|
-
* take
|
2374
|
-
* })
|
2375
|
-
*
|
2376
|
-
* // do something with the product collections or return them
|
2377
|
-
* }
|
1378
|
+
* const collections =
|
1379
|
+
* await productModuleService.listCollections(
|
1380
|
+
* {
|
1381
|
+
* id: ["pcol_123", "pcol_321"],
|
1382
|
+
* },
|
1383
|
+
* {
|
1384
|
+
* relations: ["products"],
|
1385
|
+
* take: 20,
|
1386
|
+
* skip: 2,
|
1387
|
+
* }
|
1388
|
+
* )
|
2378
1389
|
* ```
|
2379
1390
|
*/
|
2380
1391
|
listCollections(filters?: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
@@ -2392,90 +1403,40 @@ export interface IProductModuleService extends IModuleService {
|
|
2392
1403
|
* To retrieve a list of product collections using their IDs:
|
2393
1404
|
*
|
2394
1405
|
* ```ts
|
2395
|
-
*
|
2396
|
-
*
|
2397
|
-
*
|
2398
|
-
*
|
2399
|
-
* async function retrieveCollections (ids: string[]) {
|
2400
|
-
* const productModule = await initializeProductModule()
|
2401
|
-
*
|
2402
|
-
* const [collections, count] = await productModule.listAndCountCollections({
|
2403
|
-
* id: ids
|
1406
|
+
* const [collections, count] =
|
1407
|
+
* await productModuleService.listAndCountCollections({
|
1408
|
+
* id: ["pcol_123", "pcol_321"],
|
2404
1409
|
* })
|
2405
|
-
*
|
2406
|
-
* // do something with the product collections or return them
|
2407
|
-
* }
|
2408
1410
|
* ```
|
2409
1411
|
*
|
2410
1412
|
* To specify relations that should be retrieved within the product collections:
|
2411
1413
|
*
|
2412
1414
|
* ```ts
|
2413
|
-
*
|
2414
|
-
*
|
2415
|
-
*
|
2416
|
-
*
|
2417
|
-
*
|
2418
|
-
*
|
2419
|
-
*
|
2420
|
-
*
|
2421
|
-
*
|
2422
|
-
* }, {
|
2423
|
-
* relations: ["products"]
|
2424
|
-
* })
|
2425
|
-
*
|
2426
|
-
* // do something with the product collections or return them
|
2427
|
-
* }
|
1415
|
+
* const [collections, count] =
|
1416
|
+
* await productModuleService.listAndCountCollections(
|
1417
|
+
* {
|
1418
|
+
* id: ["pcol_123", "pcol_321"],
|
1419
|
+
* },
|
1420
|
+
* {
|
1421
|
+
* relations: ["products"],
|
1422
|
+
* }
|
1423
|
+
* )
|
2428
1424
|
* ```
|
2429
1425
|
*
|
2430
1426
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
2431
1427
|
*
|
2432
1428
|
* ```ts
|
2433
|
-
*
|
2434
|
-
*
|
2435
|
-
*
|
2436
|
-
*
|
2437
|
-
*
|
2438
|
-
*
|
2439
|
-
*
|
2440
|
-
*
|
2441
|
-
*
|
2442
|
-
*
|
2443
|
-
*
|
2444
|
-
* skip,
|
2445
|
-
* take
|
2446
|
-
* })
|
2447
|
-
*
|
2448
|
-
* // do something with the product collections or return them
|
2449
|
-
* }
|
2450
|
-
* ```
|
2451
|
-
*
|
2452
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
2453
|
-
*
|
2454
|
-
* ```ts
|
2455
|
-
* import {
|
2456
|
-
* initialize as initializeProductModule,
|
2457
|
-
* } from "@medusajs/product"
|
2458
|
-
*
|
2459
|
-
* async function retrieveCollections (ids: string[], title: string, skip: number, take: number) {
|
2460
|
-
* const productModule = await initializeProductModule()
|
2461
|
-
*
|
2462
|
-
* const [collections, count] = await productModule.listAndCountCollections({
|
2463
|
-
* $and: [
|
2464
|
-
* {
|
2465
|
-
* id: ids
|
2466
|
-
* },
|
2467
|
-
* {
|
2468
|
-
* title
|
2469
|
-
* }
|
2470
|
-
* ]
|
2471
|
-
* }, {
|
2472
|
-
* relations: ["products"],
|
2473
|
-
* skip,
|
2474
|
-
* take
|
2475
|
-
* })
|
2476
|
-
*
|
2477
|
-
* // do something with the product collections or return them
|
2478
|
-
* }
|
1429
|
+
* const [collections, count] =
|
1430
|
+
* await productModuleService.listAndCountCollections(
|
1431
|
+
* {
|
1432
|
+
* id: ["pcol_123", "pcol_321"],
|
1433
|
+
* },
|
1434
|
+
* {
|
1435
|
+
* relations: ["products"],
|
1436
|
+
* take: 20,
|
1437
|
+
* skip: 2,
|
1438
|
+
* }
|
1439
|
+
* )
|
2479
1440
|
* ```
|
2480
1441
|
*/
|
2481
1442
|
listAndCountCollections(filters?: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, sharedContext?: Context): Promise<[ProductCollectionDTO[], number]>;
|
@@ -2487,22 +1448,16 @@ export interface IProductModuleService extends IModuleService {
|
|
2487
1448
|
* @returns {Promise<ProductCollectionDTO[]>} The list of created product collections.
|
2488
1449
|
*
|
2489
1450
|
* @example
|
2490
|
-
*
|
2491
|
-
*
|
2492
|
-
* } from "@medusajs/product"
|
2493
|
-
*
|
2494
|
-
* async function createCollections (title: string) {
|
2495
|
-
* const productModule = await initializeProductModule()
|
2496
|
-
*
|
2497
|
-
* const collections = await productModule.createCollections([
|
1451
|
+
* const collections =
|
1452
|
+
* await productModuleService.createCollections([
|
2498
1453
|
* {
|
2499
|
-
* title
|
2500
|
-
* }
|
1454
|
+
* title: "Summer Collection",
|
1455
|
+
* },
|
1456
|
+
* {
|
1457
|
+
* title: "Winter Collection",
|
1458
|
+
* },
|
2501
1459
|
* ])
|
2502
1460
|
*
|
2503
|
-
* // do something with the product collections or return them
|
2504
|
-
* }
|
2505
|
-
*
|
2506
1461
|
*/
|
2507
1462
|
createCollections(data: CreateProductCollectionDTO[], sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
2508
1463
|
/**
|
@@ -2513,21 +1468,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2513
1468
|
* @returns {Promise<ProductCollectionDTO>} The created product collection.
|
2514
1469
|
*
|
2515
1470
|
* @example
|
2516
|
-
*
|
2517
|
-
*
|
2518
|
-
*
|
2519
|
-
*
|
2520
|
-
* async function createCollection (title: string) {
|
2521
|
-
* const productModule = await initializeProductModule()
|
2522
|
-
*
|
2523
|
-
* const collection = await productModule.createCollections(
|
2524
|
-
* {
|
2525
|
-
* title
|
2526
|
-
* }
|
2527
|
-
* )
|
2528
|
-
*
|
2529
|
-
* // do something with the product collection or return them
|
2530
|
-
* }
|
1471
|
+
* const collection =
|
1472
|
+
* await productModuleService.createCollections({
|
1473
|
+
* title: "Summer Collection",
|
1474
|
+
* })
|
2531
1475
|
*
|
2532
1476
|
*/
|
2533
1477
|
createCollections(data: CreateProductCollectionDTO, sharedContext?: Context): Promise<ProductCollectionDTO>;
|
@@ -2539,21 +1483,16 @@ export interface IProductModuleService extends IModuleService {
|
|
2539
1483
|
* @returns {Promise<ProductCollectionDTO[]>} The updated and created collections.
|
2540
1484
|
*
|
2541
1485
|
* @example
|
2542
|
-
*
|
2543
|
-
*
|
2544
|
-
* } from "@medusajs/product"
|
2545
|
-
*
|
2546
|
-
* async function upsertCollections (title: string) {
|
2547
|
-
* const productModule = await initializeProductModule()
|
2548
|
-
*
|
2549
|
-
* const createdCollections = await productModule.upsertCollections([
|
1486
|
+
* const collections =
|
1487
|
+
* await productModuleService.upsertCollections([
|
2550
1488
|
* {
|
2551
|
-
*
|
2552
|
-
*
|
1489
|
+
* id: "pcol_123",
|
1490
|
+
* title: "Winter Collection",
|
1491
|
+
* },
|
1492
|
+
* {
|
1493
|
+
* title: "Summer Collection",
|
1494
|
+
* },
|
2553
1495
|
* ])
|
2554
|
-
*
|
2555
|
-
* // do something with the collections or return them
|
2556
|
-
* }
|
2557
1496
|
*/
|
2558
1497
|
upsertCollections(data: UpsertProductCollectionDTO[], sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
2559
1498
|
/**
|
@@ -2564,21 +1503,11 @@ export interface IProductModuleService extends IModuleService {
|
|
2564
1503
|
* @returns {Promise<ProductCollectionDTO>} The updated or created collection.
|
2565
1504
|
*
|
2566
1505
|
* @example
|
2567
|
-
*
|
2568
|
-
*
|
2569
|
-
*
|
2570
|
-
*
|
2571
|
-
*
|
2572
|
-
* const productModule = await initializeProductModule()
|
2573
|
-
*
|
2574
|
-
* const createdCollection = await productModule.upsertCollection(
|
2575
|
-
* {
|
2576
|
-
* title
|
2577
|
-
* }
|
2578
|
-
* )
|
2579
|
-
*
|
2580
|
-
* // do something with the collection or return it
|
2581
|
-
* }
|
1506
|
+
* const collection =
|
1507
|
+
* await productModuleService.upsertCollections({
|
1508
|
+
* id: "pcol_123",
|
1509
|
+
* title: "Winter Collection",
|
1510
|
+
* })
|
2582
1511
|
*/
|
2583
1512
|
upsertCollections(data: UpsertProductCollectionDTO, sharedContext?: Context): Promise<ProductCollectionDTO>;
|
2584
1513
|
/**
|
@@ -2590,45 +1519,30 @@ export interface IProductModuleService extends IModuleService {
|
|
2590
1519
|
* @returns {Promise<ProductCollectionDTO>} The updated collection.
|
2591
1520
|
*
|
2592
1521
|
* @example
|
2593
|
-
*
|
2594
|
-
*
|
2595
|
-
*
|
2596
|
-
*
|
2597
|
-
* async function updateCollection (id: string, title: string) {
|
2598
|
-
* const productModule = await initializeProductModule()
|
2599
|
-
*
|
2600
|
-
* const collection = await productModule.updateCollections(id, {
|
2601
|
-
* title
|
2602
|
-
* }
|
2603
|
-
* )
|
2604
|
-
*
|
2605
|
-
* // do something with the collection or return it
|
2606
|
-
* }
|
1522
|
+
* const collection =
|
1523
|
+
* await productModuleService.updateCollections("pcol_123", {
|
1524
|
+
* title: "Summer Collection",
|
1525
|
+
* })
|
2607
1526
|
*/
|
2608
1527
|
updateCollections(id: string, data: UpdateProductCollectionDTO, sharedContext?: Context): Promise<ProductCollectionDTO>;
|
2609
1528
|
/**
|
2610
|
-
* This method is used to update a list of collections
|
1529
|
+
* This method is used to update a list of collections matching the specified filters.
|
2611
1530
|
*
|
2612
|
-
* @param {FilterableProductCollectionProps} selector - The filters
|
1531
|
+
* @param {FilterableProductCollectionProps} selector - The filters specifying which collections to update.
|
2613
1532
|
* @param {UpdateProductCollectionDTO} data - The attributes to be updated on the selected collections
|
2614
1533
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
2615
1534
|
* @returns {Promise<ProductCollectionDTO[]>} The updated collections.
|
2616
1535
|
*
|
2617
1536
|
* @example
|
2618
|
-
*
|
2619
|
-
*
|
2620
|
-
*
|
2621
|
-
*
|
2622
|
-
*
|
2623
|
-
*
|
2624
|
-
*
|
2625
|
-
* const collections = await productModule.updateCollections({id: ids}, {
|
2626
|
-
* title
|
1537
|
+
* const collections =
|
1538
|
+
* await productModuleService.updateCollections(
|
1539
|
+
* {
|
1540
|
+
* id: ["pcol_123", "pcol_321"],
|
1541
|
+
* },
|
1542
|
+
* {
|
1543
|
+
* title: "Summer Collection",
|
2627
1544
|
* }
|
2628
1545
|
* )
|
2629
|
-
*
|
2630
|
-
* // do something with the collections or return them
|
2631
|
-
* }
|
2632
1546
|
*/
|
2633
1547
|
updateCollections(selector: FilterableProductCollectionProps, data: UpdateProductCollectionDTO, sharedContext?: Context): Promise<ProductCollectionDTO[]>;
|
2634
1548
|
/**
|
@@ -2639,15 +1553,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2639
1553
|
* @returns {Promise<void>} Resolves when the product options are successfully deleted.
|
2640
1554
|
*
|
2641
1555
|
* @example
|
2642
|
-
*
|
2643
|
-
*
|
2644
|
-
*
|
2645
|
-
*
|
2646
|
-
* async function deleteCollection (ids: string[]) {
|
2647
|
-
* const productModule = await initializeProductModule()
|
2648
|
-
*
|
2649
|
-
* await productModule.deleteCollections(ids)
|
2650
|
-
* }
|
1556
|
+
* await productModuleService.deleteCollections([
|
1557
|
+
* "pcol_123",
|
1558
|
+
* "pcol_321",
|
1559
|
+
* ])
|
2651
1560
|
*
|
2652
1561
|
*/
|
2653
1562
|
deleteCollections(productCollectionIds: string[], sharedContext?: Context): Promise<void>;
|
@@ -2667,17 +1576,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2667
1576
|
* If there are no related records, the promise resolved to `void`.
|
2668
1577
|
*
|
2669
1578
|
* @example
|
2670
|
-
*
|
2671
|
-
*
|
2672
|
-
*
|
2673
|
-
*
|
2674
|
-
* async function deleteCollections (ids: string[]) {
|
2675
|
-
* const productModule = await initializeProductModule()
|
2676
|
-
*
|
2677
|
-
* const cascadedEntities = await productModule.softDeleteCollections(ids)
|
2678
|
-
*
|
2679
|
-
* // do something with the returned cascaded entity IDs or return them
|
2680
|
-
* }
|
1579
|
+
* await productModuleService.softDeleteCollections([
|
1580
|
+
* "pcol_123",
|
1581
|
+
* "pcol_321",
|
1582
|
+
* ])
|
2681
1583
|
*/
|
2682
1584
|
softDeleteCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
2683
1585
|
/**
|
@@ -2694,19 +1596,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2694
1596
|
* If there are no related records that were restored, the promise resolved to `void`.
|
2695
1597
|
*
|
2696
1598
|
* @example
|
2697
|
-
*
|
2698
|
-
*
|
2699
|
-
*
|
2700
|
-
*
|
2701
|
-
* async function restoreCollections (ids: string[]) {
|
2702
|
-
* const productModule = await initializeProductModule()
|
2703
|
-
*
|
2704
|
-
* const cascadedEntities = await productModule.restoreCollections(ids, {
|
2705
|
-
* returnLinkableKeys: []
|
2706
|
-
* })
|
2707
|
-
*
|
2708
|
-
* // do something with the returned cascaded entity IDs or return them
|
2709
|
-
* }
|
1599
|
+
* await productModuleService.restoreCollections([
|
1600
|
+
* "pcol_123",
|
1601
|
+
* "pcol_321",
|
1602
|
+
* ])
|
2710
1603
|
*/
|
2711
1604
|
restoreCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
2712
1605
|
/**
|
@@ -2723,35 +1616,19 @@ export interface IProductModuleService extends IModuleService {
|
|
2723
1616
|
* A simple example that retrieves a product category by its ID:
|
2724
1617
|
*
|
2725
1618
|
* ```ts
|
2726
|
-
*
|
2727
|
-
*
|
2728
|
-
* } from "@medusajs/product"
|
2729
|
-
*
|
2730
|
-
* async function retrieveCategory (id: string) {
|
2731
|
-
* const productModule = await initializeProductModule()
|
2732
|
-
*
|
2733
|
-
* const category = await productModule.retrieveCategory(id)
|
2734
|
-
*
|
2735
|
-
* // do something with the product category or return it
|
2736
|
-
* }
|
1619
|
+
* const category =
|
1620
|
+
* await productModuleService.retrieveCategory("pcat_123")
|
2737
1621
|
* ```
|
2738
1622
|
*
|
2739
1623
|
* To specify relations that should be retrieved:
|
2740
1624
|
*
|
2741
1625
|
* ```ts
|
2742
|
-
*
|
2743
|
-
*
|
2744
|
-
*
|
2745
|
-
*
|
2746
|
-
*
|
2747
|
-
*
|
2748
|
-
*
|
2749
|
-
* const category = await productModule.retrieveCategory(id, {
|
2750
|
-
* relations: ["parent_category"]
|
2751
|
-
* })
|
2752
|
-
*
|
2753
|
-
* // do something with the product category or return it
|
2754
|
-
* }
|
1626
|
+
* const category = await productModuleService.retrieveCategory(
|
1627
|
+
* "pcat_123",
|
1628
|
+
* {
|
1629
|
+
* relations: ["products"],
|
1630
|
+
* }
|
1631
|
+
* )
|
2755
1632
|
* ```
|
2756
1633
|
*/
|
2757
1634
|
retrieveCategory(productCategoryId: string, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
@@ -2769,90 +1646,37 @@ export interface IProductModuleService extends IModuleService {
|
|
2769
1646
|
* To retrieve a list of product categories using their IDs:
|
2770
1647
|
*
|
2771
1648
|
* ```ts
|
2772
|
-
*
|
2773
|
-
*
|
2774
|
-
* }
|
2775
|
-
*
|
2776
|
-
* async function retrieveCategories (ids: string[]) {
|
2777
|
-
* const productModule = await initializeProductModule()
|
2778
|
-
*
|
2779
|
-
* const categories = await productModule.listCategories({
|
2780
|
-
* id: ids
|
2781
|
-
* })
|
2782
|
-
*
|
2783
|
-
* // do something with the product category or return it
|
2784
|
-
* }
|
1649
|
+
* const categories = await productModuleService.listCategories({
|
1650
|
+
* id: ["pcat_123", "pcat_321"],
|
1651
|
+
* })
|
2785
1652
|
* ```
|
2786
1653
|
*
|
2787
1654
|
* To specify relations that should be retrieved within the product categories:
|
2788
1655
|
*
|
2789
1656
|
* ```ts
|
2790
|
-
*
|
2791
|
-
*
|
2792
|
-
*
|
2793
|
-
*
|
2794
|
-
*
|
2795
|
-
*
|
2796
|
-
*
|
2797
|
-
*
|
2798
|
-
* id: ids
|
2799
|
-
* }, {
|
2800
|
-
* relations: ["parent_category"]
|
2801
|
-
* })
|
2802
|
-
*
|
2803
|
-
* // do something with the product category or return it
|
2804
|
-
* }
|
1657
|
+
* const categories = await productModuleService.listCategories(
|
1658
|
+
* {
|
1659
|
+
* id: ["pcat_123", "pcat_321"],
|
1660
|
+
* },
|
1661
|
+
* {
|
1662
|
+
* relations: ["products"],
|
1663
|
+
* }
|
1664
|
+
* )
|
2805
1665
|
* ```
|
2806
1666
|
*
|
2807
1667
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
2808
1668
|
*
|
2809
1669
|
* ```ts
|
2810
|
-
*
|
2811
|
-
*
|
2812
|
-
*
|
2813
|
-
*
|
2814
|
-
*
|
2815
|
-
*
|
2816
|
-
*
|
2817
|
-
*
|
2818
|
-
*
|
2819
|
-
*
|
2820
|
-
* relations: ["parent_category"],
|
2821
|
-
* skip,
|
2822
|
-
* take
|
2823
|
-
* })
|
2824
|
-
*
|
2825
|
-
* // do something with the product category or return it
|
2826
|
-
* }
|
2827
|
-
* ```
|
2828
|
-
*
|
2829
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
2830
|
-
*
|
2831
|
-
* ```ts
|
2832
|
-
* import {
|
2833
|
-
* initialize as initializeProductModule,
|
2834
|
-
* } from "@medusajs/product"
|
2835
|
-
*
|
2836
|
-
* async function retrieveCategories (ids: string[], name: string, skip: number, take: number) {
|
2837
|
-
* const productModule = await initializeProductModule()
|
2838
|
-
*
|
2839
|
-
* const categories = await productModule.listCategories({
|
2840
|
-
* $or: [
|
2841
|
-
* {
|
2842
|
-
* id: ids
|
2843
|
-
* },
|
2844
|
-
* {
|
2845
|
-
* name
|
2846
|
-
* }
|
2847
|
-
* ]
|
2848
|
-
* }, {
|
2849
|
-
* relations: ["parent_category"],
|
2850
|
-
* skip,
|
2851
|
-
* take
|
2852
|
-
* })
|
2853
|
-
*
|
2854
|
-
* // do something with the product category or return it
|
2855
|
-
* }
|
1670
|
+
* const categories = await productModuleService.listCategories(
|
1671
|
+
* {
|
1672
|
+
* id: ["pcat_123", "pcat_321"],
|
1673
|
+
* },
|
1674
|
+
* {
|
1675
|
+
* relations: ["products"],
|
1676
|
+
* take: 20,
|
1677
|
+
* skip: 2,
|
1678
|
+
* }
|
1679
|
+
* )
|
2856
1680
|
* ```
|
2857
1681
|
*/
|
2858
1682
|
listCategories(filters?: FilterableProductCategoryProps, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO[]>;
|
@@ -2870,90 +1694,40 @@ export interface IProductModuleService extends IModuleService {
|
|
2870
1694
|
* To retrieve a list of product categories using their IDs:
|
2871
1695
|
*
|
2872
1696
|
* ```ts
|
2873
|
-
*
|
2874
|
-
*
|
2875
|
-
*
|
2876
|
-
*
|
2877
|
-
* async function retrieveCategories (ids: string[]) {
|
2878
|
-
* const productModule = await initializeProductModule()
|
2879
|
-
*
|
2880
|
-
* const [categories, count] = await productModule.listAndCountCategories({
|
2881
|
-
* id: ids
|
1697
|
+
* const [categories, count] =
|
1698
|
+
* await productModuleService.listAndCountCategories({
|
1699
|
+
* id: ["pcat_123", "pcat_321"],
|
2882
1700
|
* })
|
2883
|
-
*
|
2884
|
-
* // do something with the product category or return it
|
2885
|
-
* }
|
2886
1701
|
* ```
|
2887
1702
|
*
|
2888
1703
|
* To specify relations that should be retrieved within the product categories:
|
2889
1704
|
*
|
2890
1705
|
* ```ts
|
2891
|
-
*
|
2892
|
-
*
|
2893
|
-
*
|
2894
|
-
*
|
2895
|
-
*
|
2896
|
-
*
|
2897
|
-
*
|
2898
|
-
*
|
2899
|
-
*
|
2900
|
-
* }, {
|
2901
|
-
* relations: ["parent_category"]
|
2902
|
-
* })
|
2903
|
-
*
|
2904
|
-
* // do something with the product category or return it
|
2905
|
-
* }
|
1706
|
+
* const [categories, count] =
|
1707
|
+
* await productModuleService.listAndCountCategories(
|
1708
|
+
* {
|
1709
|
+
* id: ["pcat_123", "pcat_321"],
|
1710
|
+
* },
|
1711
|
+
* {
|
1712
|
+
* relations: ["products"],
|
1713
|
+
* }
|
1714
|
+
* )
|
2906
1715
|
* ```
|
2907
1716
|
*
|
2908
1717
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
2909
1718
|
*
|
2910
1719
|
* ```ts
|
2911
|
-
*
|
2912
|
-
*
|
2913
|
-
*
|
2914
|
-
*
|
2915
|
-
*
|
2916
|
-
*
|
2917
|
-
*
|
2918
|
-
*
|
2919
|
-
*
|
2920
|
-
*
|
2921
|
-
*
|
2922
|
-
* skip,
|
2923
|
-
* take
|
2924
|
-
* })
|
2925
|
-
*
|
2926
|
-
* // do something with the product category or return it
|
2927
|
-
* }
|
2928
|
-
* ```
|
2929
|
-
*
|
2930
|
-
* You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
2931
|
-
*
|
2932
|
-
* ```ts
|
2933
|
-
* import {
|
2934
|
-
* initialize as initializeProductModule,
|
2935
|
-
* } from "@medusajs/product"
|
2936
|
-
*
|
2937
|
-
* async function retrieveCategories (ids: string[], name: string, skip: number, take: number) {
|
2938
|
-
* const productModule = await initializeProductModule()
|
2939
|
-
*
|
2940
|
-
* const [categories, count] = await productModule.listAndCountCategories({
|
2941
|
-
* $or: [
|
2942
|
-
* {
|
2943
|
-
* id: ids
|
2944
|
-
* },
|
2945
|
-
* {
|
2946
|
-
* name
|
2947
|
-
* }
|
2948
|
-
* ]
|
2949
|
-
* }, {
|
2950
|
-
* relations: ["parent_category"],
|
2951
|
-
* skip,
|
2952
|
-
* take
|
2953
|
-
* })
|
2954
|
-
*
|
2955
|
-
* // do something with the product category or return it
|
2956
|
-
* }
|
1720
|
+
* const [categories, count] =
|
1721
|
+
* await productModuleService.listAndCountCategories(
|
1722
|
+
* {
|
1723
|
+
* id: ["pcat_123", "pcat_321"],
|
1724
|
+
* },
|
1725
|
+
* {
|
1726
|
+
* relations: ["products"],
|
1727
|
+
* take: 20,
|
1728
|
+
* skip: 2,
|
1729
|
+
* }
|
1730
|
+
* )
|
2957
1731
|
* ```
|
2958
1732
|
*/
|
2959
1733
|
listAndCountCategories(filters?: FilterableProductCategoryProps, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<[ProductCategoryDTO[], number]>;
|
@@ -2965,20 +1739,10 @@ export interface IProductModuleService extends IModuleService {
|
|
2965
1739
|
* @returns {Promise<ProductCategoryDTO>} The created product category.
|
2966
1740
|
*
|
2967
1741
|
* @example
|
2968
|
-
*
|
2969
|
-
*
|
2970
|
-
*
|
2971
|
-
*
|
2972
|
-
* async function createCategory (name: string, parent_category_id: string | null) {
|
2973
|
-
* const productModule = await initializeProductModule()
|
2974
|
-
*
|
2975
|
-
* const category = await productModule.createCategory({
|
2976
|
-
* name,
|
2977
|
-
* parent_category_id
|
2978
|
-
* })
|
2979
|
-
*
|
2980
|
-
* // do something with the product category or return it
|
2981
|
-
* }
|
1742
|
+
* const category = await productModuleService.createCategory({
|
1743
|
+
* name: "Shirts",
|
1744
|
+
* parent_category_id: null,
|
1745
|
+
* })
|
2982
1746
|
*
|
2983
1747
|
*/
|
2984
1748
|
createCategory(data: CreateProductCategoryDTO, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
@@ -2991,19 +1755,12 @@ export interface IProductModuleService extends IModuleService {
|
|
2991
1755
|
* @returns {Promise<ProductCategoryDTO>} The updated product category.
|
2992
1756
|
*
|
2993
1757
|
* @example
|
2994
|
-
*
|
2995
|
-
*
|
2996
|
-
*
|
2997
|
-
*
|
2998
|
-
*
|
2999
|
-
*
|
3000
|
-
*
|
3001
|
-
* const category = await productModule.updateCategory(id, {
|
3002
|
-
* name,
|
3003
|
-
* })
|
3004
|
-
*
|
3005
|
-
* // do something with the product category or return it
|
3006
|
-
* }
|
1758
|
+
* const category = await productModuleService.updateCategory(
|
1759
|
+
* "pcat_123",
|
1760
|
+
* {
|
1761
|
+
* name: "Shirts",
|
1762
|
+
* }
|
1763
|
+
* )
|
3007
1764
|
*/
|
3008
1765
|
updateCategory(categoryId: string, data: UpdateProductCategoryDTO, sharedContext?: Context): Promise<ProductCategoryDTO>;
|
3009
1766
|
/**
|
@@ -3014,15 +1771,7 @@ export interface IProductModuleService extends IModuleService {
|
|
3014
1771
|
* @returns {Promise<void>} Resolves when the product category is successfully deleted.
|
3015
1772
|
*
|
3016
1773
|
* @example
|
3017
|
-
*
|
3018
|
-
* initialize as initializeProductModule,
|
3019
|
-
* } from "@medusajs/product"
|
3020
|
-
*
|
3021
|
-
* async function deleteCategory (id: string) {
|
3022
|
-
* const productModule = await initializeProductModule()
|
3023
|
-
*
|
3024
|
-
* await productModule.deleteCategory(id)
|
3025
|
-
* }
|
1774
|
+
* await productModuleService.deleteCategory("pcat_123")
|
3026
1775
|
*/
|
3027
1776
|
deleteCategory(categoryId: string, sharedContext?: Context): Promise<void>;
|
3028
1777
|
}
|