@wix/stores 1.0.60 → 1.0.61

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.
Files changed (75) hide show
  1. package/build/cjs/index.d.ts +1 -1
  2. package/build/cjs/index.js +1 -1
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/src/stores-catalog-v1-product.http.d.ts +21 -1
  5. package/build/cjs/src/stores-catalog-v1-product.http.js +283 -1
  6. package/build/cjs/src/stores-catalog-v1-product.http.js.map +1 -1
  7. package/build/cjs/src/stores-catalog-v1-product.public.d.ts +35 -0
  8. package/build/cjs/src/stores-catalog-v1-product.public.js +182 -0
  9. package/build/cjs/src/stores-catalog-v1-product.public.js.map +1 -0
  10. package/build/cjs/src/stores-catalog-v1-product.types.d.ts +37 -32
  11. package/build/cjs/src/stores-catalog-v1-product.types.js.map +1 -1
  12. package/build/cjs/src/{stores-catalog-v1-product-products.universal.d.ts → stores-catalog-v1-product.universal.d.ts} +446 -8
  13. package/build/cjs/src/stores-catalog-v1-product.universal.js +1657 -0
  14. package/build/cjs/src/stores-catalog-v1-product.universal.js.map +1 -0
  15. package/build/cjs/src/stores-v1-subscription-option.http.js +6 -0
  16. package/build/cjs/src/stores-v1-subscription-option.http.js.map +1 -1
  17. package/build/cjs/src/stores-v2-inventory.http.d.ts +29 -3
  18. package/build/cjs/src/stores-v2-inventory.http.js +177 -3
  19. package/build/cjs/src/stores-v2-inventory.http.js.map +1 -1
  20. package/build/cjs/src/stores-v2-inventory.public.d.ts +7 -4
  21. package/build/cjs/src/stores-v2-inventory.public.js +21 -3
  22. package/build/cjs/src/stores-v2-inventory.public.js.map +1 -1
  23. package/build/cjs/src/stores-v2-inventory.types.d.ts +2 -2
  24. package/build/cjs/src/stores-v2-inventory.universal.d.ts +107 -17
  25. package/build/cjs/src/stores-v2-inventory.universal.js +193 -11
  26. package/build/cjs/src/stores-v2-inventory.universal.js.map +1 -1
  27. package/build/es/index.d.ts +1 -1
  28. package/build/es/index.js +1 -1
  29. package/build/es/index.js.map +1 -1
  30. package/build/es/src/stores-catalog-v1-product.http.d.ts +21 -1
  31. package/build/es/src/stores-catalog-v1-product.http.js +275 -0
  32. package/build/es/src/stores-catalog-v1-product.http.js.map +1 -1
  33. package/build/es/src/stores-catalog-v1-product.public.d.ts +35 -0
  34. package/build/es/src/stores-catalog-v1-product.public.js +144 -0
  35. package/build/es/src/stores-catalog-v1-product.public.js.map +1 -0
  36. package/build/es/src/stores-catalog-v1-product.types.d.ts +37 -32
  37. package/build/es/src/stores-catalog-v1-product.types.js.map +1 -1
  38. package/build/es/src/{stores-catalog-v1-product-products.universal.d.ts → stores-catalog-v1-product.universal.d.ts} +446 -8
  39. package/build/es/src/stores-catalog-v1-product.universal.js +1607 -0
  40. package/build/es/src/stores-catalog-v1-product.universal.js.map +1 -0
  41. package/build/es/src/stores-v1-subscription-option.http.js +6 -0
  42. package/build/es/src/stores-v1-subscription-option.http.js.map +1 -1
  43. package/build/es/src/stores-v2-inventory.http.d.ts +29 -3
  44. package/build/es/src/stores-v2-inventory.http.js +173 -2
  45. package/build/es/src/stores-v2-inventory.http.js.map +1 -1
  46. package/build/es/src/stores-v2-inventory.public.d.ts +7 -4
  47. package/build/es/src/stores-v2-inventory.public.js +18 -3
  48. package/build/es/src/stores-v2-inventory.public.js.map +1 -1
  49. package/build/es/src/stores-v2-inventory.types.d.ts +2 -2
  50. package/build/es/src/stores-v2-inventory.universal.d.ts +107 -17
  51. package/build/es/src/stores-v2-inventory.universal.js +189 -10
  52. package/build/es/src/stores-v2-inventory.universal.js.map +1 -1
  53. package/package.json +2 -2
  54. package/build/cjs/src/stores-catalog-v1-product-products.http.d.ts +0 -62
  55. package/build/cjs/src/stores-catalog-v1-product-products.http.js +0 -845
  56. package/build/cjs/src/stores-catalog-v1-product-products.http.js.map +0 -1
  57. package/build/cjs/src/stores-catalog-v1-product-products.public.d.ts +0 -9
  58. package/build/cjs/src/stores-catalog-v1-product-products.public.js +0 -26
  59. package/build/cjs/src/stores-catalog-v1-product-products.public.js.map +0 -1
  60. package/build/cjs/src/stores-catalog-v1-product-products.types.d.ts +0 -1398
  61. package/build/cjs/src/stores-catalog-v1-product-products.types.js +0 -69
  62. package/build/cjs/src/stores-catalog-v1-product-products.types.js.map +0 -1
  63. package/build/cjs/src/stores-catalog-v1-product-products.universal.js +0 -232
  64. package/build/cjs/src/stores-catalog-v1-product-products.universal.js.map +0 -1
  65. package/build/es/src/stores-catalog-v1-product-products.http.d.ts +0 -62
  66. package/build/es/src/stores-catalog-v1-product-products.http.js +0 -821
  67. package/build/es/src/stores-catalog-v1-product-products.http.js.map +0 -1
  68. package/build/es/src/stores-catalog-v1-product-products.public.d.ts +0 -9
  69. package/build/es/src/stores-catalog-v1-product-products.public.js +0 -14
  70. package/build/es/src/stores-catalog-v1-product-products.public.js.map +0 -1
  71. package/build/es/src/stores-catalog-v1-product-products.types.d.ts +0 -1398
  72. package/build/es/src/stores-catalog-v1-product-products.types.js +0 -66
  73. package/build/es/src/stores-catalog-v1-product-products.types.js.map +0 -1
  74. package/build/es/src/stores-catalog-v1-product-products.universal.js +0 -208
  75. package/build/es/src/stores-catalog-v1-product-products.universal.js.map +0 -1
@@ -0,0 +1,1657 @@
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.getStoreVariant = exports.queryStoreVariants = exports.queryProductVariants = exports.getProductOptionsAvailability = exports.getCollectionBySlug = exports.getCollection = exports.queryCollections = 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 _getCollectionBySlugRequest = {};
137
+ const _getCollectionBySlugResponse = {};
138
+ const _getCollectionRequest = {};
139
+ const _getCollectionResponse = {};
140
+ const _getProductRequest = {};
141
+ const _getProductResponse = {};
142
+ const _getStoreVariantRequest = {};
143
+ const _getStoreVariantResponse = { variant: '_storeVariant' };
144
+ const _platformMedia = {
145
+ image: 'wix.common.Image',
146
+ video: 'wix.common.VideoV2',
147
+ };
148
+ const _productOptionsAvailabilityRequest = {};
149
+ const _productOptionsAvailabilityResponse = {};
150
+ const _queryCollectionsRequest = {};
151
+ const _queryCollectionsResponse = {};
152
+ const _queryProductsPlatformizedRequest = {};
153
+ const _queryProductsPlatformizedResponse = {};
154
+ const _queryProductVariantsRequest = {};
155
+ const _queryProductVariantsResponse = {};
156
+ const _queryStoreVariantsRequest = {};
157
+ const _queryStoreVariantsResponse = { variants: '_storeVariant' };
158
+ const _removeProductBrandRequest = {};
159
+ const _removeProductBrandResponse = {};
160
+ const _removeProductMediaFromChoicesRequest = {};
161
+ const _removeProductMediaFromChoicesResponse = {};
162
+ const _removeProductMediaRequest = {};
163
+ const _removeProductMediaResponse = {};
164
+ const _removeProductRibbonRequest = {};
165
+ const _removeProductRibbonResponse = {};
166
+ const _removeProductsFromCollectionRequest = {};
167
+ const _removeProductsFromCollectionResponse = {};
168
+ const _resetAllVariantDataRequest = {};
169
+ const _resetAllVariantDataResponse = {};
170
+ const _storeVariant = { media: '_platformMedia' };
171
+ const _updateCollectionRequest = {};
172
+ const _updateCollectionResponse = {};
173
+ const _updateProductRequest = {};
174
+ const _updateProductResponse = {};
175
+ const _updateVariantsRequest = {};
176
+ const _updateVariantsResponse = {};
177
+ /**
178
+ * Creates a new product.
179
+ * @public
180
+ * @documentationMaturity preview
181
+ * @requiredField options.product.costAndProfitData.itemCost
182
+ * @requiredField options.product.name
183
+ * @requiredField options.product.priceData
184
+ * @requiredField options.product.priceData.price
185
+ */
186
+ function createProduct(options) {
187
+ var _a, _b, _c;
188
+ return __awaiter(this, arguments, void 0, function* () {
189
+ const requestTransformation = { product: '$[0].product' };
190
+ const responseTransformation = '$';
191
+ // @ts-ignore
192
+ const { httpClient, sideEffects } = arguments[1];
193
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
194
+ rootSchema: _createProductRequest,
195
+ depSchemas: {},
196
+ fqdnTransformation: {
197
+ paths: [...['product']],
198
+ transformation: _fromVeloEntity,
199
+ },
200
+ customTransformation: requestTransformation,
201
+ });
202
+ const { fromJSON } = (0, velo_1.serializer)({
203
+ rootSchema: _createProductResponse,
204
+ depSchemas: {},
205
+ fqdnTransformation: {
206
+ paths: [...['product']],
207
+ transformation: _toVeloEntity,
208
+ },
209
+ customTransformation: responseTransformation,
210
+ });
211
+ const payload = toAmbassadorRequest([options]);
212
+ const reqOpts = ambassadorWixStoresCatalogV1Product.createProduct(payload);
213
+ __log(`"CreateProduct" sending request with: ${__inspect(reqOpts)}`);
214
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
215
+ try {
216
+ const result = yield httpClient.request(reqOpts);
217
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
218
+ return fromJSON(result.data);
219
+ }
220
+ catch (err) {
221
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
222
+ 'options',
223
+ ]);
224
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
225
+ throw transformedError;
226
+ }
227
+ });
228
+ }
229
+ exports.createProduct = createProduct;
230
+ /**
231
+ * Updates specified fields in a product.
232
+ * @param _id - Product ID (generated automatically by the catalog).
233
+ * @public
234
+ * @documentationMaturity preview
235
+ * @requiredField _id
236
+ * @requiredField product
237
+ */
238
+ function updateProduct(_id, product) {
239
+ var _a, _b, _c;
240
+ return __awaiter(this, arguments, void 0, function* () {
241
+ const requestTransformation = { product: { '*': '$[1]', id: '$[0]' } };
242
+ const responseTransformation = '$';
243
+ // @ts-ignore
244
+ const { httpClient, sideEffects } = arguments[2];
245
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
246
+ rootSchema: _updateProductRequest,
247
+ depSchemas: {},
248
+ fqdnTransformation: {
249
+ paths: [...['product']],
250
+ transformation: _fromVeloEntity,
251
+ },
252
+ customTransformation: requestTransformation,
253
+ });
254
+ const { fromJSON } = (0, velo_1.serializer)({
255
+ rootSchema: _updateProductResponse,
256
+ depSchemas: {},
257
+ fqdnTransformation: {
258
+ paths: [...['product']],
259
+ transformation: _toVeloEntity,
260
+ },
261
+ customTransformation: responseTransformation,
262
+ });
263
+ const payload = toAmbassadorRequest([_id, product]);
264
+ const reqOpts = ambassadorWixStoresCatalogV1Product.updateProduct(payload);
265
+ __log(`"UpdateProduct" sending request with: ${__inspect(reqOpts)}`);
266
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
267
+ try {
268
+ const result = yield httpClient.request(reqOpts);
269
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
270
+ return fromJSON(result.data);
271
+ }
272
+ catch (err) {
273
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
274
+ '_id',
275
+ 'product',
276
+ ]);
277
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
278
+ throw transformedError;
279
+ }
280
+ });
281
+ }
282
+ exports.updateProduct = updateProduct;
283
+ /**
284
+ * Deletes a product.
285
+ * @param _id - ID of the product to be deleted.
286
+ * @public
287
+ * @documentationMaturity preview
288
+ * @requiredField _id
289
+ */
290
+ function deleteProduct(_id) {
291
+ var _a, _b, _c;
292
+ return __awaiter(this, arguments, void 0, function* () {
293
+ const requestTransformation = { id: '$[0]' };
294
+ const responseTransformation = '$';
295
+ // @ts-ignore
296
+ const { httpClient, sideEffects } = arguments[1];
297
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
298
+ rootSchema: _deleteProductRequest,
299
+ depSchemas: {},
300
+ fqdnTransformation: {
301
+ paths: [],
302
+ transformation: _fromVeloEntity,
303
+ },
304
+ customTransformation: requestTransformation,
305
+ });
306
+ const { fromJSON } = (0, velo_1.serializer)({
307
+ rootSchema: _deleteProductResponse,
308
+ depSchemas: {},
309
+ fqdnTransformation: {
310
+ paths: [],
311
+ transformation: _toVeloEntity,
312
+ },
313
+ customTransformation: responseTransformation,
314
+ });
315
+ const payload = toAmbassadorRequest([_id]);
316
+ const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProduct(payload);
317
+ __log(`"DeleteProduct" sending request with: ${__inspect(reqOpts)}`);
318
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
319
+ try {
320
+ const result = yield httpClient.request(reqOpts);
321
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
322
+ return fromJSON(result.data);
323
+ }
324
+ catch (err) {
325
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
326
+ '_id',
327
+ ]);
328
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
329
+ throw transformedError;
330
+ }
331
+ });
332
+ }
333
+ exports.deleteProduct = deleteProduct;
334
+ /**
335
+ * Updates variants of a specified product.
336
+ * @param _id - ID of the product with managed variants.
337
+ * @public
338
+ * @documentationMaturity preview
339
+ * @requiredField _id
340
+ */
341
+ function updateVariants(_id, options) {
342
+ var _a, _b, _c;
343
+ return __awaiter(this, arguments, void 0, function* () {
344
+ const requestTransformation = { id: '$[0]', variants: '$[1].variants' };
345
+ const responseTransformation = '$';
346
+ // @ts-ignore
347
+ const { httpClient, sideEffects } = arguments[2];
348
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
349
+ rootSchema: _updateVariantsRequest,
350
+ depSchemas: {},
351
+ fqdnTransformation: {
352
+ paths: [],
353
+ transformation: _fromVeloEntity,
354
+ },
355
+ customTransformation: requestTransformation,
356
+ });
357
+ const { fromJSON } = (0, velo_1.serializer)({
358
+ rootSchema: _updateVariantsResponse,
359
+ depSchemas: {},
360
+ fqdnTransformation: {
361
+ paths: [],
362
+ transformation: _toVeloEntity,
363
+ },
364
+ customTransformation: responseTransformation,
365
+ });
366
+ const payload = toAmbassadorRequest([_id, options]);
367
+ const reqOpts = ambassadorWixStoresCatalogV1Product.updateVariants(payload);
368
+ __log(`"UpdateVariants" sending request with: ${__inspect(reqOpts)}`);
369
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
370
+ try {
371
+ const result = yield httpClient.request(reqOpts);
372
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
373
+ return fromJSON(result.data);
374
+ }
375
+ catch (err) {
376
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
377
+ '_id',
378
+ 'options',
379
+ ]);
380
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
381
+ throw transformedError;
382
+ }
383
+ });
384
+ }
385
+ exports.updateVariants = updateVariants;
386
+ /**
387
+ * Resets all variant information to default values (price = current product price; weight = current product weight; SKU = current product SKU; visibility = true).
388
+ * @param _id - Product ID.
389
+ * @public
390
+ * @documentationMaturity preview
391
+ * @requiredField _id
392
+ */
393
+ function resetAllVariantData(_id) {
394
+ var _a, _b, _c;
395
+ return __awaiter(this, arguments, void 0, function* () {
396
+ const requestTransformation = { id: '$[0]' };
397
+ const responseTransformation = '$';
398
+ // @ts-ignore
399
+ const { httpClient, sideEffects } = arguments[1];
400
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
401
+ rootSchema: _resetAllVariantDataRequest,
402
+ depSchemas: {},
403
+ fqdnTransformation: {
404
+ paths: [],
405
+ transformation: _fromVeloEntity,
406
+ },
407
+ customTransformation: requestTransformation,
408
+ });
409
+ const { fromJSON } = (0, velo_1.serializer)({
410
+ rootSchema: _resetAllVariantDataResponse,
411
+ depSchemas: {},
412
+ fqdnTransformation: {
413
+ paths: [],
414
+ transformation: _toVeloEntity,
415
+ },
416
+ customTransformation: responseTransformation,
417
+ });
418
+ const payload = toAmbassadorRequest([_id]);
419
+ const reqOpts = ambassadorWixStoresCatalogV1Product.resetAllVariantData(payload);
420
+ __log(`"ResetAllVariantData" sending request with: ${__inspect(reqOpts)}`);
421
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
422
+ try {
423
+ const result = yield httpClient.request(reqOpts);
424
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
425
+ return fromJSON(result.data);
426
+ }
427
+ catch (err) {
428
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
429
+ '_id',
430
+ ]);
431
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
432
+ throw transformedError;
433
+ }
434
+ });
435
+ }
436
+ exports.resetAllVariantData = resetAllVariantData;
437
+ /**
438
+ * Adds products to a specified collection.
439
+ * @param _id - Collection ID. Cannot be used to add products to All Products
440
+ * @public
441
+ * @documentationMaturity preview
442
+ * @requiredField _id
443
+ */
444
+ function addProductsToCollection(_id, options) {
445
+ var _a, _b, _c;
446
+ return __awaiter(this, arguments, void 0, function* () {
447
+ const requestTransformation = { id: '$[0]', productIds: '$[1].productIds' };
448
+ const responseTransformation = '$';
449
+ // @ts-ignore
450
+ const { httpClient, sideEffects } = arguments[2];
451
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
452
+ rootSchema: _addProductsToCollectionRequest,
453
+ depSchemas: {},
454
+ fqdnTransformation: {
455
+ paths: [],
456
+ transformation: _fromVeloEntity,
457
+ },
458
+ customTransformation: requestTransformation,
459
+ });
460
+ const { fromJSON } = (0, velo_1.serializer)({
461
+ rootSchema: _addProductsToCollectionResponse,
462
+ depSchemas: {},
463
+ fqdnTransformation: {
464
+ paths: [],
465
+ transformation: _toVeloEntity,
466
+ },
467
+ customTransformation: responseTransformation,
468
+ });
469
+ const payload = toAmbassadorRequest([_id, options]);
470
+ const reqOpts = ambassadorWixStoresCatalogV1Product.addProductsToCollection(payload);
471
+ __log(`"AddProductsToCollection" sending request with: ${__inspect(reqOpts)}`);
472
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
473
+ try {
474
+ const result = yield httpClient.request(reqOpts);
475
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
476
+ return fromJSON(result.data);
477
+ }
478
+ catch (err) {
479
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
480
+ '_id',
481
+ 'options',
482
+ ]);
483
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
484
+ throw transformedError;
485
+ }
486
+ });
487
+ }
488
+ exports.addProductsToCollection = addProductsToCollection;
489
+ /**
490
+ * Deletes products from a specified collection.
491
+ * @param _id - Collection ID. Cannot be used to remove products from All Products
492
+ * @param productIds - IDs of the products that will be deleted from the collection.
493
+ * @public
494
+ * @documentationMaturity preview
495
+ * @requiredField _id
496
+ * @requiredField productIds
497
+ */
498
+ function removeProductsFromCollection(_id, productIds) {
499
+ var _a, _b, _c;
500
+ return __awaiter(this, arguments, void 0, function* () {
501
+ const requestTransformation = { id: '$[0]', productIds: '$[1]' };
502
+ const responseTransformation = '$';
503
+ // @ts-ignore
504
+ const { httpClient, sideEffects } = arguments[2];
505
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
506
+ rootSchema: _removeProductsFromCollectionRequest,
507
+ depSchemas: {},
508
+ fqdnTransformation: {
509
+ paths: [],
510
+ transformation: _fromVeloEntity,
511
+ },
512
+ customTransformation: requestTransformation,
513
+ });
514
+ const { fromJSON } = (0, velo_1.serializer)({
515
+ rootSchema: _removeProductsFromCollectionResponse,
516
+ depSchemas: {},
517
+ fqdnTransformation: {
518
+ paths: [],
519
+ transformation: _toVeloEntity,
520
+ },
521
+ customTransformation: responseTransformation,
522
+ });
523
+ const payload = toAmbassadorRequest([_id, productIds]);
524
+ const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductsFromCollection(payload);
525
+ __log(`"RemoveProductsFromCollection" sending request with: ${__inspect(reqOpts)}`);
526
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
527
+ try {
528
+ const result = yield httpClient.request(reqOpts);
529
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
530
+ return fromJSON(result.data);
531
+ }
532
+ catch (err) {
533
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
534
+ '_id',
535
+ 'productIds',
536
+ ]);
537
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
538
+ throw transformedError;
539
+ }
540
+ });
541
+ }
542
+ exports.removeProductsFromCollection = removeProductsFromCollection;
543
+ /**
544
+ * Adds media items to a specified product, either via URL or existing media ID.
545
+ * @param _id - Product ID.
546
+ * @public
547
+ * @documentationMaturity preview
548
+ * @requiredField _id
549
+ */
550
+ function addProductMedia(_id, options) {
551
+ var _a, _b, _c;
552
+ return __awaiter(this, arguments, void 0, function* () {
553
+ const requestTransformation = { id: '$[0]', media: '$[1].media' };
554
+ const responseTransformation = '$';
555
+ // @ts-ignore
556
+ const { httpClient, sideEffects } = arguments[2];
557
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
558
+ rootSchema: _addProductMediaRequest,
559
+ depSchemas: {},
560
+ fqdnTransformation: {
561
+ paths: [],
562
+ transformation: _fromVeloEntity,
563
+ },
564
+ customTransformation: requestTransformation,
565
+ });
566
+ const { fromJSON } = (0, velo_1.serializer)({
567
+ rootSchema: _addProductMediaResponse,
568
+ depSchemas: {},
569
+ fqdnTransformation: {
570
+ paths: [],
571
+ transformation: _toVeloEntity,
572
+ },
573
+ customTransformation: responseTransformation,
574
+ });
575
+ const payload = toAmbassadorRequest([_id, options]);
576
+ const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMedia(payload);
577
+ __log(`"AddProductMedia" sending request with: ${__inspect(reqOpts)}`);
578
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
579
+ try {
580
+ const result = yield httpClient.request(reqOpts);
581
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
582
+ return fromJSON(result.data);
583
+ }
584
+ catch (err) {
585
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
586
+ '_id',
587
+ 'options',
588
+ ]);
589
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
590
+ throw transformedError;
591
+ }
592
+ });
593
+ }
594
+ exports.addProductMedia = addProductMedia;
595
+ /**
596
+ * Removes specified media items from a product.
597
+ * Pass an empty array to remove all media items.
598
+ * @param _id - Product ID.
599
+ * @public
600
+ * @documentationMaturity preview
601
+ * @requiredField _id
602
+ */
603
+ function removeProductMedia(_id, options) {
604
+ var _a, _b, _c;
605
+ return __awaiter(this, arguments, void 0, function* () {
606
+ const requestTransformation = { id: '$[0]', mediaIds: '$[1].mediaIds' };
607
+ const responseTransformation = '$';
608
+ // @ts-ignore
609
+ const { httpClient, sideEffects } = arguments[2];
610
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
611
+ rootSchema: _removeProductMediaRequest,
612
+ depSchemas: {},
613
+ fqdnTransformation: {
614
+ paths: [],
615
+ transformation: _fromVeloEntity,
616
+ },
617
+ customTransformation: requestTransformation,
618
+ });
619
+ const { fromJSON } = (0, velo_1.serializer)({
620
+ rootSchema: _removeProductMediaResponse,
621
+ depSchemas: {},
622
+ fqdnTransformation: {
623
+ paths: [],
624
+ transformation: _toVeloEntity,
625
+ },
626
+ customTransformation: responseTransformation,
627
+ });
628
+ const payload = toAmbassadorRequest([_id, options]);
629
+ const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMedia(payload);
630
+ __log(`"RemoveProductMedia" sending request with: ${__inspect(reqOpts)}`);
631
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
632
+ try {
633
+ const result = yield httpClient.request(reqOpts);
634
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
635
+ return fromJSON(result.data);
636
+ }
637
+ catch (err) {
638
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
639
+ '_id',
640
+ 'options',
641
+ ]);
642
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
643
+ throw transformedError;
644
+ }
645
+ });
646
+ }
647
+ exports.removeProductMedia = removeProductMedia;
648
+ /**
649
+ * Links media items that are already associated with a specific product to a choice within the same product.
650
+ *
651
+ * 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).
652
+ *
653
+ * 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.
654
+ * @param _id - Product ID.
655
+ * @public
656
+ * @documentationMaturity preview
657
+ * @requiredField _id
658
+ * @requiredField options.media.choice
659
+ * @requiredField options.media.option
660
+ */
661
+ function addProductMediaToChoices(_id, options) {
662
+ var _a, _b, _c;
663
+ return __awaiter(this, arguments, void 0, function* () {
664
+ const requestTransformation = { id: '$[0]', media: '$[1].media' };
665
+ const responseTransformation = '$';
666
+ // @ts-ignore
667
+ const { httpClient, sideEffects } = arguments[2];
668
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
669
+ rootSchema: _addProductMediaToChoicesRequest,
670
+ depSchemas: {},
671
+ fqdnTransformation: {
672
+ paths: [],
673
+ transformation: _fromVeloEntity,
674
+ },
675
+ customTransformation: requestTransformation,
676
+ });
677
+ const { fromJSON } = (0, velo_1.serializer)({
678
+ rootSchema: _addProductMediaToChoicesResponse,
679
+ depSchemas: {},
680
+ fqdnTransformation: {
681
+ paths: [],
682
+ transformation: _toVeloEntity,
683
+ },
684
+ customTransformation: responseTransformation,
685
+ });
686
+ const payload = toAmbassadorRequest([_id, options]);
687
+ const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMediaToChoices(payload);
688
+ __log(`"AddProductMediaToChoices" sending request with: ${__inspect(reqOpts)}`);
689
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
690
+ try {
691
+ const result = yield httpClient.request(reqOpts);
692
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
693
+ return fromJSON(result.data);
694
+ }
695
+ catch (err) {
696
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
697
+ '_id',
698
+ 'options',
699
+ ]);
700
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
701
+ throw transformedError;
702
+ }
703
+ });
704
+ }
705
+ exports.addProductMediaToChoices = addProductMediaToChoices;
706
+ /**
707
+ * Removes media items from all or some of a product's choices.
708
+ * (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).)
709
+ * @param _id - Product ID.
710
+ * @public
711
+ * @documentationMaturity preview
712
+ * @requiredField _id
713
+ */
714
+ function removeProductMediaFromChoices(_id, options) {
715
+ var _a, _b, _c;
716
+ return __awaiter(this, arguments, void 0, function* () {
717
+ const requestTransformation = { id: '$[0]', media: '$[1].media' };
718
+ const responseTransformation = '$';
719
+ // @ts-ignore
720
+ const { httpClient, sideEffects } = arguments[2];
721
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
722
+ rootSchema: _removeProductMediaFromChoicesRequest,
723
+ depSchemas: {},
724
+ fqdnTransformation: {
725
+ paths: [],
726
+ transformation: _fromVeloEntity,
727
+ },
728
+ customTransformation: requestTransformation,
729
+ });
730
+ const { fromJSON } = (0, velo_1.serializer)({
731
+ rootSchema: _removeProductMediaFromChoicesResponse,
732
+ depSchemas: {},
733
+ fqdnTransformation: {
734
+ paths: [],
735
+ transformation: _toVeloEntity,
736
+ },
737
+ customTransformation: responseTransformation,
738
+ });
739
+ const payload = toAmbassadorRequest([_id, options]);
740
+ const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMediaFromChoices(payload);
741
+ __log(`"RemoveProductMediaFromChoices" sending request with: ${__inspect(reqOpts)}`);
742
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
743
+ try {
744
+ const result = yield httpClient.request(reqOpts);
745
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
746
+ return fromJSON(result.data);
747
+ }
748
+ catch (err) {
749
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
750
+ '_id',
751
+ 'options',
752
+ ]);
753
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
754
+ throw transformedError;
755
+ }
756
+ });
757
+ }
758
+ exports.removeProductMediaFromChoices = removeProductMediaFromChoices;
759
+ /**
760
+ * Delete all options from a specific product (only available when variant management is disabled).
761
+ * @param _id - Product ID.
762
+ * @public
763
+ * @documentationMaturity preview
764
+ * @requiredField _id
765
+ */
766
+ function deleteProductOptions(_id) {
767
+ var _a, _b, _c;
768
+ return __awaiter(this, arguments, void 0, function* () {
769
+ const requestTransformation = { id: '$[0]' };
770
+ const responseTransformation = '$';
771
+ // @ts-ignore
772
+ const { httpClient, sideEffects } = arguments[1];
773
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
774
+ rootSchema: _deleteProductOptionsRequest,
775
+ depSchemas: {},
776
+ fqdnTransformation: {
777
+ paths: [],
778
+ transformation: _fromVeloEntity,
779
+ },
780
+ customTransformation: requestTransformation,
781
+ });
782
+ const { fromJSON } = (0, velo_1.serializer)({
783
+ rootSchema: _deleteProductOptionsResponse,
784
+ depSchemas: {},
785
+ fqdnTransformation: {
786
+ paths: [],
787
+ transformation: _toVeloEntity,
788
+ },
789
+ customTransformation: responseTransformation,
790
+ });
791
+ const payload = toAmbassadorRequest([_id]);
792
+ const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProductOptions(payload);
793
+ __log(`"DeleteProductOptions" sending request with: ${__inspect(reqOpts)}`);
794
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
795
+ try {
796
+ const result = yield httpClient.request(reqOpts);
797
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
798
+ return fromJSON(result.data);
799
+ }
800
+ catch (err) {
801
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
802
+ '_id',
803
+ ]);
804
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
805
+ throw transformedError;
806
+ }
807
+ });
808
+ }
809
+ exports.deleteProductOptions = deleteProductOptions;
810
+ /**
811
+ * Deletes a product's brand.
812
+ * @param _id - Product ID.
813
+ * @public
814
+ * @documentationMaturity preview
815
+ * @requiredField _id
816
+ */
817
+ function removeBrand(_id) {
818
+ var _a, _b, _c;
819
+ return __awaiter(this, arguments, void 0, function* () {
820
+ const requestTransformation = { id: '$[0]' };
821
+ const responseTransformation = '$';
822
+ // @ts-ignore
823
+ const { httpClient, sideEffects } = arguments[1];
824
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
825
+ rootSchema: _removeProductBrandRequest,
826
+ depSchemas: {},
827
+ fqdnTransformation: {
828
+ paths: [],
829
+ transformation: _fromVeloEntity,
830
+ },
831
+ customTransformation: requestTransformation,
832
+ });
833
+ const { fromJSON } = (0, velo_1.serializer)({
834
+ rootSchema: _removeProductBrandResponse,
835
+ depSchemas: {},
836
+ fqdnTransformation: {
837
+ paths: [],
838
+ transformation: _toVeloEntity,
839
+ },
840
+ customTransformation: responseTransformation,
841
+ });
842
+ const payload = toAmbassadorRequest([_id]);
843
+ const reqOpts = ambassadorWixStoresCatalogV1Product.removeBrand(payload);
844
+ __log(`"RemoveBrand" sending request with: ${__inspect(reqOpts)}`);
845
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
846
+ try {
847
+ const result = yield httpClient.request(reqOpts);
848
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
849
+ return fromJSON(result.data);
850
+ }
851
+ catch (err) {
852
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
853
+ '_id',
854
+ ]);
855
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
856
+ throw transformedError;
857
+ }
858
+ });
859
+ }
860
+ exports.removeBrand = removeBrand;
861
+ /**
862
+ * Creates a new collection.
863
+ * @param collection - Collection info.
864
+ * @public
865
+ * @documentationMaturity preview
866
+ * @requiredField collection
867
+ * @requiredField collection.name
868
+ */
869
+ function createCollection(collection) {
870
+ var _a, _b, _c;
871
+ return __awaiter(this, arguments, void 0, function* () {
872
+ const requestTransformation = { collection: '$[0]' };
873
+ const responseTransformation = '$';
874
+ // @ts-ignore
875
+ const { httpClient, sideEffects } = arguments[1];
876
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
877
+ rootSchema: _createCollectionRequest,
878
+ depSchemas: {},
879
+ fqdnTransformation: {
880
+ paths: [],
881
+ transformation: _fromVeloEntity,
882
+ },
883
+ customTransformation: requestTransformation,
884
+ });
885
+ const { fromJSON } = (0, velo_1.serializer)({
886
+ rootSchema: _createCollectionResponse,
887
+ depSchemas: {},
888
+ fqdnTransformation: {
889
+ paths: [],
890
+ transformation: _toVeloEntity,
891
+ },
892
+ customTransformation: responseTransformation,
893
+ });
894
+ const payload = toAmbassadorRequest([collection]);
895
+ const reqOpts = ambassadorWixStoresCatalogV1Product.createCollection(payload);
896
+ __log(`"CreateCollection" sending request with: ${__inspect(reqOpts)}`);
897
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
898
+ try {
899
+ const result = yield httpClient.request(reqOpts);
900
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
901
+ return fromJSON(result.data);
902
+ }
903
+ catch (err) {
904
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
905
+ 'collection',
906
+ ]);
907
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
908
+ throw transformedError;
909
+ }
910
+ });
911
+ }
912
+ exports.createCollection = createCollection;
913
+ /**
914
+ * Updates specified properties of a collection.
915
+ * 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.
916
+ * @param _id - Collection ID (generated automatically by the catalog).
917
+ * @public
918
+ * @documentationMaturity preview
919
+ * @requiredField _id
920
+ * @requiredField collection
921
+ */
922
+ function updateCollection(_id, collection) {
923
+ var _a, _b, _c;
924
+ return __awaiter(this, arguments, void 0, function* () {
925
+ const requestTransformation = { collection: { '*': '$[1]', id: '$[0]' } };
926
+ const responseTransformation = '$';
927
+ // @ts-ignore
928
+ const { httpClient, sideEffects } = arguments[2];
929
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
930
+ rootSchema: _updateCollectionRequest,
931
+ depSchemas: {},
932
+ fqdnTransformation: {
933
+ paths: [],
934
+ transformation: _fromVeloEntity,
935
+ },
936
+ customTransformation: requestTransformation,
937
+ });
938
+ const { fromJSON } = (0, velo_1.serializer)({
939
+ rootSchema: _updateCollectionResponse,
940
+ depSchemas: {},
941
+ fqdnTransformation: {
942
+ paths: [],
943
+ transformation: _toVeloEntity,
944
+ },
945
+ customTransformation: responseTransformation,
946
+ });
947
+ const payload = toAmbassadorRequest([_id, collection]);
948
+ const reqOpts = ambassadorWixStoresCatalogV1Product.updateCollection(payload);
949
+ __log(`"UpdateCollection" sending request with: ${__inspect(reqOpts)}`);
950
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
951
+ try {
952
+ const result = yield httpClient.request(reqOpts);
953
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
954
+ return fromJSON(result.data);
955
+ }
956
+ catch (err) {
957
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
958
+ '_id',
959
+ 'collection',
960
+ ]);
961
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
962
+ throw transformedError;
963
+ }
964
+ });
965
+ }
966
+ exports.updateCollection = updateCollection;
967
+ /**
968
+ * Deletes a collection.
969
+ * @param _id - ID of the collection to delete. Cannot be used to delete All Products
970
+ * @public
971
+ * @documentationMaturity preview
972
+ * @requiredField _id
973
+ */
974
+ function deleteCollection(_id) {
975
+ var _a, _b, _c;
976
+ return __awaiter(this, arguments, void 0, function* () {
977
+ const requestTransformation = { id: '$[0]' };
978
+ const responseTransformation = '$';
979
+ // @ts-ignore
980
+ const { httpClient, sideEffects } = arguments[1];
981
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
982
+ rootSchema: _deleteCollectionRequest,
983
+ depSchemas: {},
984
+ fqdnTransformation: {
985
+ paths: [],
986
+ transformation: _fromVeloEntity,
987
+ },
988
+ customTransformation: requestTransformation,
989
+ });
990
+ const { fromJSON } = (0, velo_1.serializer)({
991
+ rootSchema: _deleteCollectionResponse,
992
+ depSchemas: {},
993
+ fqdnTransformation: {
994
+ paths: [],
995
+ transformation: _toVeloEntity,
996
+ },
997
+ customTransformation: responseTransformation,
998
+ });
999
+ const payload = toAmbassadorRequest([_id]);
1000
+ const reqOpts = ambassadorWixStoresCatalogV1Product.deleteCollection(payload);
1001
+ __log(`"DeleteCollection" sending request with: ${__inspect(reqOpts)}`);
1002
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1003
+ try {
1004
+ const result = yield httpClient.request(reqOpts);
1005
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1006
+ return fromJSON(result.data);
1007
+ }
1008
+ catch (err) {
1009
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1010
+ '_id',
1011
+ ]);
1012
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1013
+ throw transformedError;
1014
+ }
1015
+ });
1016
+ }
1017
+ exports.deleteCollection = deleteCollection;
1018
+ /**
1019
+ * Deletes a product's ribbon.
1020
+ * @param _id - Product ID.
1021
+ * @public
1022
+ * @documentationMaturity preview
1023
+ * @requiredField _id
1024
+ */
1025
+ function removeRibbon(_id) {
1026
+ var _a, _b, _c;
1027
+ return __awaiter(this, arguments, void 0, function* () {
1028
+ const requestTransformation = { id: '$[0]' };
1029
+ const responseTransformation = '$';
1030
+ // @ts-ignore
1031
+ const { httpClient, sideEffects } = arguments[1];
1032
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1033
+ rootSchema: _removeProductRibbonRequest,
1034
+ depSchemas: {},
1035
+ fqdnTransformation: {
1036
+ paths: [],
1037
+ transformation: _fromVeloEntity,
1038
+ },
1039
+ customTransformation: requestTransformation,
1040
+ });
1041
+ const { fromJSON } = (0, velo_1.serializer)({
1042
+ rootSchema: _removeProductRibbonResponse,
1043
+ depSchemas: {},
1044
+ fqdnTransformation: {
1045
+ paths: [],
1046
+ transformation: _toVeloEntity,
1047
+ },
1048
+ customTransformation: responseTransformation,
1049
+ });
1050
+ const payload = toAmbassadorRequest([_id]);
1051
+ const reqOpts = ambassadorWixStoresCatalogV1Product.removeRibbon(payload);
1052
+ __log(`"RemoveRibbon" sending request with: ${__inspect(reqOpts)}`);
1053
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1054
+ try {
1055
+ const result = yield httpClient.request(reqOpts);
1056
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1057
+ return fromJSON(result.data);
1058
+ }
1059
+ catch (err) {
1060
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1061
+ '_id',
1062
+ ]);
1063
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1064
+ throw transformedError;
1065
+ }
1066
+ });
1067
+ }
1068
+ exports.removeRibbon = removeRibbon;
1069
+ /**
1070
+ * Updates a specified property for up to 100 products at a time.
1071
+ * @param ids - Product IDs.
1072
+ * @public
1073
+ * @documentationMaturity preview
1074
+ * @requiredField ids
1075
+ */
1076
+ function bulkUpdateProducts(ids, options) {
1077
+ var _a, _b, _c;
1078
+ return __awaiter(this, arguments, void 0, function* () {
1079
+ const requestTransformation = { ids: '$[0]', set: '$[1].set' };
1080
+ const responseTransformation = '$';
1081
+ // @ts-ignore
1082
+ const { httpClient, sideEffects } = arguments[2];
1083
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1084
+ rootSchema: _bulkUpdateProductsRequest,
1085
+ depSchemas: {},
1086
+ fqdnTransformation: {
1087
+ paths: [],
1088
+ transformation: _fromVeloEntity,
1089
+ },
1090
+ customTransformation: requestTransformation,
1091
+ });
1092
+ const { fromJSON } = (0, velo_1.serializer)({
1093
+ rootSchema: _bulkUpdateProductsResponse,
1094
+ depSchemas: {},
1095
+ fqdnTransformation: {
1096
+ paths: [],
1097
+ transformation: _toVeloEntity,
1098
+ },
1099
+ customTransformation: responseTransformation,
1100
+ });
1101
+ const payload = toAmbassadorRequest([ids, options]);
1102
+ const reqOpts = ambassadorWixStoresCatalogV1Product.bulkUpdateProducts(payload);
1103
+ __log(`"BulkUpdateProducts" sending request with: ${__inspect(reqOpts)}`);
1104
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1105
+ try {
1106
+ const result = yield httpClient.request(reqOpts);
1107
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1108
+ return fromJSON(result.data);
1109
+ }
1110
+ catch (err) {
1111
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1112
+ 'ids',
1113
+ 'options',
1114
+ ]);
1115
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1116
+ throw transformedError;
1117
+ }
1118
+ });
1119
+ }
1120
+ exports.bulkUpdateProducts = bulkUpdateProducts;
1121
+ /**
1122
+ * Adjusts a specified numerical property for up to 100 products at a time.
1123
+ * The property can be increased or decreased either by percentage or amount.
1124
+ * @param ids - Product IDs.
1125
+ * @public
1126
+ * @documentationMaturity preview
1127
+ * @requiredField ids
1128
+ */
1129
+ function bulkAdjustProductProperties(ids, options) {
1130
+ var _a, _b, _c;
1131
+ return __awaiter(this, arguments, void 0, function* () {
1132
+ const requestTransformation = { ids: '$[0]', adjust: '$[1].adjust' };
1133
+ const responseTransformation = '$';
1134
+ // @ts-ignore
1135
+ const { httpClient, sideEffects } = arguments[2];
1136
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1137
+ rootSchema: _bulkAdjustProductPropertiesRequest,
1138
+ depSchemas: {},
1139
+ fqdnTransformation: {
1140
+ paths: [],
1141
+ transformation: _fromVeloEntity,
1142
+ },
1143
+ customTransformation: requestTransformation,
1144
+ });
1145
+ const { fromJSON } = (0, velo_1.serializer)({
1146
+ rootSchema: _bulkAdjustProductPropertiesResponse,
1147
+ depSchemas: {},
1148
+ fqdnTransformation: {
1149
+ paths: [],
1150
+ transformation: _toVeloEntity,
1151
+ },
1152
+ customTransformation: responseTransformation,
1153
+ });
1154
+ const payload = toAmbassadorRequest([ids, options]);
1155
+ const reqOpts = ambassadorWixStoresCatalogV1Product.bulkAdjustProductProperties(payload);
1156
+ __log(`"BulkAdjustProductProperties" sending request with: ${__inspect(reqOpts)}`);
1157
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1158
+ try {
1159
+ const result = yield httpClient.request(reqOpts);
1160
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1161
+ return fromJSON(result.data);
1162
+ }
1163
+ catch (err) {
1164
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1165
+ 'ids',
1166
+ 'options',
1167
+ ]);
1168
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1169
+ throw transformedError;
1170
+ }
1171
+ });
1172
+ }
1173
+ exports.bulkAdjustProductProperties = bulkAdjustProductProperties;
1174
+ /**
1175
+ * Returns a list of up to 100 products, given the provided paging, sorting and filtering.
1176
+ * @public
1177
+ * @documentationMaturity preview
1178
+ */
1179
+ function queryProducts() {
1180
+ const requestTransformation = { '*': '$[1]', query: '$[0]' };
1181
+ const responseTransformation = {
1182
+ items: '$.products',
1183
+ pagingMetadata: '$.metadata',
1184
+ };
1185
+ // @ts-ignore
1186
+ const { httpClient, sideEffects } = arguments[0];
1187
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1188
+ rootSchema: _queryProductsPlatformizedRequest,
1189
+ depSchemas: {},
1190
+ fqdnTransformation: {
1191
+ paths: [],
1192
+ transformation: _fromVeloEntity,
1193
+ },
1194
+ customTransformation: requestTransformation,
1195
+ });
1196
+ const { fromJSON } = (0, velo_1.serializer)({
1197
+ rootSchema: _queryProductsPlatformizedResponse,
1198
+ depSchemas: {},
1199
+ fqdnTransformation: {
1200
+ paths: [...['Array#products']],
1201
+ transformation: _toVeloEntity,
1202
+ },
1203
+ customTransformation: responseTransformation,
1204
+ });
1205
+ return (0, motion_edm_autogen_query_wrapper_1.wrapWithQueryBuilder)({
1206
+ func: (payload) => __awaiter(this, void 0, void 0, function* () {
1207
+ var _a, _b, _c;
1208
+ const reqOpts = ambassadorWixStoresCatalogV1Product.queryProductsPlatformized(payload);
1209
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1210
+ try {
1211
+ const result = yield httpClient.request(reqOpts);
1212
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1213
+ return result;
1214
+ }
1215
+ catch (err) {
1216
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1217
+ throw err;
1218
+ }
1219
+ }),
1220
+ requestTransformer: (...args) => toAmbassadorRequest(args),
1221
+ responseTransformer: ({ data }) => fromJSON(data),
1222
+ errorTransformer: (err) => {
1223
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation);
1224
+ throw transformedError;
1225
+ },
1226
+ pagingMethod: 'OFFSET',
1227
+ transformationPaths: (0, velo_1.resolveQueryFieldsTransformationPaths)(_toVeloEntity),
1228
+ })({ cursorWithEmptyFilterAndSort: true });
1229
+ }
1230
+ exports.queryProducts = queryProducts;
1231
+ /**
1232
+ * Retrieves a product with the provided ID.
1233
+ * @param _id - Requested product ID.
1234
+ * @public
1235
+ * @documentationMaturity preview
1236
+ * @requiredField _id
1237
+ */
1238
+ function getProduct(_id, options) {
1239
+ var _a, _b, _c;
1240
+ return __awaiter(this, arguments, void 0, function* () {
1241
+ const requestTransformation = {
1242
+ id: '$[0]',
1243
+ includeMerchantSpecificData: '$[1].includeMerchantSpecificData',
1244
+ };
1245
+ const responseTransformation = '$';
1246
+ // @ts-ignore
1247
+ const { httpClient, sideEffects } = arguments[2];
1248
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1249
+ rootSchema: _getProductRequest,
1250
+ depSchemas: {},
1251
+ fqdnTransformation: {
1252
+ paths: [],
1253
+ transformation: _fromVeloEntity,
1254
+ },
1255
+ customTransformation: requestTransformation,
1256
+ });
1257
+ const { fromJSON } = (0, velo_1.serializer)({
1258
+ rootSchema: _getProductResponse,
1259
+ depSchemas: {},
1260
+ fqdnTransformation: {
1261
+ paths: [...['product']],
1262
+ transformation: _toVeloEntity,
1263
+ },
1264
+ customTransformation: responseTransformation,
1265
+ });
1266
+ const payload = toAmbassadorRequest([_id, options]);
1267
+ const reqOpts = ambassadorWixStoresCatalogV1Product.getProduct(payload);
1268
+ __log(`"GetProduct" sending request with: ${__inspect(reqOpts)}`);
1269
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1270
+ try {
1271
+ const result = yield httpClient.request(reqOpts);
1272
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1273
+ return fromJSON(result.data);
1274
+ }
1275
+ catch (err) {
1276
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1277
+ '_id',
1278
+ 'options',
1279
+ ]);
1280
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1281
+ throw transformedError;
1282
+ }
1283
+ });
1284
+ }
1285
+ exports.getProduct = getProduct;
1286
+ /**
1287
+ * Retrieves a list of up to 100 collections, given the provided paging, sorting and filtering.
1288
+ * See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information.
1289
+ * @public
1290
+ * @documentationMaturity preview
1291
+ */
1292
+ function queryCollections(options) {
1293
+ var _a, _b, _c;
1294
+ return __awaiter(this, arguments, void 0, function* () {
1295
+ const requestTransformation = {
1296
+ query: '$[0].query',
1297
+ includeNumberOfProducts: '$[0].includeNumberOfProducts',
1298
+ includeDescription: '$[0].includeDescription',
1299
+ };
1300
+ const responseTransformation = '$';
1301
+ // @ts-ignore
1302
+ const { httpClient, sideEffects } = arguments[1];
1303
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1304
+ rootSchema: _queryCollectionsRequest,
1305
+ depSchemas: {},
1306
+ fqdnTransformation: {
1307
+ paths: [],
1308
+ transformation: _fromVeloEntity,
1309
+ },
1310
+ customTransformation: requestTransformation,
1311
+ });
1312
+ const { fromJSON } = (0, velo_1.serializer)({
1313
+ rootSchema: _queryCollectionsResponse,
1314
+ depSchemas: {},
1315
+ fqdnTransformation: {
1316
+ paths: [],
1317
+ transformation: _toVeloEntity,
1318
+ },
1319
+ customTransformation: responseTransformation,
1320
+ });
1321
+ const payload = toAmbassadorRequest([options]);
1322
+ const reqOpts = ambassadorWixStoresCatalogV1Product.queryCollections(payload);
1323
+ __log(`"QueryCollections" sending request with: ${__inspect(reqOpts)}`);
1324
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1325
+ try {
1326
+ const result = yield httpClient.request(reqOpts);
1327
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1328
+ return fromJSON(result.data);
1329
+ }
1330
+ catch (err) {
1331
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1332
+ 'options',
1333
+ ]);
1334
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1335
+ throw transformedError;
1336
+ }
1337
+ });
1338
+ }
1339
+ exports.queryCollections = queryCollections;
1340
+ /**
1341
+ * Retrieves a collection with the provided ID.
1342
+ * @param _id - Requested collection ID.
1343
+ * @public
1344
+ * @documentationMaturity preview
1345
+ * @requiredField _id
1346
+ */
1347
+ function getCollection(_id, options) {
1348
+ var _a, _b, _c;
1349
+ return __awaiter(this, arguments, void 0, function* () {
1350
+ const requestTransformation = {
1351
+ id: '$[0]',
1352
+ includeNumberOfProducts: '$[1].includeNumberOfProducts',
1353
+ };
1354
+ const responseTransformation = '$';
1355
+ // @ts-ignore
1356
+ const { httpClient, sideEffects } = arguments[2];
1357
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1358
+ rootSchema: _getCollectionRequest,
1359
+ depSchemas: {},
1360
+ fqdnTransformation: {
1361
+ paths: [],
1362
+ transformation: _fromVeloEntity,
1363
+ },
1364
+ customTransformation: requestTransformation,
1365
+ });
1366
+ const { fromJSON } = (0, velo_1.serializer)({
1367
+ rootSchema: _getCollectionResponse,
1368
+ depSchemas: {},
1369
+ fqdnTransformation: {
1370
+ paths: [],
1371
+ transformation: _toVeloEntity,
1372
+ },
1373
+ customTransformation: responseTransformation,
1374
+ });
1375
+ const payload = toAmbassadorRequest([_id, options]);
1376
+ const reqOpts = ambassadorWixStoresCatalogV1Product.getCollection(payload);
1377
+ __log(`"GetCollection" sending request with: ${__inspect(reqOpts)}`);
1378
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1379
+ try {
1380
+ const result = yield httpClient.request(reqOpts);
1381
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1382
+ return fromJSON(result.data);
1383
+ }
1384
+ catch (err) {
1385
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1386
+ '_id',
1387
+ 'options',
1388
+ ]);
1389
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1390
+ throw transformedError;
1391
+ }
1392
+ });
1393
+ }
1394
+ exports.getCollection = getCollection;
1395
+ /**
1396
+ * Retrieves a collection with the provided slug.
1397
+ * @param slug - Slug of the collection to retrieve.
1398
+ * @public
1399
+ * @documentationMaturity preview
1400
+ * @requiredField slug
1401
+ */
1402
+ function getCollectionBySlug(slug) {
1403
+ var _a, _b, _c;
1404
+ return __awaiter(this, arguments, void 0, function* () {
1405
+ const requestTransformation = { slug: '$[0]' };
1406
+ const responseTransformation = '$';
1407
+ // @ts-ignore
1408
+ const { httpClient, sideEffects } = arguments[1];
1409
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1410
+ rootSchema: _getCollectionBySlugRequest,
1411
+ depSchemas: {},
1412
+ fqdnTransformation: {
1413
+ paths: [],
1414
+ transformation: _fromVeloEntity,
1415
+ },
1416
+ customTransformation: requestTransformation,
1417
+ });
1418
+ const { fromJSON } = (0, velo_1.serializer)({
1419
+ rootSchema: _getCollectionBySlugResponse,
1420
+ depSchemas: {},
1421
+ fqdnTransformation: {
1422
+ paths: [],
1423
+ transformation: _toVeloEntity,
1424
+ },
1425
+ customTransformation: responseTransformation,
1426
+ });
1427
+ const payload = toAmbassadorRequest([slug]);
1428
+ const reqOpts = ambassadorWixStoresCatalogV1Product.getCollectionBySlug(payload);
1429
+ __log(`"GetCollectionBySlug" sending request with: ${__inspect(reqOpts)}`);
1430
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1431
+ try {
1432
+ const result = yield httpClient.request(reqOpts);
1433
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1434
+ return fromJSON(result.data);
1435
+ }
1436
+ catch (err) {
1437
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1438
+ 'slug',
1439
+ ]);
1440
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1441
+ throw transformedError;
1442
+ }
1443
+ });
1444
+ }
1445
+ exports.getCollectionBySlug = getCollectionBySlug;
1446
+ /**
1447
+ * Gets the availability of relevant product variants based on the product ID and selections provided. See [Use Cases](https://dev.wix.com/api/rest/wix-stores/catalog/use-cases) for an example.
1448
+ * @param _id - Requested product ID.
1449
+ * @public
1450
+ * @documentationMaturity preview
1451
+ * @requiredField _id
1452
+ */
1453
+ function getProductOptionsAvailability(_id, options) {
1454
+ var _a, _b, _c;
1455
+ return __awaiter(this, arguments, void 0, function* () {
1456
+ const requestTransformation = { id: '$[0]', options: '$[1].options' };
1457
+ const responseTransformation = '$';
1458
+ // @ts-ignore
1459
+ const { httpClient, sideEffects } = arguments[2];
1460
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1461
+ rootSchema: _productOptionsAvailabilityRequest,
1462
+ depSchemas: {},
1463
+ fqdnTransformation: {
1464
+ paths: [],
1465
+ transformation: _fromVeloEntity,
1466
+ },
1467
+ customTransformation: requestTransformation,
1468
+ });
1469
+ const { fromJSON } = (0, velo_1.serializer)({
1470
+ rootSchema: _productOptionsAvailabilityResponse,
1471
+ depSchemas: {},
1472
+ fqdnTransformation: {
1473
+ paths: [],
1474
+ transformation: _toVeloEntity,
1475
+ },
1476
+ customTransformation: responseTransformation,
1477
+ });
1478
+ const payload = toAmbassadorRequest([_id, options]);
1479
+ const reqOpts = ambassadorWixStoresCatalogV1Product.productOptionsAvailability(payload);
1480
+ __log(`"ProductOptionsAvailability" sending request with: ${__inspect(reqOpts)}`);
1481
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1482
+ try {
1483
+ const result = yield httpClient.request(reqOpts);
1484
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1485
+ return fromJSON(result.data);
1486
+ }
1487
+ catch (err) {
1488
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1489
+ '_id',
1490
+ 'options',
1491
+ ]);
1492
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1493
+ throw transformedError;
1494
+ }
1495
+ });
1496
+ }
1497
+ exports.getProductOptionsAvailability = getProductOptionsAvailability;
1498
+ /**
1499
+ * Retrieves product variants, based on either choices (option-choice key-value pairs) or variant IDs.
1500
+ * See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information.
1501
+ * @param _id - Requested product ID.
1502
+ * @public
1503
+ * @documentationMaturity preview
1504
+ * @requiredField _id
1505
+ */
1506
+ function queryProductVariants(_id, options) {
1507
+ var _a, _b, _c;
1508
+ return __awaiter(this, arguments, void 0, function* () {
1509
+ const requestTransformation = {
1510
+ id: '$[0]',
1511
+ choices: '$[1].choices',
1512
+ variantIds: '$[1].variantIds',
1513
+ paging: '$[1].paging',
1514
+ includeMerchantSpecificData: '$[1].includeMerchantSpecificData',
1515
+ };
1516
+ const responseTransformation = '$';
1517
+ // @ts-ignore
1518
+ const { httpClient, sideEffects } = arguments[2];
1519
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1520
+ rootSchema: _queryProductVariantsRequest,
1521
+ depSchemas: {},
1522
+ fqdnTransformation: {
1523
+ paths: [],
1524
+ transformation: _fromVeloEntity,
1525
+ },
1526
+ customTransformation: requestTransformation,
1527
+ });
1528
+ const { fromJSON } = (0, velo_1.serializer)({
1529
+ rootSchema: _queryProductVariantsResponse,
1530
+ depSchemas: {},
1531
+ fqdnTransformation: {
1532
+ paths: [],
1533
+ transformation: _toVeloEntity,
1534
+ },
1535
+ customTransformation: responseTransformation,
1536
+ });
1537
+ const payload = toAmbassadorRequest([_id, options]);
1538
+ const reqOpts = ambassadorWixStoresCatalogV1Product.queryProductVariants(payload);
1539
+ __log(`"QueryProductVariants" sending request with: ${__inspect(reqOpts)}`);
1540
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1541
+ try {
1542
+ const result = yield httpClient.request(reqOpts);
1543
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1544
+ return fromJSON(result.data);
1545
+ }
1546
+ catch (err) {
1547
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1548
+ '_id',
1549
+ 'options',
1550
+ ]);
1551
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1552
+ throw transformedError;
1553
+ }
1554
+ });
1555
+ }
1556
+ exports.queryProductVariants = queryProductVariants;
1557
+ /**
1558
+ * Retrieves up to 100 store variants, given the provided paging, filtering, and sorting.
1559
+ * @public
1560
+ * @documentationMaturity preview
1561
+ */
1562
+ function queryStoreVariants(options) {
1563
+ var _a, _b, _c;
1564
+ return __awaiter(this, arguments, void 0, function* () {
1565
+ const requestTransformation = { query: '$[0].query' };
1566
+ const responseTransformation = '$';
1567
+ // @ts-ignore
1568
+ const { httpClient, sideEffects } = arguments[1];
1569
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1570
+ rootSchema: _queryStoreVariantsRequest,
1571
+ depSchemas: {},
1572
+ fqdnTransformation: {
1573
+ paths: [],
1574
+ transformation: _fromVeloEntity,
1575
+ },
1576
+ customTransformation: requestTransformation,
1577
+ });
1578
+ const { fromJSON } = (0, velo_1.serializer)({
1579
+ rootSchema: _queryStoreVariantsResponse,
1580
+ depSchemas: { _platformMedia, _storeVariant },
1581
+ fqdnTransformation: {
1582
+ paths: [],
1583
+ transformation: _toVeloEntity,
1584
+ },
1585
+ customTransformation: responseTransformation,
1586
+ });
1587
+ const payload = toAmbassadorRequest([options]);
1588
+ const reqOpts = ambassadorWixStoresCatalogV1Product.queryStoreVariants(payload);
1589
+ __log(`"QueryStoreVariants" sending request with: ${__inspect(reqOpts)}`);
1590
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1591
+ try {
1592
+ const result = yield httpClient.request(reqOpts);
1593
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1594
+ return fromJSON(result.data);
1595
+ }
1596
+ catch (err) {
1597
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1598
+ 'options',
1599
+ ]);
1600
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1601
+ throw transformedError;
1602
+ }
1603
+ });
1604
+ }
1605
+ exports.queryStoreVariants = queryStoreVariants;
1606
+ /**
1607
+ * Retrieves a store variant with the provided ID.
1608
+ * @param _id - Store variant ID. Comprised of the `productId` and the `variantId`, separated by a hyphen. For example, `{productId}-{variantId}`.
1609
+ * @public
1610
+ * @documentationMaturity preview
1611
+ * @requiredField _id
1612
+ */
1613
+ function getStoreVariant(_id) {
1614
+ var _a, _b, _c;
1615
+ return __awaiter(this, arguments, void 0, function* () {
1616
+ const requestTransformation = { id: '$[0]' };
1617
+ const responseTransformation = '$';
1618
+ // @ts-ignore
1619
+ const { httpClient, sideEffects } = arguments[1];
1620
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
1621
+ rootSchema: _getStoreVariantRequest,
1622
+ depSchemas: {},
1623
+ fqdnTransformation: {
1624
+ paths: [],
1625
+ transformation: _fromVeloEntity,
1626
+ },
1627
+ customTransformation: requestTransformation,
1628
+ });
1629
+ const { fromJSON } = (0, velo_1.serializer)({
1630
+ rootSchema: _getStoreVariantResponse,
1631
+ depSchemas: { _platformMedia, _storeVariant },
1632
+ fqdnTransformation: {
1633
+ paths: [],
1634
+ transformation: _toVeloEntity,
1635
+ },
1636
+ customTransformation: responseTransformation,
1637
+ });
1638
+ const payload = toAmbassadorRequest([_id]);
1639
+ const reqOpts = ambassadorWixStoresCatalogV1Product.getStoreVariant(payload);
1640
+ __log(`"GetStoreVariant" sending request with: ${__inspect(reqOpts)}`);
1641
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1642
+ try {
1643
+ const result = yield httpClient.request(reqOpts);
1644
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1645
+ return fromJSON(result.data);
1646
+ }
1647
+ catch (err) {
1648
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
1649
+ '_id',
1650
+ ]);
1651
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1652
+ throw transformedError;
1653
+ }
1654
+ });
1655
+ }
1656
+ exports.getStoreVariant = getStoreVariant;
1657
+ //# sourceMappingURL=stores-catalog-v1-product.universal.js.map