@wix/categories 1.0.0

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 (31) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +24 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/src/categories-v1-category.http.d.ts +54 -0
  5. package/build/cjs/src/categories-v1-category.http.js +790 -0
  6. package/build/cjs/src/categories-v1-category.http.js.map +1 -0
  7. package/build/cjs/src/categories-v1-category.public.d.ts +24 -0
  8. package/build/cjs/src/categories-v1-category.public.js +141 -0
  9. package/build/cjs/src/categories-v1-category.public.js.map +1 -0
  10. package/build/cjs/src/categories-v1-category.types.d.ts +1969 -0
  11. package/build/cjs/src/categories-v1-category.types.js +316 -0
  12. package/build/cjs/src/categories-v1-category.types.js.map +1 -0
  13. package/build/cjs/src/categories-v1-category.universal.d.ts +2429 -0
  14. package/build/cjs/src/categories-v1-category.universal.js +1457 -0
  15. package/build/cjs/src/categories-v1-category.universal.js.map +1 -0
  16. package/build/es/index.d.ts +1 -0
  17. package/build/es/index.js +2 -0
  18. package/build/es/index.js.map +1 -0
  19. package/build/es/src/categories-v1-category.http.d.ts +54 -0
  20. package/build/es/src/categories-v1-category.http.js +770 -0
  21. package/build/es/src/categories-v1-category.http.js.map +1 -0
  22. package/build/es/src/categories-v1-category.public.d.ts +24 -0
  23. package/build/es/src/categories-v1-category.public.js +89 -0
  24. package/build/es/src/categories-v1-category.public.js.map +1 -0
  25. package/build/es/src/categories-v1-category.types.d.ts +1969 -0
  26. package/build/es/src/categories-v1-category.types.js +313 -0
  27. package/build/es/src/categories-v1-category.types.js.map +1 -0
  28. package/build/es/src/categories-v1-category.universal.d.ts +2429 -0
  29. package/build/es/src/categories-v1-category.universal.js +1418 -0
  30. package/build/es/src/categories-v1-category.universal.js.map +1 -0
  31. package/package.json +37 -0
@@ -0,0 +1,1418 @@
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 ambassadorWixCategoriesV1Category from './categories-v1-category.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 NodeType;
30
+ (function (NodeType) {
31
+ NodeType["PARAGRAPH"] = "PARAGRAPH";
32
+ NodeType["TEXT"] = "TEXT";
33
+ NodeType["HEADING"] = "HEADING";
34
+ NodeType["BULLETED_LIST"] = "BULLETED_LIST";
35
+ NodeType["ORDERED_LIST"] = "ORDERED_LIST";
36
+ NodeType["LIST_ITEM"] = "LIST_ITEM";
37
+ NodeType["BLOCKQUOTE"] = "BLOCKQUOTE";
38
+ NodeType["CODE_BLOCK"] = "CODE_BLOCK";
39
+ NodeType["VIDEO"] = "VIDEO";
40
+ NodeType["DIVIDER"] = "DIVIDER";
41
+ NodeType["FILE"] = "FILE";
42
+ NodeType["GALLERY"] = "GALLERY";
43
+ NodeType["GIF"] = "GIF";
44
+ NodeType["HTML"] = "HTML";
45
+ NodeType["IMAGE"] = "IMAGE";
46
+ NodeType["LINK_PREVIEW"] = "LINK_PREVIEW";
47
+ NodeType["MAP"] = "MAP";
48
+ NodeType["POLL"] = "POLL";
49
+ NodeType["APP_EMBED"] = "APP_EMBED";
50
+ NodeType["BUTTON"] = "BUTTON";
51
+ NodeType["COLLAPSIBLE_LIST"] = "COLLAPSIBLE_LIST";
52
+ NodeType["TABLE"] = "TABLE";
53
+ NodeType["EMBED"] = "EMBED";
54
+ NodeType["COLLAPSIBLE_ITEM"] = "COLLAPSIBLE_ITEM";
55
+ NodeType["COLLAPSIBLE_ITEM_TITLE"] = "COLLAPSIBLE_ITEM_TITLE";
56
+ NodeType["COLLAPSIBLE_ITEM_BODY"] = "COLLAPSIBLE_ITEM_BODY";
57
+ NodeType["TABLE_CELL"] = "TABLE_CELL";
58
+ NodeType["TABLE_ROW"] = "TABLE_ROW";
59
+ NodeType["EXTERNAL"] = "EXTERNAL";
60
+ NodeType["AUDIO"] = "AUDIO";
61
+ })(NodeType || (NodeType = {}));
62
+ export var WidthType;
63
+ (function (WidthType) {
64
+ /** Width matches the content width */
65
+ WidthType["CONTENT"] = "CONTENT";
66
+ /** Small Width */
67
+ WidthType["SMALL"] = "SMALL";
68
+ /** Width will match the original asset width */
69
+ WidthType["ORIGINAL"] = "ORIGINAL";
70
+ /** coast-to-coast display */
71
+ WidthType["FULL_WIDTH"] = "FULL_WIDTH";
72
+ })(WidthType || (WidthType = {}));
73
+ export var PluginContainerDataAlignment;
74
+ (function (PluginContainerDataAlignment) {
75
+ /** Center Alignment */
76
+ PluginContainerDataAlignment["CENTER"] = "CENTER";
77
+ /** Left Alignment */
78
+ PluginContainerDataAlignment["LEFT"] = "LEFT";
79
+ /** Right Alignment */
80
+ PluginContainerDataAlignment["RIGHT"] = "RIGHT";
81
+ })(PluginContainerDataAlignment || (PluginContainerDataAlignment = {}));
82
+ export var Type;
83
+ (function (Type) {
84
+ /** Regular link button */
85
+ Type["LINK"] = "LINK";
86
+ /** Triggers custom action that is defined in plugin configuration by the consumer */
87
+ Type["ACTION"] = "ACTION";
88
+ })(Type || (Type = {}));
89
+ export var Target;
90
+ (function (Target) {
91
+ /** Opens the linked document in the same frame as it was clicked (this is default) */
92
+ Target["SELF"] = "SELF";
93
+ /** Opens the linked document in a new window or tab */
94
+ Target["BLANK"] = "BLANK";
95
+ /** Opens the linked document in the parent frame */
96
+ Target["PARENT"] = "PARENT";
97
+ /** Opens the linked document in the full body of the window */
98
+ Target["TOP"] = "TOP";
99
+ })(Target || (Target = {}));
100
+ export var TextAlignment;
101
+ (function (TextAlignment) {
102
+ /** browser default, eqivalent to `initial` */
103
+ TextAlignment["AUTO"] = "AUTO";
104
+ /** Left align */
105
+ TextAlignment["LEFT"] = "LEFT";
106
+ /** Right align */
107
+ TextAlignment["RIGHT"] = "RIGHT";
108
+ /** Center align */
109
+ TextAlignment["CENTER"] = "CENTER";
110
+ /** Text is spaced to line up its left and right edges to the left and right edges of the line box, except for the last line */
111
+ TextAlignment["JUSTIFY"] = "JUSTIFY";
112
+ })(TextAlignment || (TextAlignment = {}));
113
+ export var LineStyle;
114
+ (function (LineStyle) {
115
+ /** Single Line */
116
+ LineStyle["SINGLE"] = "SINGLE";
117
+ /** Double Line */
118
+ LineStyle["DOUBLE"] = "DOUBLE";
119
+ /** Dashed Line */
120
+ LineStyle["DASHED"] = "DASHED";
121
+ /** Dotted Line */
122
+ LineStyle["DOTTED"] = "DOTTED";
123
+ })(LineStyle || (LineStyle = {}));
124
+ export var Width;
125
+ (function (Width) {
126
+ /** Large line */
127
+ Width["LARGE"] = "LARGE";
128
+ /** Medium line */
129
+ Width["MEDIUM"] = "MEDIUM";
130
+ /** Small line */
131
+ Width["SMALL"] = "SMALL";
132
+ })(Width || (Width = {}));
133
+ export var Alignment;
134
+ (function (Alignment) {
135
+ /** Center alignment */
136
+ Alignment["CENTER"] = "CENTER";
137
+ /** Left alignment */
138
+ Alignment["LEFT"] = "LEFT";
139
+ /** Right alignment */
140
+ Alignment["RIGHT"] = "RIGHT";
141
+ })(Alignment || (Alignment = {}));
142
+ export var ViewMode;
143
+ (function (ViewMode) {
144
+ /** No PDF view */
145
+ ViewMode["NONE"] = "NONE";
146
+ /** Full PDF view */
147
+ ViewMode["FULL"] = "FULL";
148
+ /** Mini PDF view */
149
+ ViewMode["MINI"] = "MINI";
150
+ })(ViewMode || (ViewMode = {}));
151
+ export var LayoutType;
152
+ (function (LayoutType) {
153
+ /** Collage type */
154
+ LayoutType["COLLAGE"] = "COLLAGE";
155
+ /** Masonry type */
156
+ LayoutType["MASONRY"] = "MASONRY";
157
+ /** Grid type */
158
+ LayoutType["GRID"] = "GRID";
159
+ /** Thumbnail type */
160
+ LayoutType["THUMBNAIL"] = "THUMBNAIL";
161
+ /** Slider type */
162
+ LayoutType["SLIDER"] = "SLIDER";
163
+ /** Slideshow type */
164
+ LayoutType["SLIDESHOW"] = "SLIDESHOW";
165
+ /** Panorama type */
166
+ LayoutType["PANORAMA"] = "PANORAMA";
167
+ /** Column type */
168
+ LayoutType["COLUMN"] = "COLUMN";
169
+ /** Magic type */
170
+ LayoutType["MAGIC"] = "MAGIC";
171
+ /** Fullsize images type */
172
+ LayoutType["FULLSIZE"] = "FULLSIZE";
173
+ })(LayoutType || (LayoutType = {}));
174
+ export var Orientation;
175
+ (function (Orientation) {
176
+ /** Rows Orientation */
177
+ Orientation["ROWS"] = "ROWS";
178
+ /** Columns Orientation */
179
+ Orientation["COLUMNS"] = "COLUMNS";
180
+ })(Orientation || (Orientation = {}));
181
+ export var Crop;
182
+ (function (Crop) {
183
+ /** Crop to fill */
184
+ Crop["FILL"] = "FILL";
185
+ /** Crop to fit */
186
+ Crop["FIT"] = "FIT";
187
+ })(Crop || (Crop = {}));
188
+ export var ThumbnailsAlignment;
189
+ (function (ThumbnailsAlignment) {
190
+ /** Top alignment */
191
+ ThumbnailsAlignment["TOP"] = "TOP";
192
+ /** Right alignment */
193
+ ThumbnailsAlignment["RIGHT"] = "RIGHT";
194
+ /** Bottom alignment */
195
+ ThumbnailsAlignment["BOTTOM"] = "BOTTOM";
196
+ /** Left alignment */
197
+ ThumbnailsAlignment["LEFT"] = "LEFT";
198
+ /** No thumbnail */
199
+ ThumbnailsAlignment["NONE"] = "NONE";
200
+ })(ThumbnailsAlignment || (ThumbnailsAlignment = {}));
201
+ export var Source;
202
+ (function (Source) {
203
+ Source["HTML"] = "HTML";
204
+ Source["ADSENSE"] = "ADSENSE";
205
+ })(Source || (Source = {}));
206
+ export var MapType;
207
+ (function (MapType) {
208
+ /** Roadmap map type */
209
+ MapType["ROADMAP"] = "ROADMAP";
210
+ /** Satellite map type */
211
+ MapType["SATELITE"] = "SATELITE";
212
+ /** Hybrid map type */
213
+ MapType["HYBRID"] = "HYBRID";
214
+ /** Terrain map type */
215
+ MapType["TERRAIN"] = "TERRAIN";
216
+ })(MapType || (MapType = {}));
217
+ export var ViewRole;
218
+ (function (ViewRole) {
219
+ /** Only Poll creator can view the results */
220
+ ViewRole["CREATOR"] = "CREATOR";
221
+ /** Anyone who voted can see the results */
222
+ ViewRole["VOTERS"] = "VOTERS";
223
+ /** Anyone can see the results, even if one didn't vote */
224
+ ViewRole["EVERYONE"] = "EVERYONE";
225
+ })(ViewRole || (ViewRole = {}));
226
+ export var VoteRole;
227
+ (function (VoteRole) {
228
+ /** Logged in member */
229
+ VoteRole["SITE_MEMBERS"] = "SITE_MEMBERS";
230
+ /** Anyone */
231
+ VoteRole["ALL"] = "ALL";
232
+ })(VoteRole || (VoteRole = {}));
233
+ export var PollLayoutType;
234
+ (function (PollLayoutType) {
235
+ /** List */
236
+ PollLayoutType["LIST"] = "LIST";
237
+ /** Grid */
238
+ PollLayoutType["GRID"] = "GRID";
239
+ })(PollLayoutType || (PollLayoutType = {}));
240
+ export var PollLayoutDirection;
241
+ (function (PollLayoutDirection) {
242
+ /** Left-to-right */
243
+ PollLayoutDirection["LTR"] = "LTR";
244
+ /** Right-to-left */
245
+ PollLayoutDirection["RTL"] = "RTL";
246
+ })(PollLayoutDirection || (PollLayoutDirection = {}));
247
+ export var BackgroundType;
248
+ (function (BackgroundType) {
249
+ /** Color background type */
250
+ BackgroundType["COLOR"] = "COLOR";
251
+ /** Image background type */
252
+ BackgroundType["IMAGE"] = "IMAGE";
253
+ /** Gradiant background type */
254
+ BackgroundType["GRADIENT"] = "GRADIENT";
255
+ })(BackgroundType || (BackgroundType = {}));
256
+ export var DecorationType;
257
+ (function (DecorationType) {
258
+ DecorationType["BOLD"] = "BOLD";
259
+ DecorationType["ITALIC"] = "ITALIC";
260
+ DecorationType["UNDERLINE"] = "UNDERLINE";
261
+ DecorationType["SPOILER"] = "SPOILER";
262
+ DecorationType["ANCHOR"] = "ANCHOR";
263
+ DecorationType["MENTION"] = "MENTION";
264
+ DecorationType["LINK"] = "LINK";
265
+ DecorationType["COLOR"] = "COLOR";
266
+ DecorationType["FONT_SIZE"] = "FONT_SIZE";
267
+ DecorationType["EXTERNAL"] = "EXTERNAL";
268
+ })(DecorationType || (DecorationType = {}));
269
+ export var FontType;
270
+ (function (FontType) {
271
+ FontType["PX"] = "PX";
272
+ FontType["EM"] = "EM";
273
+ })(FontType || (FontType = {}));
274
+ export var AppType;
275
+ (function (AppType) {
276
+ AppType["PRODUCT"] = "PRODUCT";
277
+ AppType["EVENT"] = "EVENT";
278
+ AppType["BOOKING"] = "BOOKING";
279
+ })(AppType || (AppType = {}));
280
+ export var InitialExpandedItems;
281
+ (function (InitialExpandedItems) {
282
+ /** First item will be expended initally */
283
+ InitialExpandedItems["FIRST"] = "FIRST";
284
+ /** All items will expended initally */
285
+ InitialExpandedItems["ALL"] = "ALL";
286
+ /** All items collapsed initally */
287
+ InitialExpandedItems["NONE"] = "NONE";
288
+ })(InitialExpandedItems || (InitialExpandedItems = {}));
289
+ export var Direction;
290
+ (function (Direction) {
291
+ /** Left-to-right */
292
+ Direction["LTR"] = "LTR";
293
+ /** Right-to-left */
294
+ Direction["RTL"] = "RTL";
295
+ })(Direction || (Direction = {}));
296
+ export var VerticalAlignment;
297
+ (function (VerticalAlignment) {
298
+ /** Top alignment */
299
+ VerticalAlignment["TOP"] = "TOP";
300
+ /** Middle alignment */
301
+ VerticalAlignment["MIDDLE"] = "MIDDLE";
302
+ /** Bottom alignment */
303
+ VerticalAlignment["BOTTOM"] = "BOTTOM";
304
+ })(VerticalAlignment || (VerticalAlignment = {}));
305
+ /**
306
+ * `NullValue` is a singleton enumeration to represent the null value for the
307
+ * `Value` type union.
308
+ *
309
+ * The JSON representation for `NullValue` is JSON `null`.
310
+ */
311
+ export var NullValue;
312
+ (function (NullValue) {
313
+ /** Null value. */
314
+ NullValue["NULL_VALUE"] = "NULL_VALUE";
315
+ })(NullValue || (NullValue = {}));
316
+ export var RequestedFields;
317
+ (function (RequestedFields) {
318
+ RequestedFields["UNKNOWN_REQUESTED_FIELD"] = "UNKNOWN_REQUESTED_FIELD";
319
+ RequestedFields["BREADCRUMBS"] = "BREADCRUMBS";
320
+ })(RequestedFields || (RequestedFields = {}));
321
+ export var SortOrder;
322
+ (function (SortOrder) {
323
+ SortOrder["ASC"] = "ASC";
324
+ SortOrder["DESC"] = "DESC";
325
+ })(SortOrder || (SortOrder = {}));
326
+ export var PlaceCategoryInParentCategoryRequestPosition;
327
+ (function (PlaceCategoryInParentCategoryRequestPosition) {
328
+ PlaceCategoryInParentCategoryRequestPosition["UNKNOWN_POSITION"] = "UNKNOWN_POSITION";
329
+ PlaceCategoryInParentCategoryRequestPosition["FIRST"] = "FIRST";
330
+ PlaceCategoryInParentCategoryRequestPosition["LAST"] = "LAST";
331
+ PlaceCategoryInParentCategoryRequestPosition["BEFORE"] = "BEFORE";
332
+ })(PlaceCategoryInParentCategoryRequestPosition || (PlaceCategoryInParentCategoryRequestPosition = {}));
333
+ export var Position;
334
+ (function (Position) {
335
+ Position["UNKNOWN_POSITION"] = "UNKNOWN_POSITION";
336
+ Position["FIRST"] = "FIRST";
337
+ Position["LAST"] = "LAST";
338
+ Position["BEFORE"] = "BEFORE";
339
+ Position["NONE"] = "NONE";
340
+ })(Position || (Position = {}));
341
+ const _addItemsToCategoryRequest = {};
342
+ const _addItemsToCategoryResponse = {};
343
+ const _addItemToCategoriesRequest = {};
344
+ const _addItemToCategoriesResponse = {};
345
+ const _bulkCategoriesResult = { category: '_category' };
346
+ const _bulkUpdateCategoriesRequest = { categories: '_maskedCategory' };
347
+ const _bulkUpdateCategoriesResponse = { results: '_bulkCategoriesResult' };
348
+ const _category = {
349
+ image: 'wix.common.Image',
350
+ richContentDescription: '_richContent',
351
+ };
352
+ const _createCategoryRequest = { category: '_category' };
353
+ const _createCategoryResponse = { category: '_category' };
354
+ const _deleteCategoryRequest = {};
355
+ const _deleteCategoryResponse = {};
356
+ const _getArrangedItemsRequest = {};
357
+ const _getArrangedItemsResponse = {};
358
+ const _getCategoryRequest = {};
359
+ const _getCategoryResponse = { category: '_category' };
360
+ const _listCategoriesForItemRequest = {};
361
+ const _listCategoriesForItemResponse = {};
362
+ const _listItemsInCategoryRequest = {};
363
+ const _listItemsInCategoryResponse = {};
364
+ const _maskedCategory = { category: '_category' };
365
+ const _moveItemInCategoryRequest = {};
366
+ const _moveItemInCategoryResponse = {};
367
+ const _node = { nodes: '_node' };
368
+ const _placeCategoryInParentCategoryRequest = {};
369
+ const _placeCategoryInParentCategoryResponse = {};
370
+ const _queryCategoriesRequest = {};
371
+ const _queryCategoriesResponse = { categories: '_category' };
372
+ const _removeItemFromCategoriesRequest = {};
373
+ const _removeItemFromCategoriesResponse = {};
374
+ const _removeItemsFromCategoryRequest = {};
375
+ const _removeItemsFromCategoryResponse = {};
376
+ const _richContent = { nodes: '_node' };
377
+ const _setArrangedItemsRequest = {};
378
+ const _setArrangedItemsResponse = {};
379
+ const _updateCategoryRequest = { category: '_category' };
380
+ const _updateCategoryResponse = { category: '_category' };
381
+ const _updateCategoryVisibilityRequest = {};
382
+ const _updateCategoryVisibilityResponse = { category: '_category' };
383
+ /**
384
+ * Creates a new Category.
385
+ * @param category - Category to be created.
386
+ * @public
387
+ * @documentationMaturity preview
388
+ * @requiredField category
389
+ * @requiredField category.name
390
+ * @requiredField category.parentCategory._id
391
+ * @requiredField options
392
+ * @requiredField options.treeReference
393
+ * @requiredField options.treeReference.appNamespace
394
+ * @returns The created Category.
395
+ */
396
+ export function createCategory(category, options) {
397
+ var _a, _b, _c;
398
+ return __awaiter(this, arguments, void 0, function* () {
399
+ const requestTransformation = {
400
+ category: '$[0]',
401
+ treeReference: '$[1].treeReference',
402
+ fields: '$[1].fields',
403
+ };
404
+ const responseTransformation = '$.category';
405
+ // @ts-ignore
406
+ const { httpClient, sideEffects } = arguments[2];
407
+ const { toAmbassadorRequest } = serializer({
408
+ rootSchema: _createCategoryRequest,
409
+ depSchemas: { _category, _node, _richContent },
410
+ fqdnTransformation: {
411
+ paths: [...['category']],
412
+ transformation: _fromVeloEntity,
413
+ },
414
+ customTransformation: requestTransformation,
415
+ });
416
+ const { fromJSON } = serializer({
417
+ rootSchema: _createCategoryResponse,
418
+ depSchemas: { _category, _node, _richContent },
419
+ fqdnTransformation: {
420
+ paths: [...['category']],
421
+ transformation: _toVeloEntity,
422
+ },
423
+ customTransformation: responseTransformation,
424
+ });
425
+ const payload = toAmbassadorRequest([category, options]);
426
+ const reqOpts = ambassadorWixCategoriesV1Category.createCategory(payload);
427
+ __log(`"CreateCategory" sending request with: ${__inspect(reqOpts)}`);
428
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
429
+ try {
430
+ const result = yield httpClient.request(reqOpts);
431
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
432
+ return fromJSON(result.data);
433
+ }
434
+ catch (err) {
435
+ const transformedError = transformError(err, requestTransformation, [
436
+ 'category',
437
+ 'options',
438
+ ]);
439
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
440
+ throw transformedError;
441
+ }
442
+ });
443
+ }
444
+ /**
445
+ * Retrieves a category with the provided ID.
446
+ * @param categoryId - Id of the Category to retrieve.
447
+ * @param treeReference - A reference to the tree that contains this category.
448
+ * @public
449
+ * @documentationMaturity preview
450
+ * @requiredField categoryId
451
+ * @requiredField treeReference
452
+ * @requiredField treeReference.appNamespace
453
+ * @applicableIdentity VISITOR
454
+ * @returns The retrieved Category.
455
+ */
456
+ export function getCategory(categoryId, treeReference, options) {
457
+ var _a, _b, _c;
458
+ return __awaiter(this, arguments, void 0, function* () {
459
+ const requestTransformation = {
460
+ categoryId: '$[0]',
461
+ treeReference: '$[1]',
462
+ fields: '$[2].fields',
463
+ };
464
+ const responseTransformation = '$.category';
465
+ // @ts-ignore
466
+ const { httpClient, sideEffects } = arguments[3];
467
+ const { toAmbassadorRequest } = serializer({
468
+ rootSchema: _getCategoryRequest,
469
+ depSchemas: {},
470
+ fqdnTransformation: {
471
+ paths: [],
472
+ transformation: _fromVeloEntity,
473
+ },
474
+ customTransformation: requestTransformation,
475
+ });
476
+ const { fromJSON } = serializer({
477
+ rootSchema: _getCategoryResponse,
478
+ depSchemas: { _category, _node, _richContent },
479
+ fqdnTransformation: {
480
+ paths: [...['category']],
481
+ transformation: _toVeloEntity,
482
+ },
483
+ customTransformation: responseTransformation,
484
+ });
485
+ const payload = toAmbassadorRequest([categoryId, treeReference, options]);
486
+ const reqOpts = ambassadorWixCategoriesV1Category.getCategory(payload);
487
+ __log(`"GetCategory" sending request with: ${__inspect(reqOpts)}`);
488
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
489
+ try {
490
+ const result = yield httpClient.request(reqOpts);
491
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
492
+ return fromJSON(result.data);
493
+ }
494
+ catch (err) {
495
+ const transformedError = transformError(err, requestTransformation, [
496
+ 'categoryId',
497
+ 'treeReference',
498
+ 'options',
499
+ ]);
500
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
501
+ throw transformedError;
502
+ }
503
+ });
504
+ }
505
+ /**
506
+ * Update a Category, supports partial update.
507
+ * Pass the latest `revision` for a successful update.
508
+ * Each time the category is updated, `revision` increments by 1.
509
+ * @param _id - Category ID.
510
+ * @public
511
+ * @documentationMaturity preview
512
+ * @requiredField _id
513
+ * @requiredField category
514
+ * @requiredField category.revision
515
+ * @requiredField options
516
+ * @requiredField options.treeReference
517
+ * @requiredField options.treeReference.appNamespace
518
+ * @returns The updated Category.
519
+ */
520
+ export function updateCategory(_id, category, options) {
521
+ var _a, _b, _c;
522
+ return __awaiter(this, arguments, void 0, function* () {
523
+ const requestTransformation = {
524
+ category: { '*': '$[1]', id: '$[0]' },
525
+ treeReference: '$[2].treeReference',
526
+ fields: '$[2].fields',
527
+ };
528
+ const responseTransformation = '$.category';
529
+ // @ts-ignore
530
+ const { httpClient, sideEffects } = arguments[3];
531
+ const { toAmbassadorRequest } = serializer({
532
+ rootSchema: _updateCategoryRequest,
533
+ depSchemas: { _category, _node, _richContent },
534
+ fqdnTransformation: {
535
+ paths: [...['category']],
536
+ transformation: _fromVeloEntity,
537
+ },
538
+ customTransformation: requestTransformation,
539
+ });
540
+ const { fromJSON } = serializer({
541
+ rootSchema: _updateCategoryResponse,
542
+ depSchemas: { _category, _node, _richContent },
543
+ fqdnTransformation: {
544
+ paths: [...['category']],
545
+ transformation: _toVeloEntity,
546
+ },
547
+ customTransformation: responseTransformation,
548
+ });
549
+ const payload = toAmbassadorRequest([_id, category, options]);
550
+ const reqOpts = ambassadorWixCategoriesV1Category.updateCategory(payload);
551
+ __log(`"UpdateCategory" sending request with: ${__inspect(reqOpts)}`);
552
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
553
+ try {
554
+ const result = yield httpClient.request(reqOpts);
555
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
556
+ return fromJSON(result.data);
557
+ }
558
+ catch (err) {
559
+ const transformedError = transformError(err, requestTransformation, [
560
+ '_id',
561
+ 'category',
562
+ 'options',
563
+ ]);
564
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
565
+ throw transformedError;
566
+ }
567
+ });
568
+ }
569
+ /**
570
+ * Deletes a Category.
571
+ * @param categoryId - Id of the Category to delete.
572
+ * @param treeReference - A reference to the tree that contains this category.
573
+ * @public
574
+ * @documentationMaturity preview
575
+ * @requiredField categoryId
576
+ * @requiredField treeReference
577
+ * @requiredField treeReference.appNamespace
578
+ */
579
+ export function deleteCategory(categoryId, treeReference) {
580
+ var _a, _b, _c;
581
+ return __awaiter(this, arguments, void 0, function* () {
582
+ const requestTransformation = { categoryId: '$[0]', treeReference: '$[1]' };
583
+ const responseTransformation = '$';
584
+ // @ts-ignore
585
+ const { httpClient, sideEffects } = arguments[2];
586
+ const { toAmbassadorRequest } = serializer({
587
+ rootSchema: _deleteCategoryRequest,
588
+ depSchemas: {},
589
+ fqdnTransformation: {
590
+ paths: [],
591
+ transformation: _fromVeloEntity,
592
+ },
593
+ customTransformation: requestTransformation,
594
+ });
595
+ const { fromJSON } = serializer({
596
+ rootSchema: _deleteCategoryResponse,
597
+ depSchemas: {},
598
+ fqdnTransformation: {
599
+ paths: [],
600
+ transformation: _toVeloEntity,
601
+ },
602
+ customTransformation: responseTransformation,
603
+ });
604
+ const payload = toAmbassadorRequest([categoryId, treeReference]);
605
+ const reqOpts = ambassadorWixCategoriesV1Category.deleteCategory(payload);
606
+ __log(`"DeleteCategory" sending request with: ${__inspect(reqOpts)}`);
607
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
608
+ try {
609
+ const result = yield httpClient.request(reqOpts);
610
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
611
+ return fromJSON(result.data);
612
+ }
613
+ catch (err) {
614
+ const transformedError = transformError(err, requestTransformation, [
615
+ 'categoryId',
616
+ 'treeReference',
617
+ ]);
618
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
619
+ throw transformedError;
620
+ }
621
+ });
622
+ }
623
+ /**
624
+ * Query Categories using [WQL - Wix Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language)
625
+ * @public
626
+ * @documentationMaturity preview
627
+ * @applicableIdentity VISITOR
628
+ */
629
+ export function queryCategories(options) {
630
+ const requestTransformation = { '*': '$[1]', query: '$[0]' };
631
+ const responseTransformation = {
632
+ items: '$.categories',
633
+ pagingMetadata: '$.metadata',
634
+ };
635
+ // @ts-ignore
636
+ const { httpClient, sideEffects } = arguments[1];
637
+ const { toAmbassadorRequest } = serializer({
638
+ rootSchema: _queryCategoriesRequest,
639
+ depSchemas: {},
640
+ fqdnTransformation: {
641
+ paths: [],
642
+ transformation: _fromVeloEntity,
643
+ },
644
+ customTransformation: requestTransformation,
645
+ });
646
+ const { fromJSON } = serializer({
647
+ rootSchema: _queryCategoriesResponse,
648
+ depSchemas: { _category, _node, _richContent },
649
+ fqdnTransformation: {
650
+ paths: [...['Array#categories']],
651
+ transformation: _toVeloEntity,
652
+ },
653
+ customTransformation: responseTransformation,
654
+ });
655
+ return wrapWithQueryBuilder({
656
+ func: (payload) => __awaiter(this, void 0, void 0, function* () {
657
+ var _a, _b, _c;
658
+ const reqOpts = ambassadorWixCategoriesV1Category.queryCategories(Object.assign(Object.assign({}, payload), options));
659
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
660
+ try {
661
+ const result = yield httpClient.request(reqOpts);
662
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
663
+ return result;
664
+ }
665
+ catch (err) {
666
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
667
+ throw err;
668
+ }
669
+ }),
670
+ requestTransformer: (...args) => toAmbassadorRequest(args),
671
+ responseTransformer: ({ data }) => fromJSON(data),
672
+ errorTransformer: (err) => {
673
+ const transformedError = transformError(err, requestTransformation);
674
+ throw transformedError;
675
+ },
676
+ pagingMethod: 'CURSOR',
677
+ transformationPaths: resolveQueryFieldsTransformationPaths(_toVeloEntity),
678
+ })({ cursorWithEmptyFilterAndSort: true });
679
+ }
680
+ /**
681
+ * Places category in parent category.
682
+ * This operation updates `parentCategory` (`id` and `index`) for category with `categoryId` in tree with `treeId`.
683
+ * This endpoint can be used to move category to different parent in the same tree or to change it's position in current parent.
684
+ * @param categoryId - ID of category to place.
685
+ * @param treeReference - A reference to the tree that contains this category.
686
+ * @public
687
+ * @documentationMaturity preview
688
+ * @requiredField categoryId
689
+ * @requiredField options
690
+ * @requiredField options.position
691
+ * @requiredField treeReference
692
+ * @requiredField treeReference.appNamespace
693
+ */
694
+ export function placeCategoryInParentCategory(categoryId, treeReference, options) {
695
+ var _a, _b, _c;
696
+ return __awaiter(this, arguments, void 0, function* () {
697
+ const requestTransformation = {
698
+ categoryId: '$[0]',
699
+ treeReference: '$[1]',
700
+ parentCategoryId: '$[2].parentCategoryId',
701
+ position: '$[2].position',
702
+ moveBeforeCategoryId: '$[2].moveBeforeCategoryId',
703
+ };
704
+ const responseTransformation = '$';
705
+ // @ts-ignore
706
+ const { httpClient, sideEffects } = arguments[3];
707
+ const { toAmbassadorRequest } = serializer({
708
+ rootSchema: _placeCategoryInParentCategoryRequest,
709
+ depSchemas: {},
710
+ fqdnTransformation: {
711
+ paths: [],
712
+ transformation: _fromVeloEntity,
713
+ },
714
+ customTransformation: requestTransformation,
715
+ });
716
+ const { fromJSON } = serializer({
717
+ rootSchema: _placeCategoryInParentCategoryResponse,
718
+ depSchemas: {},
719
+ fqdnTransformation: {
720
+ paths: [],
721
+ transformation: _toVeloEntity,
722
+ },
723
+ customTransformation: responseTransformation,
724
+ });
725
+ const payload = toAmbassadorRequest([categoryId, treeReference, options]);
726
+ const reqOpts = ambassadorWixCategoriesV1Category.placeCategoryInParentCategory(payload);
727
+ __log(`"PlaceCategoryInParentCategory" sending request with: ${__inspect(reqOpts)}`);
728
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
729
+ try {
730
+ const result = yield httpClient.request(reqOpts);
731
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
732
+ return fromJSON(result.data);
733
+ }
734
+ catch (err) {
735
+ const transformedError = transformError(err, requestTransformation, [
736
+ 'categoryId',
737
+ 'treeReference',
738
+ 'options',
739
+ ]);
740
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
741
+ throw transformedError;
742
+ }
743
+ });
744
+ }
745
+ /**
746
+ * Update multiple Categories, supports partial update.
747
+ * Pass the latest `revision` for a successful update.
748
+ * To update visibility, call the BulkUpdateCategoryVisibility endpoint.
749
+ * @param categories - List of categories to be updated.
750
+ * @public
751
+ * @documentationMaturity preview
752
+ * @requiredField categories
753
+ * @requiredField categories.category
754
+ * @requiredField categories.category._id
755
+ * @requiredField categories.category.revision
756
+ * @requiredField options
757
+ * @requiredField options.treeReference
758
+ * @requiredField options.treeReference.appNamespace
759
+ */
760
+ export function bulkUpdateCategories(categories, options) {
761
+ var _a, _b, _c;
762
+ return __awaiter(this, arguments, void 0, function* () {
763
+ const requestTransformation = {
764
+ categories: '$[0]',
765
+ treeReference: '$[1].treeReference',
766
+ returnEntity: '$[1].returnEntity',
767
+ };
768
+ const responseTransformation = '$';
769
+ // @ts-ignore
770
+ const { httpClient, sideEffects } = arguments[2];
771
+ const { toAmbassadorRequest } = serializer({
772
+ rootSchema: _bulkUpdateCategoriesRequest,
773
+ depSchemas: { _category, _maskedCategory, _node, _richContent },
774
+ fqdnTransformation: {
775
+ paths: [...['Array#categories.category']],
776
+ transformation: _fromVeloEntity,
777
+ },
778
+ customTransformation: requestTransformation,
779
+ });
780
+ const { fromJSON } = serializer({
781
+ rootSchema: _bulkUpdateCategoriesResponse,
782
+ depSchemas: { _bulkCategoriesResult, _category, _node, _richContent },
783
+ fqdnTransformation: {
784
+ paths: [...['Array#results.category']],
785
+ transformation: _toVeloEntity,
786
+ },
787
+ customTransformation: responseTransformation,
788
+ });
789
+ const payload = toAmbassadorRequest([categories, options]);
790
+ const reqOpts = ambassadorWixCategoriesV1Category.bulkUpdateCategories(payload);
791
+ __log(`"BulkUpdateCategories" sending request with: ${__inspect(reqOpts)}`);
792
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
793
+ try {
794
+ const result = yield httpClient.request(reqOpts);
795
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
796
+ return fromJSON(result.data);
797
+ }
798
+ catch (err) {
799
+ const transformedError = transformError(err, requestTransformation, [
800
+ 'categories',
801
+ 'options',
802
+ ]);
803
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
804
+ throw transformedError;
805
+ }
806
+ });
807
+ }
808
+ /**
809
+ * Update `visible` field. If visible is set to false, all subcategories will be set to `visible=false`
810
+ * @param categoryId - ID of category to be updated
811
+ * @public
812
+ * @documentationMaturity preview
813
+ * @requiredField categoryId
814
+ * @requiredField options
815
+ * @requiredField options.revision
816
+ * @requiredField options.treeReference
817
+ * @requiredField options.treeReference.appNamespace
818
+ * @requiredField options.visible
819
+ */
820
+ export function updateCategoryVisibility(categoryId, options) {
821
+ var _a, _b, _c;
822
+ return __awaiter(this, arguments, void 0, function* () {
823
+ const requestTransformation = {
824
+ categoryId: '$[0]',
825
+ visible: '$[1].visible',
826
+ treeReference: '$[1].treeReference',
827
+ revision: '$[1].revision',
828
+ };
829
+ const responseTransformation = '$';
830
+ // @ts-ignore
831
+ const { httpClient, sideEffects } = arguments[2];
832
+ const { toAmbassadorRequest } = serializer({
833
+ rootSchema: _updateCategoryVisibilityRequest,
834
+ depSchemas: {},
835
+ fqdnTransformation: {
836
+ paths: [],
837
+ transformation: _fromVeloEntity,
838
+ },
839
+ customTransformation: requestTransformation,
840
+ });
841
+ const { fromJSON } = serializer({
842
+ rootSchema: _updateCategoryVisibilityResponse,
843
+ depSchemas: { _category, _node, _richContent },
844
+ fqdnTransformation: {
845
+ paths: [...['category']],
846
+ transformation: _toVeloEntity,
847
+ },
848
+ customTransformation: responseTransformation,
849
+ });
850
+ const payload = toAmbassadorRequest([categoryId, options]);
851
+ const reqOpts = ambassadorWixCategoriesV1Category.updateCategoryVisibility(payload);
852
+ __log(`"UpdateCategoryVisibility" sending request with: ${__inspect(reqOpts)}`);
853
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
854
+ try {
855
+ const result = yield httpClient.request(reqOpts);
856
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
857
+ return fromJSON(result.data);
858
+ }
859
+ catch (err) {
860
+ const transformedError = transformError(err, requestTransformation, [
861
+ 'categoryId',
862
+ 'options',
863
+ ]);
864
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
865
+ throw transformedError;
866
+ }
867
+ });
868
+ }
869
+ /**
870
+ * Adds multiple items to single category, fires as many domain events as many items successfully added.
871
+ * @param categoryId - Category id.
872
+ * @param items - List of catalog items with reference info.
873
+ * @public
874
+ * @documentationMaturity preview
875
+ * @requiredField categoryId
876
+ * @requiredField items
877
+ * @requiredField items.appId
878
+ * @requiredField items.catalogItemId
879
+ * @requiredField options
880
+ * @requiredField options.treeReference
881
+ * @requiredField options.treeReference.appNamespace
882
+ */
883
+ export function addItemsToCategory(categoryId, items, options) {
884
+ var _a, _b, _c;
885
+ return __awaiter(this, arguments, void 0, function* () {
886
+ const requestTransformation = {
887
+ categoryId: '$[0]',
888
+ items: '$[1]',
889
+ treeReference: '$[2].treeReference',
890
+ };
891
+ const responseTransformation = '$';
892
+ // @ts-ignore
893
+ const { httpClient, sideEffects } = arguments[3];
894
+ const { toAmbassadorRequest } = serializer({
895
+ rootSchema: _addItemsToCategoryRequest,
896
+ depSchemas: {},
897
+ fqdnTransformation: {
898
+ paths: [],
899
+ transformation: _fromVeloEntity,
900
+ },
901
+ customTransformation: requestTransformation,
902
+ });
903
+ const { fromJSON } = serializer({
904
+ rootSchema: _addItemsToCategoryResponse,
905
+ depSchemas: {},
906
+ fqdnTransformation: {
907
+ paths: [],
908
+ transformation: _toVeloEntity,
909
+ },
910
+ customTransformation: responseTransformation,
911
+ });
912
+ const payload = toAmbassadorRequest([categoryId, items, options]);
913
+ const reqOpts = ambassadorWixCategoriesV1Category.addItemsToCategory(payload);
914
+ __log(`"AddItemsToCategory" sending request with: ${__inspect(reqOpts)}`);
915
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
916
+ try {
917
+ const result = yield httpClient.request(reqOpts);
918
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
919
+ return fromJSON(result.data);
920
+ }
921
+ catch (err) {
922
+ const transformedError = transformError(err, requestTransformation, [
923
+ 'categoryId',
924
+ 'items',
925
+ 'options',
926
+ ]);
927
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
928
+ throw transformedError;
929
+ }
930
+ });
931
+ }
932
+ /**
933
+ * Adds single item to multiple categories, fires as many domain events as many categories were successfully added.
934
+ * @param itemReference - Catalog item reference info
935
+ * @public
936
+ * @documentationMaturity preview
937
+ * @requiredField itemReference
938
+ * @requiredField itemReference.appId
939
+ * @requiredField itemReference.catalogItemId
940
+ * @requiredField options
941
+ * @requiredField options.categoryIds
942
+ * @requiredField options.treeReference
943
+ * @requiredField options.treeReference.appNamespace
944
+ */
945
+ export function addItemToCategories(itemReference, options) {
946
+ var _a, _b, _c;
947
+ return __awaiter(this, arguments, void 0, function* () {
948
+ const requestTransformation = {
949
+ itemReference: '$[0]',
950
+ categoryIds: '$[1].categoryIds',
951
+ treeReference: '$[1].treeReference',
952
+ };
953
+ const responseTransformation = '$';
954
+ // @ts-ignore
955
+ const { httpClient, sideEffects } = arguments[2];
956
+ const { toAmbassadorRequest } = serializer({
957
+ rootSchema: _addItemToCategoriesRequest,
958
+ depSchemas: {},
959
+ fqdnTransformation: {
960
+ paths: [],
961
+ transformation: _fromVeloEntity,
962
+ },
963
+ customTransformation: requestTransformation,
964
+ });
965
+ const { fromJSON } = serializer({
966
+ rootSchema: _addItemToCategoriesResponse,
967
+ depSchemas: {},
968
+ fqdnTransformation: {
969
+ paths: [],
970
+ transformation: _toVeloEntity,
971
+ },
972
+ customTransformation: responseTransformation,
973
+ });
974
+ const payload = toAmbassadorRequest([itemReference, options]);
975
+ const reqOpts = ambassadorWixCategoriesV1Category.addItemToCategories(payload);
976
+ __log(`"AddItemToCategories" sending request with: ${__inspect(reqOpts)}`);
977
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
978
+ try {
979
+ const result = yield httpClient.request(reqOpts);
980
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
981
+ return fromJSON(result.data);
982
+ }
983
+ catch (err) {
984
+ const transformedError = transformError(err, requestTransformation, [
985
+ 'itemReference',
986
+ 'options',
987
+ ]);
988
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
989
+ throw transformedError;
990
+ }
991
+ });
992
+ }
993
+ /**
994
+ * Removed multiple items from single category, fires as many domain events as many items successfully removed.
995
+ * @param categoryId - Category id
996
+ * @param items - List of catalog items with reference info.
997
+ * @public
998
+ * @documentationMaturity preview
999
+ * @requiredField categoryId
1000
+ * @requiredField items
1001
+ * @requiredField items.appId
1002
+ * @requiredField items.catalogItemId
1003
+ * @requiredField options
1004
+ * @requiredField options.treeReference
1005
+ * @requiredField options.treeReference.appNamespace
1006
+ */
1007
+ export function removeItemsFromCategory(categoryId, items, options) {
1008
+ var _a, _b, _c;
1009
+ return __awaiter(this, arguments, void 0, function* () {
1010
+ const requestTransformation = {
1011
+ categoryId: '$[0]',
1012
+ items: '$[1]',
1013
+ treeReference: '$[2].treeReference',
1014
+ };
1015
+ const responseTransformation = '$';
1016
+ // @ts-ignore
1017
+ const { httpClient, sideEffects } = arguments[3];
1018
+ const { toAmbassadorRequest } = serializer({
1019
+ rootSchema: _removeItemsFromCategoryRequest,
1020
+ depSchemas: {},
1021
+ fqdnTransformation: {
1022
+ paths: [],
1023
+ transformation: _fromVeloEntity,
1024
+ },
1025
+ customTransformation: requestTransformation,
1026
+ });
1027
+ const { fromJSON } = serializer({
1028
+ rootSchema: _removeItemsFromCategoryResponse,
1029
+ depSchemas: {},
1030
+ fqdnTransformation: {
1031
+ paths: [],
1032
+ transformation: _toVeloEntity,
1033
+ },
1034
+ customTransformation: responseTransformation,
1035
+ });
1036
+ const payload = toAmbassadorRequest([categoryId, items, options]);
1037
+ const reqOpts = ambassadorWixCategoriesV1Category.removeItemsFromCategory(payload);
1038
+ __log(`"RemoveItemsFromCategory" sending request with: ${__inspect(reqOpts)}`);
1039
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1040
+ try {
1041
+ const result = yield httpClient.request(reqOpts);
1042
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1043
+ return fromJSON(result.data);
1044
+ }
1045
+ catch (err) {
1046
+ const transformedError = transformError(err, requestTransformation, [
1047
+ 'categoryId',
1048
+ 'items',
1049
+ 'options',
1050
+ ]);
1051
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1052
+ throw transformedError;
1053
+ }
1054
+ });
1055
+ }
1056
+ /**
1057
+ * Removes single item from multiple categories, fires as many domain events as many categories were successfully removed.
1058
+ * @param itemReference - Catalog item reference info
1059
+ * @public
1060
+ * @documentationMaturity preview
1061
+ * @requiredField itemReference
1062
+ * @requiredField itemReference.appId
1063
+ * @requiredField itemReference.catalogItemId
1064
+ * @requiredField options
1065
+ * @requiredField options.categoryIds
1066
+ * @requiredField options.treeReference
1067
+ * @requiredField options.treeReference.appNamespace
1068
+ */
1069
+ export function removeItemFromCategories(itemReference, options) {
1070
+ var _a, _b, _c;
1071
+ return __awaiter(this, arguments, void 0, function* () {
1072
+ const requestTransformation = {
1073
+ itemReference: '$[0]',
1074
+ categoryIds: '$[1].categoryIds',
1075
+ treeReference: '$[1].treeReference',
1076
+ };
1077
+ const responseTransformation = '$';
1078
+ // @ts-ignore
1079
+ const { httpClient, sideEffects } = arguments[2];
1080
+ const { toAmbassadorRequest } = serializer({
1081
+ rootSchema: _removeItemFromCategoriesRequest,
1082
+ depSchemas: {},
1083
+ fqdnTransformation: {
1084
+ paths: [],
1085
+ transformation: _fromVeloEntity,
1086
+ },
1087
+ customTransformation: requestTransformation,
1088
+ });
1089
+ const { fromJSON } = serializer({
1090
+ rootSchema: _removeItemFromCategoriesResponse,
1091
+ depSchemas: {},
1092
+ fqdnTransformation: {
1093
+ paths: [],
1094
+ transformation: _toVeloEntity,
1095
+ },
1096
+ customTransformation: responseTransformation,
1097
+ });
1098
+ const payload = toAmbassadorRequest([itemReference, options]);
1099
+ const reqOpts = ambassadorWixCategoriesV1Category.removeItemFromCategories(payload);
1100
+ __log(`"RemoveItemFromCategories" sending request with: ${__inspect(reqOpts)}`);
1101
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1102
+ try {
1103
+ const result = yield httpClient.request(reqOpts);
1104
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1105
+ return fromJSON(result.data);
1106
+ }
1107
+ catch (err) {
1108
+ const transformedError = transformError(err, requestTransformation, [
1109
+ 'itemReference',
1110
+ 'options',
1111
+ ]);
1112
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1113
+ throw transformedError;
1114
+ }
1115
+ });
1116
+ }
1117
+ /**
1118
+ * Returns up to 100 items related to requested `category_id` sorted by time when item added to category, descending.
1119
+ * When items added to category in bulk they considered as added at exactly same time so order will be random but always the same.
1120
+ * @param categoryId - ID of category containing items.
1121
+ * @param treeReference - A reference to the tree that contains this category.
1122
+ * @public
1123
+ * @documentationMaturity preview
1124
+ * @requiredField categoryId
1125
+ * @requiredField treeReference
1126
+ * @requiredField treeReference.appNamespace
1127
+ * @applicableIdentity VISITOR
1128
+ */
1129
+ export function listItemsInCategory(categoryId, treeReference, options) {
1130
+ var _a, _b, _c;
1131
+ return __awaiter(this, arguments, void 0, function* () {
1132
+ const requestTransformation = {
1133
+ categoryId: '$[0]',
1134
+ treeReference: '$[1]',
1135
+ useCategoryArrangement: '$[2].useCategoryArrangement',
1136
+ includeItemsFromSubcategories: '$[2].includeItemsFromSubcategories',
1137
+ paging: '$[2].paging',
1138
+ };
1139
+ const responseTransformation = '$';
1140
+ // @ts-ignore
1141
+ const { httpClient, sideEffects } = arguments[3];
1142
+ const { toAmbassadorRequest } = serializer({
1143
+ rootSchema: _listItemsInCategoryRequest,
1144
+ depSchemas: {},
1145
+ fqdnTransformation: {
1146
+ paths: [],
1147
+ transformation: _fromVeloEntity,
1148
+ },
1149
+ customTransformation: requestTransformation,
1150
+ });
1151
+ const { fromJSON } = serializer({
1152
+ rootSchema: _listItemsInCategoryResponse,
1153
+ depSchemas: {},
1154
+ fqdnTransformation: {
1155
+ paths: [],
1156
+ transformation: _toVeloEntity,
1157
+ },
1158
+ customTransformation: responseTransformation,
1159
+ });
1160
+ const payload = toAmbassadorRequest([categoryId, treeReference, options]);
1161
+ const reqOpts = ambassadorWixCategoriesV1Category.listItemsInCategory(payload);
1162
+ __log(`"ListItemsInCategory" sending request with: ${__inspect(reqOpts)}`);
1163
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1164
+ try {
1165
+ const result = yield httpClient.request(reqOpts);
1166
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1167
+ return fromJSON(result.data);
1168
+ }
1169
+ catch (err) {
1170
+ const transformedError = transformError(err, requestTransformation, [
1171
+ 'categoryId',
1172
+ 'treeReference',
1173
+ 'options',
1174
+ ]);
1175
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1176
+ throw transformedError;
1177
+ }
1178
+ });
1179
+ }
1180
+ /**
1181
+ * Returns all category IDs that contain the item and their parent category IDs.
1182
+ * @param itemReference - Catalog item reference info.
1183
+ * @public
1184
+ * @documentationMaturity preview
1185
+ * @requiredField itemReference
1186
+ * @requiredField options
1187
+ * @requiredField options.treeReference
1188
+ * @requiredField options.treeReference.appNamespace
1189
+ * @applicableIdentity VISITOR
1190
+ */
1191
+ export function listCategoriesForItem(itemReference, options) {
1192
+ var _a, _b, _c;
1193
+ return __awaiter(this, arguments, void 0, function* () {
1194
+ const requestTransformation = {
1195
+ itemReference: '$[0]',
1196
+ treeReference: '$[1].treeReference',
1197
+ };
1198
+ const responseTransformation = '$';
1199
+ // @ts-ignore
1200
+ const { httpClient, sideEffects } = arguments[2];
1201
+ const { toAmbassadorRequest } = serializer({
1202
+ rootSchema: _listCategoriesForItemRequest,
1203
+ depSchemas: {},
1204
+ fqdnTransformation: {
1205
+ paths: [],
1206
+ transformation: _fromVeloEntity,
1207
+ },
1208
+ customTransformation: requestTransformation,
1209
+ });
1210
+ const { fromJSON } = serializer({
1211
+ rootSchema: _listCategoriesForItemResponse,
1212
+ depSchemas: {},
1213
+ fqdnTransformation: {
1214
+ paths: [],
1215
+ transformation: _toVeloEntity,
1216
+ },
1217
+ customTransformation: responseTransformation,
1218
+ });
1219
+ const payload = toAmbassadorRequest([itemReference, options]);
1220
+ const reqOpts = ambassadorWixCategoriesV1Category.listCategoriesForItem(payload);
1221
+ __log(`"ListCategoriesForItem" sending request with: ${__inspect(reqOpts)}`);
1222
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1223
+ try {
1224
+ const result = yield httpClient.request(reqOpts);
1225
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1226
+ return fromJSON(result.data);
1227
+ }
1228
+ catch (err) {
1229
+ const transformedError = transformError(err, requestTransformation, [
1230
+ 'itemReference',
1231
+ 'options',
1232
+ ]);
1233
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1234
+ throw transformedError;
1235
+ }
1236
+ });
1237
+ }
1238
+ /**
1239
+ * Changes position of `item` in category. Will be used when sort items by manual arrangement
1240
+ * @param categoryId - ID of category.
1241
+ * Item must be direct child of this category, otherwise error returned
1242
+ * @param treeReference - A reference to the tree that contains this category.
1243
+ * @public
1244
+ * @documentationMaturity preview
1245
+ * @requiredField categoryId
1246
+ * @requiredField options
1247
+ * @requiredField options.item
1248
+ * @requiredField options.position
1249
+ * @requiredField treeReference
1250
+ * @requiredField treeReference.appNamespace
1251
+ */
1252
+ export function moveItemInCategory(categoryId, treeReference, options) {
1253
+ var _a, _b, _c;
1254
+ return __awaiter(this, arguments, void 0, function* () {
1255
+ const requestTransformation = {
1256
+ categoryId: '$[0]',
1257
+ treeReference: '$[1]',
1258
+ item: '$[2].item',
1259
+ position: '$[2].position',
1260
+ beforeItem: '$[2].beforeItem',
1261
+ };
1262
+ const responseTransformation = '$';
1263
+ // @ts-ignore
1264
+ const { httpClient, sideEffects } = arguments[3];
1265
+ const { toAmbassadorRequest } = serializer({
1266
+ rootSchema: _moveItemInCategoryRequest,
1267
+ depSchemas: {},
1268
+ fqdnTransformation: {
1269
+ paths: [],
1270
+ transformation: _fromVeloEntity,
1271
+ },
1272
+ customTransformation: requestTransformation,
1273
+ });
1274
+ const { fromJSON } = serializer({
1275
+ rootSchema: _moveItemInCategoryResponse,
1276
+ depSchemas: {},
1277
+ fqdnTransformation: {
1278
+ paths: [],
1279
+ transformation: _toVeloEntity,
1280
+ },
1281
+ customTransformation: responseTransformation,
1282
+ });
1283
+ const payload = toAmbassadorRequest([categoryId, treeReference, options]);
1284
+ const reqOpts = ambassadorWixCategoriesV1Category.moveItemInCategory(payload);
1285
+ __log(`"MoveItemInCategory" sending request with: ${__inspect(reqOpts)}`);
1286
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1287
+ try {
1288
+ const result = yield httpClient.request(reqOpts);
1289
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1290
+ return fromJSON(result.data);
1291
+ }
1292
+ catch (err) {
1293
+ const transformedError = transformError(err, requestTransformation, [
1294
+ 'categoryId',
1295
+ 'treeReference',
1296
+ 'options',
1297
+ ]);
1298
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1299
+ throw transformedError;
1300
+ }
1301
+ });
1302
+ }
1303
+ /**
1304
+ * Set arranged items in category. Will be used when sort items by manual arrangement.
1305
+ * Calling this endpoint overrides existing list of arranged items in category.
1306
+ * @param categoryId - ID of category.
1307
+ * @param treeReference - A reference to the tree that contains this category.
1308
+ * @public
1309
+ * @documentationMaturity preview
1310
+ * @requiredField categoryId
1311
+ * @requiredField treeReference
1312
+ * @requiredField treeReference.appNamespace
1313
+ */
1314
+ export function setArrangedItems(categoryId, treeReference, options) {
1315
+ var _a, _b, _c;
1316
+ return __awaiter(this, arguments, void 0, function* () {
1317
+ const requestTransformation = {
1318
+ categoryId: '$[0]',
1319
+ treeReference: '$[1]',
1320
+ items: '$[2].items',
1321
+ };
1322
+ const responseTransformation = '$';
1323
+ // @ts-ignore
1324
+ const { httpClient, sideEffects } = arguments[3];
1325
+ const { toAmbassadorRequest } = serializer({
1326
+ rootSchema: _setArrangedItemsRequest,
1327
+ depSchemas: {},
1328
+ fqdnTransformation: {
1329
+ paths: [],
1330
+ transformation: _fromVeloEntity,
1331
+ },
1332
+ customTransformation: requestTransformation,
1333
+ });
1334
+ const { fromJSON } = serializer({
1335
+ rootSchema: _setArrangedItemsResponse,
1336
+ depSchemas: {},
1337
+ fqdnTransformation: {
1338
+ paths: [],
1339
+ transformation: _toVeloEntity,
1340
+ },
1341
+ customTransformation: responseTransformation,
1342
+ });
1343
+ const payload = toAmbassadorRequest([categoryId, treeReference, options]);
1344
+ const reqOpts = ambassadorWixCategoriesV1Category.setArrangedItems(payload);
1345
+ __log(`"SetArrangedItems" sending request with: ${__inspect(reqOpts)}`);
1346
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1347
+ try {
1348
+ const result = yield httpClient.request(reqOpts);
1349
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1350
+ return fromJSON(result.data);
1351
+ }
1352
+ catch (err) {
1353
+ const transformedError = transformError(err, requestTransformation, [
1354
+ 'categoryId',
1355
+ 'treeReference',
1356
+ 'options',
1357
+ ]);
1358
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1359
+ throw transformedError;
1360
+ }
1361
+ });
1362
+ }
1363
+ /**
1364
+ * Returns arranged items in category
1365
+ * @param categoryId - ID of category.
1366
+ * @param treeReference - A reference to the tree that contains this category.
1367
+ * @public
1368
+ * @documentationMaturity preview
1369
+ * @requiredField categoryId
1370
+ * @requiredField treeReference
1371
+ * @requiredField treeReference.appNamespace
1372
+ * @applicableIdentity VISITOR
1373
+ */
1374
+ export function getArrangedItems(categoryId, treeReference) {
1375
+ var _a, _b, _c;
1376
+ return __awaiter(this, arguments, void 0, function* () {
1377
+ const requestTransformation = { categoryId: '$[0]', treeReference: '$[1]' };
1378
+ const responseTransformation = '$';
1379
+ // @ts-ignore
1380
+ const { httpClient, sideEffects } = arguments[2];
1381
+ const { toAmbassadorRequest } = serializer({
1382
+ rootSchema: _getArrangedItemsRequest,
1383
+ depSchemas: {},
1384
+ fqdnTransformation: {
1385
+ paths: [],
1386
+ transformation: _fromVeloEntity,
1387
+ },
1388
+ customTransformation: requestTransformation,
1389
+ });
1390
+ const { fromJSON } = serializer({
1391
+ rootSchema: _getArrangedItemsResponse,
1392
+ depSchemas: {},
1393
+ fqdnTransformation: {
1394
+ paths: [],
1395
+ transformation: _toVeloEntity,
1396
+ },
1397
+ customTransformation: responseTransformation,
1398
+ });
1399
+ const payload = toAmbassadorRequest([categoryId, treeReference]);
1400
+ const reqOpts = ambassadorWixCategoriesV1Category.getArrangedItems(payload);
1401
+ __log(`"GetArrangedItems" sending request with: ${__inspect(reqOpts)}`);
1402
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1403
+ try {
1404
+ const result = yield httpClient.request(reqOpts);
1405
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1406
+ return fromJSON(result.data);
1407
+ }
1408
+ catch (err) {
1409
+ const transformedError = transformError(err, requestTransformation, [
1410
+ 'categoryId',
1411
+ 'treeReference',
1412
+ ]);
1413
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1414
+ throw transformedError;
1415
+ }
1416
+ });
1417
+ }
1418
+ //# sourceMappingURL=categories-v1-category.universal.js.map