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