@wix/stores 1.0.4 → 1.0.6
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/build/cjs/index.d.ts +2 -2
- package/build/cjs/index.js +2 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/src/{stores-poc-v1-collection.http.d.ts → stores-catalog-v1-collection.http.d.ts} +7 -2
- package/build/cjs/src/{stores-poc-v1-collection.http.js → stores-catalog-v1-collection.http.js} +47 -44
- package/build/cjs/src/stores-catalog-v1-collection.http.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-collection.public.d.ts +5 -0
- package/build/cjs/src/stores-catalog-v1-collection.public.js +20 -0
- package/build/cjs/src/stores-catalog-v1-collection.public.js.map +1 -0
- package/build/cjs/src/{stores-poc-v1-collection.types.d.ts → stores-catalog-v1-collection.types.d.ts} +51 -17
- package/build/cjs/src/{stores-poc-v1-collection.types.js → stores-catalog-v1-collection.types.js} +1 -1
- package/build/cjs/src/stores-catalog-v1-collection.types.js.map +1 -0
- package/build/cjs/src/{stores-poc-v1-collection.universal.d.ts → stores-catalog-v1-collection.universal.d.ts} +63 -38
- package/build/cjs/src/{stores-poc-v1-collection.universal.js → stores-catalog-v1-collection.universal.js} +55 -55
- package/build/cjs/src/stores-catalog-v1-collection.universal.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product.http.d.ts +62 -0
- package/build/cjs/src/stores-catalog-v1-product.http.js +775 -0
- package/build/cjs/src/stores-catalog-v1-product.http.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product.public.d.ts +25 -0
- package/build/cjs/src/stores-catalog-v1-product.public.js +139 -0
- package/build/cjs/src/stores-catalog-v1-product.public.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product.types.d.ts +1371 -0
- package/build/cjs/src/{stores-poc-v1-product.types.js → stores-catalog-v1-product.types.js} +1 -1
- package/build/cjs/src/stores-catalog-v1-product.types.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product.universal.d.ts +1744 -0
- package/build/cjs/src/stores-catalog-v1-product.universal.js +1155 -0
- package/build/cjs/src/stores-catalog-v1-product.universal.js.map +1 -0
- package/build/es/index.d.ts +2 -2
- package/build/es/index.js +2 -2
- package/build/es/index.js.map +1 -1
- package/build/es/src/{stores-poc-v1-collection.http.d.ts → stores-catalog-v1-collection.http.d.ts} +7 -2
- package/build/es/src/{stores-poc-v1-collection.http.js → stores-catalog-v1-collection.http.js} +44 -41
- package/build/es/src/stores-catalog-v1-collection.http.js.map +1 -0
- package/build/es/src/stores-catalog-v1-collection.public.d.ts +5 -0
- package/build/es/src/stores-catalog-v1-collection.public.js +13 -0
- package/build/es/src/stores-catalog-v1-collection.public.js.map +1 -0
- package/build/es/src/{stores-poc-v1-collection.types.d.ts → stores-catalog-v1-collection.types.d.ts} +51 -17
- package/build/es/src/{stores-poc-v1-collection.types.js → stores-catalog-v1-collection.types.js} +1 -1
- package/build/es/src/stores-catalog-v1-collection.types.js.map +1 -0
- package/build/es/src/{stores-poc-v1-collection.universal.d.ts → stores-catalog-v1-collection.universal.d.ts} +63 -38
- package/build/es/src/{stores-poc-v1-collection.universal.js → stores-catalog-v1-collection.universal.js} +53 -53
- package/build/es/src/stores-catalog-v1-collection.universal.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product.http.d.ts +62 -0
- package/build/es/src/stores-catalog-v1-product.http.js +751 -0
- package/build/es/src/stores-catalog-v1-product.http.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product.public.d.ts +25 -0
- package/build/es/src/stores-catalog-v1-product.public.js +108 -0
- package/build/es/src/stores-catalog-v1-product.public.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product.types.d.ts +1371 -0
- package/build/es/src/{stores-poc-v1-product.types.js → stores-catalog-v1-product.types.js} +1 -1
- package/build/es/src/stores-catalog-v1-product.types.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product.universal.d.ts +1744 -0
- package/build/es/src/stores-catalog-v1-product.universal.js +1112 -0
- package/build/es/src/stores-catalog-v1-product.universal.js.map +1 -0
- package/package.json +2 -2
- package/build/cjs/src/stores-poc-v1-collection.http.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-collection.public.d.ts +0 -6
- package/build/cjs/src/stores-poc-v1-collection.public.js +0 -20
- package/build/cjs/src/stores-poc-v1-collection.public.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-collection.types.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-collection.universal.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-product.http.d.ts +0 -4
- package/build/cjs/src/stores-poc-v1-product.http.js +0 -143
- package/build/cjs/src/stores-poc-v1-product.http.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-product.public.d.ts +0 -6
- package/build/cjs/src/stores-poc-v1-product.public.js +0 -25
- package/build/cjs/src/stores-poc-v1-product.public.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-product.types.d.ts +0 -470
- package/build/cjs/src/stores-poc-v1-product.types.js.map +0 -1
- package/build/cjs/src/stores-poc-v1-product.universal.d.ts +0 -549
- package/build/cjs/src/stores-poc-v1-product.universal.js +0 -212
- package/build/cjs/src/stores-poc-v1-product.universal.js.map +0 -1
- package/build/es/src/stores-poc-v1-collection.http.js.map +0 -1
- package/build/es/src/stores-poc-v1-collection.public.d.ts +0 -6
- package/build/es/src/stores-poc-v1-collection.public.js +0 -13
- package/build/es/src/stores-poc-v1-collection.public.js.map +0 -1
- package/build/es/src/stores-poc-v1-collection.types.js.map +0 -1
- package/build/es/src/stores-poc-v1-collection.universal.js.map +0 -1
- package/build/es/src/stores-poc-v1-product.http.d.ts +0 -4
- package/build/es/src/stores-poc-v1-product.http.js +0 -138
- package/build/es/src/stores-poc-v1-product.http.js.map +0 -1
- package/build/es/src/stores-poc-v1-product.public.d.ts +0 -6
- package/build/es/src/stores-poc-v1-product.public.js +0 -13
- package/build/es/src/stores-poc-v1-product.public.js.map +0 -1
- package/build/es/src/stores-poc-v1-product.types.d.ts +0 -470
- package/build/es/src/stores-poc-v1-product.types.js.map +0 -1
- package/build/es/src/stores-poc-v1-product.universal.d.ts +0 -549
- package/build/es/src/stores-poc-v1-product.universal.js +0 -188
- package/build/es/src/stores-poc-v1-product.universal.js.map +0 -1
|
@@ -0,0 +1,1112 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { serializer, transformError, resolveQueryFieldsTransformationPaths, } from '@wix/metro-runtime/velo';
|
|
11
|
+
import * as ambassadorWixStoresCatalogV1Product from './stores-catalog-v1-product.http';
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
import { wrapWithQueryBuilder } from '@wix/motion-edm-autogen-query-wrapper';
|
|
14
|
+
let __verbose = false;
|
|
15
|
+
function __log(...args) {
|
|
16
|
+
__verbose && console.log(...args);
|
|
17
|
+
}
|
|
18
|
+
function __inspect(obj) {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
export const __debug = {
|
|
22
|
+
verboseLogging: {
|
|
23
|
+
on: () => (__verbose = true),
|
|
24
|
+
off: () => (__verbose = false),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const _toVeloEntity = '$';
|
|
28
|
+
const _fromVeloEntity = '$';
|
|
29
|
+
export var ProductType;
|
|
30
|
+
(function (ProductType) {
|
|
31
|
+
ProductType["unspecified_product_type"] = "unspecified_product_type";
|
|
32
|
+
ProductType["physical"] = "physical";
|
|
33
|
+
ProductType["digital"] = "digital";
|
|
34
|
+
})(ProductType || (ProductType = {}));
|
|
35
|
+
export var InventoryStatus;
|
|
36
|
+
(function (InventoryStatus) {
|
|
37
|
+
InventoryStatus["IN_STOCK"] = "IN_STOCK";
|
|
38
|
+
InventoryStatus["OUT_OF_STOCK"] = "OUT_OF_STOCK";
|
|
39
|
+
InventoryStatus["PARTIALLY_OUT_OF_STOCK"] = "PARTIALLY_OUT_OF_STOCK";
|
|
40
|
+
})(InventoryStatus || (InventoryStatus = {}));
|
|
41
|
+
export var MeasurementUnit;
|
|
42
|
+
(function (MeasurementUnit) {
|
|
43
|
+
MeasurementUnit["UNSPECIFIED"] = "UNSPECIFIED";
|
|
44
|
+
MeasurementUnit["ML"] = "ML";
|
|
45
|
+
MeasurementUnit["CL"] = "CL";
|
|
46
|
+
MeasurementUnit["L"] = "L";
|
|
47
|
+
MeasurementUnit["CBM"] = "CBM";
|
|
48
|
+
MeasurementUnit["MG"] = "MG";
|
|
49
|
+
MeasurementUnit["G"] = "G";
|
|
50
|
+
MeasurementUnit["KG"] = "KG";
|
|
51
|
+
MeasurementUnit["MM"] = "MM";
|
|
52
|
+
MeasurementUnit["CM"] = "CM";
|
|
53
|
+
MeasurementUnit["M"] = "M";
|
|
54
|
+
MeasurementUnit["SQM"] = "SQM";
|
|
55
|
+
MeasurementUnit["OZ"] = "OZ";
|
|
56
|
+
MeasurementUnit["LB"] = "LB";
|
|
57
|
+
MeasurementUnit["FLOZ"] = "FLOZ";
|
|
58
|
+
MeasurementUnit["PT"] = "PT";
|
|
59
|
+
MeasurementUnit["QT"] = "QT";
|
|
60
|
+
MeasurementUnit["GAL"] = "GAL";
|
|
61
|
+
MeasurementUnit["IN"] = "IN";
|
|
62
|
+
MeasurementUnit["FT"] = "FT";
|
|
63
|
+
MeasurementUnit["YD"] = "YD";
|
|
64
|
+
MeasurementUnit["SQFT"] = "SQFT";
|
|
65
|
+
})(MeasurementUnit || (MeasurementUnit = {}));
|
|
66
|
+
export var MediaItemType;
|
|
67
|
+
(function (MediaItemType) {
|
|
68
|
+
MediaItemType["unspecified_media_item_type"] = "unspecified_media_item_type";
|
|
69
|
+
MediaItemType["image"] = "image";
|
|
70
|
+
MediaItemType["video"] = "video";
|
|
71
|
+
MediaItemType["audio"] = "audio";
|
|
72
|
+
MediaItemType["document"] = "document";
|
|
73
|
+
MediaItemType["zip"] = "zip";
|
|
74
|
+
})(MediaItemType || (MediaItemType = {}));
|
|
75
|
+
export var OptionType;
|
|
76
|
+
(function (OptionType) {
|
|
77
|
+
OptionType["unspecified_option_type"] = "unspecified_option_type";
|
|
78
|
+
OptionType["drop_down"] = "drop_down";
|
|
79
|
+
OptionType["color"] = "color";
|
|
80
|
+
})(OptionType || (OptionType = {}));
|
|
81
|
+
export var DiscountType;
|
|
82
|
+
(function (DiscountType) {
|
|
83
|
+
DiscountType["UNDEFINED"] = "UNDEFINED";
|
|
84
|
+
/** No discount */
|
|
85
|
+
DiscountType["NONE"] = "NONE";
|
|
86
|
+
DiscountType["AMOUNT"] = "AMOUNT";
|
|
87
|
+
DiscountType["PERCENT"] = "PERCENT";
|
|
88
|
+
})(DiscountType || (DiscountType = {}));
|
|
89
|
+
export var SortOrder;
|
|
90
|
+
(function (SortOrder) {
|
|
91
|
+
SortOrder["ASC"] = "ASC";
|
|
92
|
+
SortOrder["DESC"] = "DESC";
|
|
93
|
+
})(SortOrder || (SortOrder = {}));
|
|
94
|
+
const _addProductMediaRequest = {};
|
|
95
|
+
const _addProductMediaResponse = {};
|
|
96
|
+
const _addProductMediaToChoicesRequest = {};
|
|
97
|
+
const _addProductMediaToChoicesResponse = {};
|
|
98
|
+
const _addProductsToCollectionRequest = {};
|
|
99
|
+
const _addProductsToCollectionResponse = {};
|
|
100
|
+
const _bulkAdjustProductPropertiesRequest = {};
|
|
101
|
+
const _bulkAdjustProductPropertiesResponse = {};
|
|
102
|
+
const _bulkUpdateProductsRequest = {};
|
|
103
|
+
const _bulkUpdateProductsResponse = {};
|
|
104
|
+
const _createCollectionRequest = {};
|
|
105
|
+
const _createCollectionResponse = {};
|
|
106
|
+
const _createProductRequest = {};
|
|
107
|
+
const _createProductResponse = {};
|
|
108
|
+
const _deleteCollectionRequest = {};
|
|
109
|
+
const _deleteCollectionResponse = {};
|
|
110
|
+
const _deleteProductOptionsRequest = {};
|
|
111
|
+
const _deleteProductOptionsResponse = {};
|
|
112
|
+
const _deleteProductRequest = {};
|
|
113
|
+
const _deleteProductResponse = {};
|
|
114
|
+
const _getProductRequest = {};
|
|
115
|
+
const _getProductResponse = {};
|
|
116
|
+
const _queryProductsPlatformizedRequest = {};
|
|
117
|
+
const _queryProductsPlatformizedResponse = {};
|
|
118
|
+
const _removeProductBrandRequest = {};
|
|
119
|
+
const _removeProductBrandResponse = {};
|
|
120
|
+
const _removeProductMediaFromChoicesRequest = {};
|
|
121
|
+
const _removeProductMediaFromChoicesResponse = {};
|
|
122
|
+
const _removeProductMediaRequest = {};
|
|
123
|
+
const _removeProductMediaResponse = {};
|
|
124
|
+
const _removeProductRibbonRequest = {};
|
|
125
|
+
const _removeProductRibbonResponse = {};
|
|
126
|
+
const _removeProductsFromCollectionRequest = {};
|
|
127
|
+
const _removeProductsFromCollectionResponse = {};
|
|
128
|
+
const _resetAllVariantDataRequest = {};
|
|
129
|
+
const _resetAllVariantDataResponse = {};
|
|
130
|
+
const _updateCollectionRequest = {};
|
|
131
|
+
const _updateCollectionResponse = {};
|
|
132
|
+
const _updateProductRequest = {};
|
|
133
|
+
const _updateProductResponse = {};
|
|
134
|
+
const _updateVariantsRequest = {};
|
|
135
|
+
const _updateVariantsResponse = {};
|
|
136
|
+
/**
|
|
137
|
+
* Creates a new product.
|
|
138
|
+
* @public
|
|
139
|
+
* @requiredField options.product.costAndProfitData.itemCost
|
|
140
|
+
* @requiredField options.product.name
|
|
141
|
+
* @requiredField options.product.priceData
|
|
142
|
+
* @requiredField options.product.priceData.price
|
|
143
|
+
*/
|
|
144
|
+
export function createProduct(options) {
|
|
145
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
146
|
+
const requestTransformation = { product: '$[0].product' };
|
|
147
|
+
const responseTransformation = '$';
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
const httpClient = arguments[1].httpClient;
|
|
150
|
+
const { toAmbassadorRequest } = serializer({
|
|
151
|
+
rootSchema: _createProductRequest,
|
|
152
|
+
depSchemas: {},
|
|
153
|
+
fqdnTransformation: {
|
|
154
|
+
paths: [...['product']],
|
|
155
|
+
transformation: _fromVeloEntity,
|
|
156
|
+
},
|
|
157
|
+
customTransformation: requestTransformation,
|
|
158
|
+
});
|
|
159
|
+
const { fromJSON } = serializer({
|
|
160
|
+
rootSchema: _createProductResponse,
|
|
161
|
+
depSchemas: {},
|
|
162
|
+
fqdnTransformation: {
|
|
163
|
+
paths: [...['product']],
|
|
164
|
+
transformation: _toVeloEntity,
|
|
165
|
+
},
|
|
166
|
+
customTransformation: responseTransformation,
|
|
167
|
+
});
|
|
168
|
+
const payload = toAmbassadorRequest([options]);
|
|
169
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.createProduct(payload);
|
|
170
|
+
__log(`"CreateProduct" sending request with: ${__inspect(reqOpts)}`);
|
|
171
|
+
try {
|
|
172
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
173
|
+
return fromJSON(data);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
177
|
+
'options',
|
|
178
|
+
]);
|
|
179
|
+
throw transformedError;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Updates specified fields in a product.
|
|
185
|
+
* @param _id - Product ID (generated automatically by the catalog).
|
|
186
|
+
* @public
|
|
187
|
+
* @requiredField _id
|
|
188
|
+
* @requiredField product
|
|
189
|
+
*/
|
|
190
|
+
export function updateProduct(_id, product) {
|
|
191
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
192
|
+
const requestTransformation = { product: { '*': '$[1]', id: '$[0]' } };
|
|
193
|
+
const responseTransformation = '$';
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
const httpClient = arguments[2].httpClient;
|
|
196
|
+
const { toAmbassadorRequest } = serializer({
|
|
197
|
+
rootSchema: _updateProductRequest,
|
|
198
|
+
depSchemas: {},
|
|
199
|
+
fqdnTransformation: {
|
|
200
|
+
paths: [...['product']],
|
|
201
|
+
transformation: _fromVeloEntity,
|
|
202
|
+
},
|
|
203
|
+
customTransformation: requestTransformation,
|
|
204
|
+
});
|
|
205
|
+
const { fromJSON } = serializer({
|
|
206
|
+
rootSchema: _updateProductResponse,
|
|
207
|
+
depSchemas: {},
|
|
208
|
+
fqdnTransformation: {
|
|
209
|
+
paths: [...['product']],
|
|
210
|
+
transformation: _toVeloEntity,
|
|
211
|
+
},
|
|
212
|
+
customTransformation: responseTransformation,
|
|
213
|
+
});
|
|
214
|
+
const payload = toAmbassadorRequest([_id, product]);
|
|
215
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateProduct(payload);
|
|
216
|
+
__log(`"UpdateProduct" sending request with: ${__inspect(reqOpts)}`);
|
|
217
|
+
try {
|
|
218
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
219
|
+
return fromJSON(data);
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
223
|
+
'_id',
|
|
224
|
+
'product',
|
|
225
|
+
]);
|
|
226
|
+
throw transformedError;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Deletes a product.
|
|
232
|
+
* @param _id - ID of the product to be deleted.
|
|
233
|
+
* @public
|
|
234
|
+
* @requiredField _id
|
|
235
|
+
*/
|
|
236
|
+
export function deleteProduct(_id) {
|
|
237
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
238
|
+
const requestTransformation = { id: '$[0]' };
|
|
239
|
+
const responseTransformation = '$';
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
const httpClient = arguments[1].httpClient;
|
|
242
|
+
const { toAmbassadorRequest } = serializer({
|
|
243
|
+
rootSchema: _deleteProductRequest,
|
|
244
|
+
depSchemas: {},
|
|
245
|
+
fqdnTransformation: {
|
|
246
|
+
paths: [],
|
|
247
|
+
transformation: _fromVeloEntity,
|
|
248
|
+
},
|
|
249
|
+
customTransformation: requestTransformation,
|
|
250
|
+
});
|
|
251
|
+
const { fromJSON } = serializer({
|
|
252
|
+
rootSchema: _deleteProductResponse,
|
|
253
|
+
depSchemas: {},
|
|
254
|
+
fqdnTransformation: {
|
|
255
|
+
paths: [],
|
|
256
|
+
transformation: _toVeloEntity,
|
|
257
|
+
},
|
|
258
|
+
customTransformation: responseTransformation,
|
|
259
|
+
});
|
|
260
|
+
const payload = toAmbassadorRequest([_id]);
|
|
261
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProduct(payload);
|
|
262
|
+
__log(`"DeleteProduct" sending request with: ${__inspect(reqOpts)}`);
|
|
263
|
+
try {
|
|
264
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
265
|
+
return fromJSON(data);
|
|
266
|
+
}
|
|
267
|
+
catch (err) {
|
|
268
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
269
|
+
'_id',
|
|
270
|
+
]);
|
|
271
|
+
throw transformedError;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Updates variants of a specified product.
|
|
277
|
+
* @param _id - ID of the product with managed variants.
|
|
278
|
+
* @public
|
|
279
|
+
* @requiredField _id
|
|
280
|
+
*/
|
|
281
|
+
export function updateVariants(_id, options) {
|
|
282
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
283
|
+
const requestTransformation = { id: '$[0]', variants: '$[1].variants' };
|
|
284
|
+
const responseTransformation = '$';
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
const httpClient = arguments[2].httpClient;
|
|
287
|
+
const { toAmbassadorRequest } = serializer({
|
|
288
|
+
rootSchema: _updateVariantsRequest,
|
|
289
|
+
depSchemas: {},
|
|
290
|
+
fqdnTransformation: {
|
|
291
|
+
paths: [],
|
|
292
|
+
transformation: _fromVeloEntity,
|
|
293
|
+
},
|
|
294
|
+
customTransformation: requestTransformation,
|
|
295
|
+
});
|
|
296
|
+
const { fromJSON } = serializer({
|
|
297
|
+
rootSchema: _updateVariantsResponse,
|
|
298
|
+
depSchemas: {},
|
|
299
|
+
fqdnTransformation: {
|
|
300
|
+
paths: [],
|
|
301
|
+
transformation: _toVeloEntity,
|
|
302
|
+
},
|
|
303
|
+
customTransformation: responseTransformation,
|
|
304
|
+
});
|
|
305
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
306
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateVariants(payload);
|
|
307
|
+
__log(`"UpdateVariants" sending request with: ${__inspect(reqOpts)}`);
|
|
308
|
+
try {
|
|
309
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
310
|
+
return fromJSON(data);
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
314
|
+
'_id',
|
|
315
|
+
'options',
|
|
316
|
+
]);
|
|
317
|
+
throw transformedError;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Resets all variant information to default values (price = current product price; weight = current product weight; SKU = current product SKU; visibility = true).
|
|
323
|
+
* @param _id - Product ID.
|
|
324
|
+
* @public
|
|
325
|
+
* @requiredField _id
|
|
326
|
+
*/
|
|
327
|
+
export function resetAllVariantData(_id) {
|
|
328
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
329
|
+
const requestTransformation = { id: '$[0]' };
|
|
330
|
+
const responseTransformation = '$';
|
|
331
|
+
// @ts-ignore
|
|
332
|
+
const httpClient = arguments[1].httpClient;
|
|
333
|
+
const { toAmbassadorRequest } = serializer({
|
|
334
|
+
rootSchema: _resetAllVariantDataRequest,
|
|
335
|
+
depSchemas: {},
|
|
336
|
+
fqdnTransformation: {
|
|
337
|
+
paths: [],
|
|
338
|
+
transformation: _fromVeloEntity,
|
|
339
|
+
},
|
|
340
|
+
customTransformation: requestTransformation,
|
|
341
|
+
});
|
|
342
|
+
const { fromJSON } = serializer({
|
|
343
|
+
rootSchema: _resetAllVariantDataResponse,
|
|
344
|
+
depSchemas: {},
|
|
345
|
+
fqdnTransformation: {
|
|
346
|
+
paths: [],
|
|
347
|
+
transformation: _toVeloEntity,
|
|
348
|
+
},
|
|
349
|
+
customTransformation: responseTransformation,
|
|
350
|
+
});
|
|
351
|
+
const payload = toAmbassadorRequest([_id]);
|
|
352
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.resetAllVariantData(payload);
|
|
353
|
+
__log(`"ResetAllVariantData" sending request with: ${__inspect(reqOpts)}`);
|
|
354
|
+
try {
|
|
355
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
356
|
+
return fromJSON(data);
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
360
|
+
'_id',
|
|
361
|
+
]);
|
|
362
|
+
throw transformedError;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Adds products to a specified collection.
|
|
368
|
+
* @param _id - Collection ID.
|
|
369
|
+
* @public
|
|
370
|
+
* @requiredField _id
|
|
371
|
+
*/
|
|
372
|
+
export function addProductsToCollection(_id, options) {
|
|
373
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
374
|
+
const requestTransformation = { id: '$[0]', productIds: '$[1].productIds' };
|
|
375
|
+
const responseTransformation = '$';
|
|
376
|
+
// @ts-ignore
|
|
377
|
+
const httpClient = arguments[2].httpClient;
|
|
378
|
+
const { toAmbassadorRequest } = serializer({
|
|
379
|
+
rootSchema: _addProductsToCollectionRequest,
|
|
380
|
+
depSchemas: {},
|
|
381
|
+
fqdnTransformation: {
|
|
382
|
+
paths: [],
|
|
383
|
+
transformation: _fromVeloEntity,
|
|
384
|
+
},
|
|
385
|
+
customTransformation: requestTransformation,
|
|
386
|
+
});
|
|
387
|
+
const { fromJSON } = serializer({
|
|
388
|
+
rootSchema: _addProductsToCollectionResponse,
|
|
389
|
+
depSchemas: {},
|
|
390
|
+
fqdnTransformation: {
|
|
391
|
+
paths: [],
|
|
392
|
+
transformation: _toVeloEntity,
|
|
393
|
+
},
|
|
394
|
+
customTransformation: responseTransformation,
|
|
395
|
+
});
|
|
396
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
397
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductsToCollection(payload);
|
|
398
|
+
__log(`"AddProductsToCollection" sending request with: ${__inspect(reqOpts)}`);
|
|
399
|
+
try {
|
|
400
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
401
|
+
return fromJSON(data);
|
|
402
|
+
}
|
|
403
|
+
catch (err) {
|
|
404
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
405
|
+
'_id',
|
|
406
|
+
'options',
|
|
407
|
+
]);
|
|
408
|
+
throw transformedError;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Deletes products from a specified collection.
|
|
414
|
+
* @param _id - Collection ID.
|
|
415
|
+
* @param productIds - IDs of the products that will be deleted from the collection.
|
|
416
|
+
* @public
|
|
417
|
+
* @requiredField _id
|
|
418
|
+
* @requiredField productIds
|
|
419
|
+
*/
|
|
420
|
+
export function removeProductsFromCollection(_id, productIds) {
|
|
421
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
422
|
+
const requestTransformation = { id: '$[0]', productIds: '$[1]' };
|
|
423
|
+
const responseTransformation = '$';
|
|
424
|
+
// @ts-ignore
|
|
425
|
+
const httpClient = arguments[2].httpClient;
|
|
426
|
+
const { toAmbassadorRequest } = serializer({
|
|
427
|
+
rootSchema: _removeProductsFromCollectionRequest,
|
|
428
|
+
depSchemas: {},
|
|
429
|
+
fqdnTransformation: {
|
|
430
|
+
paths: [],
|
|
431
|
+
transformation: _fromVeloEntity,
|
|
432
|
+
},
|
|
433
|
+
customTransformation: requestTransformation,
|
|
434
|
+
});
|
|
435
|
+
const { fromJSON } = serializer({
|
|
436
|
+
rootSchema: _removeProductsFromCollectionResponse,
|
|
437
|
+
depSchemas: {},
|
|
438
|
+
fqdnTransformation: {
|
|
439
|
+
paths: [],
|
|
440
|
+
transformation: _toVeloEntity,
|
|
441
|
+
},
|
|
442
|
+
customTransformation: responseTransformation,
|
|
443
|
+
});
|
|
444
|
+
const payload = toAmbassadorRequest([_id, productIds]);
|
|
445
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductsFromCollection(payload);
|
|
446
|
+
__log(`"RemoveProductsFromCollection" sending request with: ${__inspect(reqOpts)}`);
|
|
447
|
+
try {
|
|
448
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
449
|
+
return fromJSON(data);
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
453
|
+
'_id',
|
|
454
|
+
'productIds',
|
|
455
|
+
]);
|
|
456
|
+
throw transformedError;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Adds media items to a specified product, either via URL or existing media ID.
|
|
462
|
+
* @param _id - Product ID.
|
|
463
|
+
* @public
|
|
464
|
+
* @requiredField _id
|
|
465
|
+
*/
|
|
466
|
+
export function addProductMedia(_id, options) {
|
|
467
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
468
|
+
const requestTransformation = { id: '$[0]', media: '$[1].media' };
|
|
469
|
+
const responseTransformation = '$';
|
|
470
|
+
// @ts-ignore
|
|
471
|
+
const httpClient = arguments[2].httpClient;
|
|
472
|
+
const { toAmbassadorRequest } = serializer({
|
|
473
|
+
rootSchema: _addProductMediaRequest,
|
|
474
|
+
depSchemas: {},
|
|
475
|
+
fqdnTransformation: {
|
|
476
|
+
paths: [],
|
|
477
|
+
transformation: _fromVeloEntity,
|
|
478
|
+
},
|
|
479
|
+
customTransformation: requestTransformation,
|
|
480
|
+
});
|
|
481
|
+
const { fromJSON } = serializer({
|
|
482
|
+
rootSchema: _addProductMediaResponse,
|
|
483
|
+
depSchemas: {},
|
|
484
|
+
fqdnTransformation: {
|
|
485
|
+
paths: [],
|
|
486
|
+
transformation: _toVeloEntity,
|
|
487
|
+
},
|
|
488
|
+
customTransformation: responseTransformation,
|
|
489
|
+
});
|
|
490
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
491
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMedia(payload);
|
|
492
|
+
__log(`"AddProductMedia" sending request with: ${__inspect(reqOpts)}`);
|
|
493
|
+
try {
|
|
494
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
495
|
+
return fromJSON(data);
|
|
496
|
+
}
|
|
497
|
+
catch (err) {
|
|
498
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
499
|
+
'_id',
|
|
500
|
+
'options',
|
|
501
|
+
]);
|
|
502
|
+
throw transformedError;
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Removes specified media items from a product.
|
|
508
|
+
* Pass an empty array to remove all media items.
|
|
509
|
+
* @param _id - Product ID.
|
|
510
|
+
* @public
|
|
511
|
+
* @requiredField _id
|
|
512
|
+
*/
|
|
513
|
+
export function removeProductMedia(_id, options) {
|
|
514
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
515
|
+
const requestTransformation = { id: '$[0]', mediaIds: '$[1].mediaIds' };
|
|
516
|
+
const responseTransformation = '$';
|
|
517
|
+
// @ts-ignore
|
|
518
|
+
const httpClient = arguments[2].httpClient;
|
|
519
|
+
const { toAmbassadorRequest } = serializer({
|
|
520
|
+
rootSchema: _removeProductMediaRequest,
|
|
521
|
+
depSchemas: {},
|
|
522
|
+
fqdnTransformation: {
|
|
523
|
+
paths: [],
|
|
524
|
+
transformation: _fromVeloEntity,
|
|
525
|
+
},
|
|
526
|
+
customTransformation: requestTransformation,
|
|
527
|
+
});
|
|
528
|
+
const { fromJSON } = serializer({
|
|
529
|
+
rootSchema: _removeProductMediaResponse,
|
|
530
|
+
depSchemas: {},
|
|
531
|
+
fqdnTransformation: {
|
|
532
|
+
paths: [],
|
|
533
|
+
transformation: _toVeloEntity,
|
|
534
|
+
},
|
|
535
|
+
customTransformation: responseTransformation,
|
|
536
|
+
});
|
|
537
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
538
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMedia(payload);
|
|
539
|
+
__log(`"RemoveProductMedia" sending request with: ${__inspect(reqOpts)}`);
|
|
540
|
+
try {
|
|
541
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
542
|
+
return fromJSON(data);
|
|
543
|
+
}
|
|
544
|
+
catch (err) {
|
|
545
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
546
|
+
'_id',
|
|
547
|
+
'options',
|
|
548
|
+
]);
|
|
549
|
+
throw transformedError;
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Links media items that are already associated with a specific product to a choice within the same product.
|
|
555
|
+
*
|
|
556
|
+
* Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).
|
|
557
|
+
*
|
|
558
|
+
* To remove all existing media items, call the [Remove Product Media From Choices](https://dev.wix.com/api/rest/wix-stores/catalog/products/remove-product-media-from-choices) endpoint.
|
|
559
|
+
* @param _id - Product ID.
|
|
560
|
+
* @public
|
|
561
|
+
* @requiredField _id
|
|
562
|
+
* @requiredField options.media.choice
|
|
563
|
+
* @requiredField options.media.option
|
|
564
|
+
*/
|
|
565
|
+
export function addProductMediaToChoices(_id, options) {
|
|
566
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
567
|
+
const requestTransformation = { id: '$[0]', media: '$[1].media' };
|
|
568
|
+
const responseTransformation = '$';
|
|
569
|
+
// @ts-ignore
|
|
570
|
+
const httpClient = arguments[2].httpClient;
|
|
571
|
+
const { toAmbassadorRequest } = serializer({
|
|
572
|
+
rootSchema: _addProductMediaToChoicesRequest,
|
|
573
|
+
depSchemas: {},
|
|
574
|
+
fqdnTransformation: {
|
|
575
|
+
paths: [],
|
|
576
|
+
transformation: _fromVeloEntity,
|
|
577
|
+
},
|
|
578
|
+
customTransformation: requestTransformation,
|
|
579
|
+
});
|
|
580
|
+
const { fromJSON } = serializer({
|
|
581
|
+
rootSchema: _addProductMediaToChoicesResponse,
|
|
582
|
+
depSchemas: {},
|
|
583
|
+
fqdnTransformation: {
|
|
584
|
+
paths: [],
|
|
585
|
+
transformation: _toVeloEntity,
|
|
586
|
+
},
|
|
587
|
+
customTransformation: responseTransformation,
|
|
588
|
+
});
|
|
589
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
590
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMediaToChoices(payload);
|
|
591
|
+
__log(`"AddProductMediaToChoices" sending request with: ${__inspect(reqOpts)}`);
|
|
592
|
+
try {
|
|
593
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
594
|
+
return fromJSON(data);
|
|
595
|
+
}
|
|
596
|
+
catch (err) {
|
|
597
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
598
|
+
'_id',
|
|
599
|
+
'options',
|
|
600
|
+
]);
|
|
601
|
+
throw transformedError;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Removes media items from all or some of a product's choices.
|
|
607
|
+
* (Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).)
|
|
608
|
+
* @param _id - Product ID.
|
|
609
|
+
* @public
|
|
610
|
+
* @requiredField _id
|
|
611
|
+
*/
|
|
612
|
+
export function removeProductMediaFromChoices(_id, options) {
|
|
613
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
614
|
+
const requestTransformation = { id: '$[0]', media: '$[1].media' };
|
|
615
|
+
const responseTransformation = '$';
|
|
616
|
+
// @ts-ignore
|
|
617
|
+
const httpClient = arguments[2].httpClient;
|
|
618
|
+
const { toAmbassadorRequest } = serializer({
|
|
619
|
+
rootSchema: _removeProductMediaFromChoicesRequest,
|
|
620
|
+
depSchemas: {},
|
|
621
|
+
fqdnTransformation: {
|
|
622
|
+
paths: [],
|
|
623
|
+
transformation: _fromVeloEntity,
|
|
624
|
+
},
|
|
625
|
+
customTransformation: requestTransformation,
|
|
626
|
+
});
|
|
627
|
+
const { fromJSON } = serializer({
|
|
628
|
+
rootSchema: _removeProductMediaFromChoicesResponse,
|
|
629
|
+
depSchemas: {},
|
|
630
|
+
fqdnTransformation: {
|
|
631
|
+
paths: [],
|
|
632
|
+
transformation: _toVeloEntity,
|
|
633
|
+
},
|
|
634
|
+
customTransformation: responseTransformation,
|
|
635
|
+
});
|
|
636
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
637
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMediaFromChoices(payload);
|
|
638
|
+
__log(`"RemoveProductMediaFromChoices" sending request with: ${__inspect(reqOpts)}`);
|
|
639
|
+
try {
|
|
640
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
641
|
+
return fromJSON(data);
|
|
642
|
+
}
|
|
643
|
+
catch (err) {
|
|
644
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
645
|
+
'_id',
|
|
646
|
+
'options',
|
|
647
|
+
]);
|
|
648
|
+
throw transformedError;
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Delete all options from a specific product (only available when variant management is disabled).
|
|
654
|
+
* @param _id - Product ID.
|
|
655
|
+
* @public
|
|
656
|
+
* @requiredField _id
|
|
657
|
+
*/
|
|
658
|
+
export function deleteProductOptions(_id) {
|
|
659
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
660
|
+
const requestTransformation = { id: '$[0]' };
|
|
661
|
+
const responseTransformation = '$';
|
|
662
|
+
// @ts-ignore
|
|
663
|
+
const httpClient = arguments[1].httpClient;
|
|
664
|
+
const { toAmbassadorRequest } = serializer({
|
|
665
|
+
rootSchema: _deleteProductOptionsRequest,
|
|
666
|
+
depSchemas: {},
|
|
667
|
+
fqdnTransformation: {
|
|
668
|
+
paths: [],
|
|
669
|
+
transformation: _fromVeloEntity,
|
|
670
|
+
},
|
|
671
|
+
customTransformation: requestTransformation,
|
|
672
|
+
});
|
|
673
|
+
const { fromJSON } = serializer({
|
|
674
|
+
rootSchema: _deleteProductOptionsResponse,
|
|
675
|
+
depSchemas: {},
|
|
676
|
+
fqdnTransformation: {
|
|
677
|
+
paths: [],
|
|
678
|
+
transformation: _toVeloEntity,
|
|
679
|
+
},
|
|
680
|
+
customTransformation: responseTransformation,
|
|
681
|
+
});
|
|
682
|
+
const payload = toAmbassadorRequest([_id]);
|
|
683
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProductOptions(payload);
|
|
684
|
+
__log(`"DeleteProductOptions" sending request with: ${__inspect(reqOpts)}`);
|
|
685
|
+
try {
|
|
686
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
687
|
+
return fromJSON(data);
|
|
688
|
+
}
|
|
689
|
+
catch (err) {
|
|
690
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
691
|
+
'_id',
|
|
692
|
+
]);
|
|
693
|
+
throw transformedError;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Deletes a product's brand.
|
|
699
|
+
* @param _id - Product ID.
|
|
700
|
+
* @public
|
|
701
|
+
* @requiredField _id
|
|
702
|
+
*/
|
|
703
|
+
export function removeBrand(_id) {
|
|
704
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
705
|
+
const requestTransformation = { id: '$[0]' };
|
|
706
|
+
const responseTransformation = '$';
|
|
707
|
+
// @ts-ignore
|
|
708
|
+
const httpClient = arguments[1].httpClient;
|
|
709
|
+
const { toAmbassadorRequest } = serializer({
|
|
710
|
+
rootSchema: _removeProductBrandRequest,
|
|
711
|
+
depSchemas: {},
|
|
712
|
+
fqdnTransformation: {
|
|
713
|
+
paths: [],
|
|
714
|
+
transformation: _fromVeloEntity,
|
|
715
|
+
},
|
|
716
|
+
customTransformation: requestTransformation,
|
|
717
|
+
});
|
|
718
|
+
const { fromJSON } = serializer({
|
|
719
|
+
rootSchema: _removeProductBrandResponse,
|
|
720
|
+
depSchemas: {},
|
|
721
|
+
fqdnTransformation: {
|
|
722
|
+
paths: [],
|
|
723
|
+
transformation: _toVeloEntity,
|
|
724
|
+
},
|
|
725
|
+
customTransformation: responseTransformation,
|
|
726
|
+
});
|
|
727
|
+
const payload = toAmbassadorRequest([_id]);
|
|
728
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeBrand(payload);
|
|
729
|
+
__log(`"RemoveBrand" sending request with: ${__inspect(reqOpts)}`);
|
|
730
|
+
try {
|
|
731
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
732
|
+
return fromJSON(data);
|
|
733
|
+
}
|
|
734
|
+
catch (err) {
|
|
735
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
736
|
+
'_id',
|
|
737
|
+
]);
|
|
738
|
+
throw transformedError;
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Creates a new collection.
|
|
744
|
+
* @param collection - Collection information.
|
|
745
|
+
* @public
|
|
746
|
+
* @requiredField collection
|
|
747
|
+
* @requiredField collection.name
|
|
748
|
+
*/
|
|
749
|
+
export function createCollection(collection) {
|
|
750
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
751
|
+
const requestTransformation = { collection: '$[0]' };
|
|
752
|
+
const responseTransformation = '$';
|
|
753
|
+
// @ts-ignore
|
|
754
|
+
const httpClient = arguments[1].httpClient;
|
|
755
|
+
const { toAmbassadorRequest } = serializer({
|
|
756
|
+
rootSchema: _createCollectionRequest,
|
|
757
|
+
depSchemas: {},
|
|
758
|
+
fqdnTransformation: {
|
|
759
|
+
paths: [],
|
|
760
|
+
transformation: _fromVeloEntity,
|
|
761
|
+
},
|
|
762
|
+
customTransformation: requestTransformation,
|
|
763
|
+
});
|
|
764
|
+
const { fromJSON } = serializer({
|
|
765
|
+
rootSchema: _createCollectionResponse,
|
|
766
|
+
depSchemas: {},
|
|
767
|
+
fqdnTransformation: {
|
|
768
|
+
paths: [],
|
|
769
|
+
transformation: _toVeloEntity,
|
|
770
|
+
},
|
|
771
|
+
customTransformation: responseTransformation,
|
|
772
|
+
});
|
|
773
|
+
const payload = toAmbassadorRequest([collection]);
|
|
774
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.createCollection(payload);
|
|
775
|
+
__log(`"CreateCollection" sending request with: ${__inspect(reqOpts)}`);
|
|
776
|
+
try {
|
|
777
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
778
|
+
return fromJSON(data);
|
|
779
|
+
}
|
|
780
|
+
catch (err) {
|
|
781
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
782
|
+
'collection',
|
|
783
|
+
]);
|
|
784
|
+
throw transformedError;
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Updates specified properties of a collection.
|
|
790
|
+
* To add products to a collection, call the [Add Products to Collection](https://dev.wix.com/api/rest/wix-stores/catalog/collection/add-products-to-collection) endpoint.
|
|
791
|
+
* @param _id - Collection ID (generated automatically by the catalog)
|
|
792
|
+
* @public
|
|
793
|
+
* @requiredField _id
|
|
794
|
+
* @requiredField collection
|
|
795
|
+
*/
|
|
796
|
+
export function updateCollection(_id, collection) {
|
|
797
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
798
|
+
const requestTransformation = { collection: { '*': '$[1]', id: '$[0]' } };
|
|
799
|
+
const responseTransformation = '$';
|
|
800
|
+
// @ts-ignore
|
|
801
|
+
const httpClient = arguments[2].httpClient;
|
|
802
|
+
const { toAmbassadorRequest } = serializer({
|
|
803
|
+
rootSchema: _updateCollectionRequest,
|
|
804
|
+
depSchemas: {},
|
|
805
|
+
fqdnTransformation: {
|
|
806
|
+
paths: [],
|
|
807
|
+
transformation: _fromVeloEntity,
|
|
808
|
+
},
|
|
809
|
+
customTransformation: requestTransformation,
|
|
810
|
+
});
|
|
811
|
+
const { fromJSON } = serializer({
|
|
812
|
+
rootSchema: _updateCollectionResponse,
|
|
813
|
+
depSchemas: {},
|
|
814
|
+
fqdnTransformation: {
|
|
815
|
+
paths: [],
|
|
816
|
+
transformation: _toVeloEntity,
|
|
817
|
+
},
|
|
818
|
+
customTransformation: responseTransformation,
|
|
819
|
+
});
|
|
820
|
+
const payload = toAmbassadorRequest([_id, collection]);
|
|
821
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateCollection(payload);
|
|
822
|
+
__log(`"UpdateCollection" sending request with: ${__inspect(reqOpts)}`);
|
|
823
|
+
try {
|
|
824
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
825
|
+
return fromJSON(data);
|
|
826
|
+
}
|
|
827
|
+
catch (err) {
|
|
828
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
829
|
+
'_id',
|
|
830
|
+
'collection',
|
|
831
|
+
]);
|
|
832
|
+
throw transformedError;
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Deletes a collection.
|
|
838
|
+
* @param _id - Collection ID.
|
|
839
|
+
* @public
|
|
840
|
+
* @requiredField _id
|
|
841
|
+
*/
|
|
842
|
+
export function deleteCollection(_id) {
|
|
843
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
844
|
+
const requestTransformation = { id: '$[0]' };
|
|
845
|
+
const responseTransformation = '$';
|
|
846
|
+
// @ts-ignore
|
|
847
|
+
const httpClient = arguments[1].httpClient;
|
|
848
|
+
const { toAmbassadorRequest } = serializer({
|
|
849
|
+
rootSchema: _deleteCollectionRequest,
|
|
850
|
+
depSchemas: {},
|
|
851
|
+
fqdnTransformation: {
|
|
852
|
+
paths: [],
|
|
853
|
+
transformation: _fromVeloEntity,
|
|
854
|
+
},
|
|
855
|
+
customTransformation: requestTransformation,
|
|
856
|
+
});
|
|
857
|
+
const { fromJSON } = serializer({
|
|
858
|
+
rootSchema: _deleteCollectionResponse,
|
|
859
|
+
depSchemas: {},
|
|
860
|
+
fqdnTransformation: {
|
|
861
|
+
paths: [],
|
|
862
|
+
transformation: _toVeloEntity,
|
|
863
|
+
},
|
|
864
|
+
customTransformation: responseTransformation,
|
|
865
|
+
});
|
|
866
|
+
const payload = toAmbassadorRequest([_id]);
|
|
867
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteCollection(payload);
|
|
868
|
+
__log(`"DeleteCollection" sending request with: ${__inspect(reqOpts)}`);
|
|
869
|
+
try {
|
|
870
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
871
|
+
return fromJSON(data);
|
|
872
|
+
}
|
|
873
|
+
catch (err) {
|
|
874
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
875
|
+
'_id',
|
|
876
|
+
]);
|
|
877
|
+
throw transformedError;
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Deletes a product's ribbon.
|
|
883
|
+
* @param _id - Product ID.
|
|
884
|
+
* @public
|
|
885
|
+
* @requiredField _id
|
|
886
|
+
*/
|
|
887
|
+
export function removeRibbon(_id) {
|
|
888
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
889
|
+
const requestTransformation = { id: '$[0]' };
|
|
890
|
+
const responseTransformation = '$';
|
|
891
|
+
// @ts-ignore
|
|
892
|
+
const httpClient = arguments[1].httpClient;
|
|
893
|
+
const { toAmbassadorRequest } = serializer({
|
|
894
|
+
rootSchema: _removeProductRibbonRequest,
|
|
895
|
+
depSchemas: {},
|
|
896
|
+
fqdnTransformation: {
|
|
897
|
+
paths: [],
|
|
898
|
+
transformation: _fromVeloEntity,
|
|
899
|
+
},
|
|
900
|
+
customTransformation: requestTransformation,
|
|
901
|
+
});
|
|
902
|
+
const { fromJSON } = serializer({
|
|
903
|
+
rootSchema: _removeProductRibbonResponse,
|
|
904
|
+
depSchemas: {},
|
|
905
|
+
fqdnTransformation: {
|
|
906
|
+
paths: [],
|
|
907
|
+
transformation: _toVeloEntity,
|
|
908
|
+
},
|
|
909
|
+
customTransformation: responseTransformation,
|
|
910
|
+
});
|
|
911
|
+
const payload = toAmbassadorRequest([_id]);
|
|
912
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeRibbon(payload);
|
|
913
|
+
__log(`"RemoveRibbon" sending request with: ${__inspect(reqOpts)}`);
|
|
914
|
+
try {
|
|
915
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
916
|
+
return fromJSON(data);
|
|
917
|
+
}
|
|
918
|
+
catch (err) {
|
|
919
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
920
|
+
'_id',
|
|
921
|
+
]);
|
|
922
|
+
throw transformedError;
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Updates a specified property for up to 100 products at a time.
|
|
928
|
+
* @param ids - Product IDs.
|
|
929
|
+
* @public
|
|
930
|
+
* @requiredField ids
|
|
931
|
+
*/
|
|
932
|
+
export function bulkUpdateProducts(ids, options) {
|
|
933
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
934
|
+
const requestTransformation = { ids: '$[0]', set: '$[1].set' };
|
|
935
|
+
const responseTransformation = '$';
|
|
936
|
+
// @ts-ignore
|
|
937
|
+
const httpClient = arguments[2].httpClient;
|
|
938
|
+
const { toAmbassadorRequest } = serializer({
|
|
939
|
+
rootSchema: _bulkUpdateProductsRequest,
|
|
940
|
+
depSchemas: {},
|
|
941
|
+
fqdnTransformation: {
|
|
942
|
+
paths: [],
|
|
943
|
+
transformation: _fromVeloEntity,
|
|
944
|
+
},
|
|
945
|
+
customTransformation: requestTransformation,
|
|
946
|
+
});
|
|
947
|
+
const { fromJSON } = serializer({
|
|
948
|
+
rootSchema: _bulkUpdateProductsResponse,
|
|
949
|
+
depSchemas: {},
|
|
950
|
+
fqdnTransformation: {
|
|
951
|
+
paths: [],
|
|
952
|
+
transformation: _toVeloEntity,
|
|
953
|
+
},
|
|
954
|
+
customTransformation: responseTransformation,
|
|
955
|
+
});
|
|
956
|
+
const payload = toAmbassadorRequest([ids, options]);
|
|
957
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.bulkUpdateProducts(payload);
|
|
958
|
+
__log(`"BulkUpdateProducts" sending request with: ${__inspect(reqOpts)}`);
|
|
959
|
+
try {
|
|
960
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
961
|
+
return fromJSON(data);
|
|
962
|
+
}
|
|
963
|
+
catch (err) {
|
|
964
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
965
|
+
'ids',
|
|
966
|
+
'options',
|
|
967
|
+
]);
|
|
968
|
+
throw transformedError;
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Adjusts a specified numerical property for up to 100 products at a time.
|
|
974
|
+
* The property can be increased or decreased either by percentage or amount.
|
|
975
|
+
* @param ids - Product IDs.
|
|
976
|
+
* @public
|
|
977
|
+
* @requiredField ids
|
|
978
|
+
*/
|
|
979
|
+
export function bulkAdjustProductProperties(ids, options) {
|
|
980
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
981
|
+
const requestTransformation = { ids: '$[0]', adjust: '$[1].adjust' };
|
|
982
|
+
const responseTransformation = '$';
|
|
983
|
+
// @ts-ignore
|
|
984
|
+
const httpClient = arguments[2].httpClient;
|
|
985
|
+
const { toAmbassadorRequest } = serializer({
|
|
986
|
+
rootSchema: _bulkAdjustProductPropertiesRequest,
|
|
987
|
+
depSchemas: {},
|
|
988
|
+
fqdnTransformation: {
|
|
989
|
+
paths: [],
|
|
990
|
+
transformation: _fromVeloEntity,
|
|
991
|
+
},
|
|
992
|
+
customTransformation: requestTransformation,
|
|
993
|
+
});
|
|
994
|
+
const { fromJSON } = serializer({
|
|
995
|
+
rootSchema: _bulkAdjustProductPropertiesResponse,
|
|
996
|
+
depSchemas: {},
|
|
997
|
+
fqdnTransformation: {
|
|
998
|
+
paths: [],
|
|
999
|
+
transformation: _toVeloEntity,
|
|
1000
|
+
},
|
|
1001
|
+
customTransformation: responseTransformation,
|
|
1002
|
+
});
|
|
1003
|
+
const payload = toAmbassadorRequest([ids, options]);
|
|
1004
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.bulkAdjustProductProperties(payload);
|
|
1005
|
+
__log(`"BulkAdjustProductProperties" sending request with: ${__inspect(reqOpts)}`);
|
|
1006
|
+
try {
|
|
1007
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
1008
|
+
return fromJSON(data);
|
|
1009
|
+
}
|
|
1010
|
+
catch (err) {
|
|
1011
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
1012
|
+
'ids',
|
|
1013
|
+
'options',
|
|
1014
|
+
]);
|
|
1015
|
+
throw transformedError;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Returns a list of up to 100 products, given the provided paging, sorting and filtering.
|
|
1021
|
+
* @public */
|
|
1022
|
+
export function queryProducts() {
|
|
1023
|
+
const requestTransformation = { '*': '$[1]', query: '$[0]' };
|
|
1024
|
+
const responseTransformation = {
|
|
1025
|
+
items: '$.products',
|
|
1026
|
+
pagingMetadata: '$.metadata',
|
|
1027
|
+
};
|
|
1028
|
+
// @ts-ignore
|
|
1029
|
+
const httpClient = arguments[0].httpClient;
|
|
1030
|
+
const { toAmbassadorRequest } = serializer({
|
|
1031
|
+
rootSchema: _queryProductsPlatformizedRequest,
|
|
1032
|
+
depSchemas: {},
|
|
1033
|
+
fqdnTransformation: {
|
|
1034
|
+
paths: [],
|
|
1035
|
+
transformation: _fromVeloEntity,
|
|
1036
|
+
},
|
|
1037
|
+
customTransformation: requestTransformation,
|
|
1038
|
+
});
|
|
1039
|
+
const { fromJSON } = serializer({
|
|
1040
|
+
rootSchema: _queryProductsPlatformizedResponse,
|
|
1041
|
+
depSchemas: {},
|
|
1042
|
+
fqdnTransformation: {
|
|
1043
|
+
paths: [...['Array#products']],
|
|
1044
|
+
transformation: _toVeloEntity,
|
|
1045
|
+
},
|
|
1046
|
+
customTransformation: responseTransformation,
|
|
1047
|
+
});
|
|
1048
|
+
return wrapWithQueryBuilder({
|
|
1049
|
+
func: (payload) => {
|
|
1050
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.queryProductsPlatformized(payload);
|
|
1051
|
+
return httpClient.request(reqOpts);
|
|
1052
|
+
},
|
|
1053
|
+
requestTransformer: (...args) => toAmbassadorRequest(args),
|
|
1054
|
+
responseTransformer: ({ data }) => fromJSON(data),
|
|
1055
|
+
errorTransformer: (err) => {
|
|
1056
|
+
const transformedError = transformError(err, requestTransformation);
|
|
1057
|
+
throw transformedError;
|
|
1058
|
+
},
|
|
1059
|
+
pagingMethod: 'CURSOR',
|
|
1060
|
+
transformationPaths: resolveQueryFieldsTransformationPaths(_toVeloEntity),
|
|
1061
|
+
})({ cursorWithEmptyFilterAndSort: true });
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Retrieves a product with the provided ID.
|
|
1065
|
+
* @param _id - Requested product ID.
|
|
1066
|
+
* @public
|
|
1067
|
+
* @requiredField _id
|
|
1068
|
+
*/
|
|
1069
|
+
export function getProduct(_id, options) {
|
|
1070
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
1071
|
+
const requestTransformation = {
|
|
1072
|
+
id: '$[0]',
|
|
1073
|
+
includeMerchantSpecificData: '$[1].includeMerchantSpecificData',
|
|
1074
|
+
};
|
|
1075
|
+
const responseTransformation = '$';
|
|
1076
|
+
// @ts-ignore
|
|
1077
|
+
const httpClient = arguments[2].httpClient;
|
|
1078
|
+
const { toAmbassadorRequest } = serializer({
|
|
1079
|
+
rootSchema: _getProductRequest,
|
|
1080
|
+
depSchemas: {},
|
|
1081
|
+
fqdnTransformation: {
|
|
1082
|
+
paths: [],
|
|
1083
|
+
transformation: _fromVeloEntity,
|
|
1084
|
+
},
|
|
1085
|
+
customTransformation: requestTransformation,
|
|
1086
|
+
});
|
|
1087
|
+
const { fromJSON } = serializer({
|
|
1088
|
+
rootSchema: _getProductResponse,
|
|
1089
|
+
depSchemas: {},
|
|
1090
|
+
fqdnTransformation: {
|
|
1091
|
+
paths: [...['product']],
|
|
1092
|
+
transformation: _toVeloEntity,
|
|
1093
|
+
},
|
|
1094
|
+
customTransformation: responseTransformation,
|
|
1095
|
+
});
|
|
1096
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
1097
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.getProduct(payload);
|
|
1098
|
+
__log(`"GetProduct" sending request with: ${__inspect(reqOpts)}`);
|
|
1099
|
+
try {
|
|
1100
|
+
const { data } = yield httpClient.request(reqOpts);
|
|
1101
|
+
return fromJSON(data);
|
|
1102
|
+
}
|
|
1103
|
+
catch (err) {
|
|
1104
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
1105
|
+
'_id',
|
|
1106
|
+
'options',
|
|
1107
|
+
]);
|
|
1108
|
+
throw transformedError;
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
//# sourceMappingURL=stores-catalog-v1-product.universal.js.map
|