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