@medusajs/js-sdk 2.0.1-snapshot-20241025090810 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/price-list.d.ts +195 -1
- package/dist/admin/price-list.d.ts.map +1 -1
- package/dist/admin/price-list.js +194 -0
- package/dist/admin/price-list.js.map +1 -1
- package/dist/admin/price-preference.d.ts +133 -0
- package/dist/admin/price-preference.d.ts.map +1 -1
- package/dist/admin/price-preference.js +133 -0
- package/dist/admin/price-preference.js.map +1 -1
- package/dist/admin/product-category.d.ts +150 -0
- package/dist/admin/product-category.d.ts.map +1 -1
- package/dist/admin/product-category.js +150 -0
- package/dist/admin/product-category.js.map +1 -1
- package/dist/admin/product-collection.d.ts +149 -0
- package/dist/admin/product-collection.d.ts.map +1 -1
- package/dist/admin/product-collection.js +149 -0
- package/dist/admin/product-collection.js.map +1 -1
- package/dist/esm/admin/price-list.d.ts +195 -1
- package/dist/esm/admin/price-list.d.ts.map +1 -1
- package/dist/esm/admin/price-list.js +194 -0
- package/dist/esm/admin/price-list.js.map +1 -1
- package/dist/esm/admin/price-preference.d.ts +133 -0
- package/dist/esm/admin/price-preference.d.ts.map +1 -1
- package/dist/esm/admin/price-preference.js +133 -0
- package/dist/esm/admin/price-preference.js.map +1 -1
- package/dist/esm/admin/product-category.d.ts +150 -0
- package/dist/esm/admin/product-category.d.ts.map +1 -1
- package/dist/esm/admin/product-category.js +150 -0
- package/dist/esm/admin/product-category.js.map +1 -1
- package/dist/esm/admin/product-collection.d.ts +149 -0
- package/dist/esm/admin/product-collection.d.ts.map +1 -1
- package/dist/esm/admin/product-collection.js +149 -0
- package/dist/esm/admin/product-collection.js.map +1 -1
- package/package.json +2 -2
@@ -14,6 +14,24 @@ export class ProductCollection {
|
|
14
14
|
constructor(client) {
|
15
15
|
this.client = client;
|
16
16
|
}
|
17
|
+
/**
|
18
|
+
* This method creates a product collection. It sends a request to the
|
19
|
+
* [Create Collection](https://docs.medusajs.com/api/admin#collections_postcollections)
|
20
|
+
* API route.
|
21
|
+
*
|
22
|
+
* @param body - The details of the product collection to create.
|
23
|
+
* @param query - Configure the fields to retrieve in the product collection.
|
24
|
+
* @param headers - Headers to pass in the request
|
25
|
+
* @returns The product collection's details.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* sdk.admin.productCollection.create({
|
29
|
+
* title: "Summer Collection"
|
30
|
+
* })
|
31
|
+
* .then(({ collection }) => {
|
32
|
+
* console.log(collection)
|
33
|
+
* })
|
34
|
+
*/
|
17
35
|
create(body, query, headers) {
|
18
36
|
return __awaiter(this, void 0, void 0, function* () {
|
19
37
|
return this.client.fetch(`/admin/collections`, {
|
@@ -24,6 +42,25 @@ export class ProductCollection {
|
|
24
42
|
});
|
25
43
|
});
|
26
44
|
}
|
45
|
+
/**
|
46
|
+
* This method updates a collection. It sends a request to the
|
47
|
+
* [Update Collection](https://docs.medusajs.com/api/admin#collections_postcollectionsid)
|
48
|
+
* API route.
|
49
|
+
*
|
50
|
+
* @param id - The ID of the collection.
|
51
|
+
* @param body - The data to update in the collection.
|
52
|
+
* @param query - Configure the fields to retrieve in the product collection.
|
53
|
+
* @param headers - Headers to pass in the request
|
54
|
+
* @returns The product collection's details.
|
55
|
+
*
|
56
|
+
* @example
|
57
|
+
* sdk.admin.productCollection.update("pcol_123", {
|
58
|
+
* title: "Summer Collection"
|
59
|
+
* })
|
60
|
+
* .then(({ collection }) => {
|
61
|
+
* console.log(collection)
|
62
|
+
* })
|
63
|
+
*/
|
27
64
|
update(id, body, query, headers) {
|
28
65
|
return __awaiter(this, void 0, void 0, function* () {
|
29
66
|
return this.client.fetch(`/admin/collections/${id}`, {
|
@@ -34,6 +71,52 @@ export class ProductCollection {
|
|
34
71
|
});
|
35
72
|
});
|
36
73
|
}
|
74
|
+
/**
|
75
|
+
* This method retrieves a paginated list of collections. It sends a request to the
|
76
|
+
* [List Collections](https://docs.medusajs.com/api/admin#collections_getcollections) API route.
|
77
|
+
*
|
78
|
+
* @param query - Filters and pagination configurations.
|
79
|
+
* @param headers - Headers to pass in the request.
|
80
|
+
* @returns The paginated list of collections.
|
81
|
+
*
|
82
|
+
* @example
|
83
|
+
* To retrieve the list of collections:
|
84
|
+
*
|
85
|
+
* ```ts
|
86
|
+
* sdk.admin.productCollection.list()
|
87
|
+
* .then(({ collections, count, limit, offset }) => {
|
88
|
+
* console.log(collections)
|
89
|
+
* })
|
90
|
+
* ```
|
91
|
+
*
|
92
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
93
|
+
*
|
94
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
95
|
+
*
|
96
|
+
* ```ts
|
97
|
+
* sdk.admin.productCollection.list({
|
98
|
+
* limit: 10,
|
99
|
+
* offset: 10
|
100
|
+
* })
|
101
|
+
* .then(({ collections, count, limit, offset }) => {
|
102
|
+
* console.log(collections)
|
103
|
+
* })
|
104
|
+
* ```
|
105
|
+
*
|
106
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
107
|
+
* in each collection:
|
108
|
+
*
|
109
|
+
* ```ts
|
110
|
+
* sdk.admin.productCollection.list({
|
111
|
+
* fields: "id,*products"
|
112
|
+
* })
|
113
|
+
* .then(({ collections, count, limit, offset }) => {
|
114
|
+
* console.log(collections)
|
115
|
+
* })
|
116
|
+
* ```
|
117
|
+
*
|
118
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
119
|
+
*/
|
37
120
|
list(queryParams, headers) {
|
38
121
|
return __awaiter(this, void 0, void 0, function* () {
|
39
122
|
return this.client.fetch(`/admin/collections`, {
|
@@ -42,6 +125,38 @@ export class ProductCollection {
|
|
42
125
|
});
|
43
126
|
});
|
44
127
|
}
|
128
|
+
/**
|
129
|
+
* This method retrieves a collection by its ID. It sends a request to the
|
130
|
+
* [Get Collection](https://docs.medusajs.com/api/admin#collections_getcollectionsid) API route.
|
131
|
+
*
|
132
|
+
* @param id - The collection's ID.
|
133
|
+
* @param query - Configure the fields to retrieve in the collection.
|
134
|
+
* @param headers - Headers to pass in the request
|
135
|
+
* @returns The collection's details.
|
136
|
+
*
|
137
|
+
* @example
|
138
|
+
* To retrieve a collection by its ID:
|
139
|
+
*
|
140
|
+
* ```ts
|
141
|
+
* sdk.admin.productCollection.retrieve("pcol_123")
|
142
|
+
* .then(({ collection }) => {
|
143
|
+
* console.log(collection)
|
144
|
+
* })
|
145
|
+
* ```
|
146
|
+
*
|
147
|
+
* To specify the fields and relations to retrieve:
|
148
|
+
*
|
149
|
+
* ```ts
|
150
|
+
* sdk.admin.productCollection.retrieve("pcol_123", {
|
151
|
+
* fields: "id,*products"
|
152
|
+
* })
|
153
|
+
* .then(({ collection }) => {
|
154
|
+
* console.log(collection)
|
155
|
+
* })
|
156
|
+
* ```
|
157
|
+
*
|
158
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
159
|
+
*/
|
45
160
|
retrieve(id, query, headers) {
|
46
161
|
return __awaiter(this, void 0, void 0, function* () {
|
47
162
|
return this.client.fetch(`/admin/collections/${id}`, {
|
@@ -50,6 +165,21 @@ export class ProductCollection {
|
|
50
165
|
});
|
51
166
|
});
|
52
167
|
}
|
168
|
+
/**
|
169
|
+
* This method deletes a product collection. It sends a request to the
|
170
|
+
* [Delete Collection](https://docs.medusajs.com/api/admin#collections_deletecollectionsid)
|
171
|
+
* API route.
|
172
|
+
*
|
173
|
+
* @param id - The collection's ID.
|
174
|
+
* @param headers - Headers to pass in the request
|
175
|
+
* @returns The deletion's details.
|
176
|
+
*
|
177
|
+
* @example
|
178
|
+
* sdk.admin.productCollection.delete("pcol_123")
|
179
|
+
* .then(({ deleted }) => {
|
180
|
+
* console.log(deleted)
|
181
|
+
* })
|
182
|
+
*/
|
53
183
|
delete(id, headers) {
|
54
184
|
return __awaiter(this, void 0, void 0, function* () {
|
55
185
|
return this.client.fetch(`/admin/collections/${id}`, {
|
@@ -58,6 +188,25 @@ export class ProductCollection {
|
|
58
188
|
});
|
59
189
|
});
|
60
190
|
}
|
191
|
+
/**
|
192
|
+
* This method manages the products of a collection to add or remove them. It sends a request
|
193
|
+
* to the [Manage Products](https://docs.medusajs.com/api/admin#collections_postcollectionsidproducts)
|
194
|
+
* API route.
|
195
|
+
*
|
196
|
+
* @param id - The collection's ID.
|
197
|
+
* @param body - The products to add or remove.
|
198
|
+
* @param headers - Headers to pass in the request
|
199
|
+
* @returns The product category's details.
|
200
|
+
*
|
201
|
+
* @example
|
202
|
+
* sdk.admin.productCollection.updateProducts("pcol_123", {
|
203
|
+
* add: ["prod_123"],
|
204
|
+
* remove: ["prod_321"]
|
205
|
+
* })
|
206
|
+
* .then(({ collection }) => {
|
207
|
+
* console.log(collection)
|
208
|
+
* })
|
209
|
+
*/
|
61
210
|
updateProducts(id, body, headers) {
|
62
211
|
return __awaiter(this, void 0, void 0, function* () {
|
63
212
|
return this.client.fetch(`/admin/collections/${id}/products`, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"product-collection.js","sourceRoot":"","sources":["../../../src/admin/product-collection.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,OAAO,iBAAiB;IAK5B;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;
|
1
|
+
{"version":3,"file":"product-collection.js","sourceRoot":"","sources":["../../../src/admin/product-collection.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,OAAO,iBAAiB;IAK5B;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACG,MAAM,CACV,IAAqC,EACrC,KAAuC,EACvC,OAAuB;;YAEvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,oBAAoB,EACpB;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI;gBACJ,KAA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.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/js-sdk",
|
3
|
-
"version": "2.0.1
|
3
|
+
"version": "2.0.1",
|
4
4
|
"description": "SDK for the Medusa API",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"typescript": "^5.6.2"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"@medusajs/types": "2.0.1
|
38
|
+
"@medusajs/types": "^2.0.1",
|
39
39
|
"fetch-event-stream": "^0.1.5",
|
40
40
|
"qs": "^6.12.1"
|
41
41
|
},
|