@wix/auto_sdk_stores_customizations-v-3 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 (111) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +18 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/index.typings.d.ts +1 -0
  5. package/build/cjs/index.typings.js +18 -0
  6. package/build/cjs/index.typings.js.map +1 -0
  7. package/build/cjs/meta.d.ts +1 -0
  8. package/build/cjs/meta.js +18 -0
  9. package/build/cjs/meta.js.map +1 -0
  10. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.d.ts +31 -0
  11. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.js +40 -0
  12. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.js.map +1 -0
  13. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.d.ts +63 -0
  14. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.js +683 -0
  15. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.js.map +1 -0
  16. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.d.ts +35 -0
  17. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.js +237 -0
  18. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.js.map +1 -0
  19. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.d.ts +130 -0
  20. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.js +126 -0
  21. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.js.map +1 -0
  22. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.d.ts +736 -0
  23. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.js +51 -0
  24. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.js.map +1 -0
  25. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.d.ts +1281 -0
  26. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.js +764 -0
  27. package/build/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.js.map +1 -0
  28. package/build/es/index.d.ts +1 -0
  29. package/build/es/index.js +2 -0
  30. package/build/es/index.js.map +1 -0
  31. package/build/es/index.typings.d.ts +1 -0
  32. package/build/es/index.typings.js +2 -0
  33. package/build/es/index.typings.js.map +1 -0
  34. package/build/es/meta.d.ts +1 -0
  35. package/build/es/meta.js +2 -0
  36. package/build/es/meta.js.map +1 -0
  37. package/build/es/package.json +3 -0
  38. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.context.d.ts +31 -0
  39. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.context.js +31 -0
  40. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.context.js.map +1 -0
  41. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.http.d.ts +63 -0
  42. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.http.js +669 -0
  43. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.http.js.map +1 -0
  44. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.meta.d.ts +35 -0
  45. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.meta.js +200 -0
  46. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.meta.js.map +1 -0
  47. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.public.d.ts +130 -0
  48. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.public.js +106 -0
  49. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.public.js.map +1 -0
  50. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.types.d.ts +736 -0
  51. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.types.js +48 -0
  52. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.types.js.map +1 -0
  53. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.universal.d.ts +1281 -0
  54. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.universal.js +727 -0
  55. package/build/es/src/stores-catalog-v3-customization-customizations-v-3.universal.js.map +1 -0
  56. package/build/internal/cjs/index.d.ts +1 -0
  57. package/build/internal/cjs/index.js +18 -0
  58. package/build/internal/cjs/index.js.map +1 -0
  59. package/build/internal/cjs/index.typings.d.ts +1 -0
  60. package/build/internal/cjs/index.typings.js +18 -0
  61. package/build/internal/cjs/index.typings.js.map +1 -0
  62. package/build/internal/cjs/meta.d.ts +1 -0
  63. package/build/internal/cjs/meta.js +18 -0
  64. package/build/internal/cjs/meta.js.map +1 -0
  65. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.d.ts +31 -0
  66. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.js +40 -0
  67. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.context.js.map +1 -0
  68. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.d.ts +63 -0
  69. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.js +683 -0
  70. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.http.js.map +1 -0
  71. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.d.ts +35 -0
  72. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.js +237 -0
  73. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.meta.js.map +1 -0
  74. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.d.ts +130 -0
  75. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.js +126 -0
  76. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.public.js.map +1 -0
  77. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.d.ts +736 -0
  78. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.js +51 -0
  79. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.types.js.map +1 -0
  80. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.d.ts +1281 -0
  81. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.js +764 -0
  82. package/build/internal/cjs/src/stores-catalog-v3-customization-customizations-v-3.universal.js.map +1 -0
  83. package/build/internal/es/index.d.ts +1 -0
  84. package/build/internal/es/index.js +2 -0
  85. package/build/internal/es/index.js.map +1 -0
  86. package/build/internal/es/index.typings.d.ts +1 -0
  87. package/build/internal/es/index.typings.js +2 -0
  88. package/build/internal/es/index.typings.js.map +1 -0
  89. package/build/internal/es/meta.d.ts +1 -0
  90. package/build/internal/es/meta.js +2 -0
  91. package/build/internal/es/meta.js.map +1 -0
  92. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.context.d.ts +31 -0
  93. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.context.js +31 -0
  94. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.context.js.map +1 -0
  95. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.http.d.ts +63 -0
  96. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.http.js +669 -0
  97. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.http.js.map +1 -0
  98. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.meta.d.ts +35 -0
  99. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.meta.js +200 -0
  100. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.meta.js.map +1 -0
  101. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.public.d.ts +130 -0
  102. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.public.js +106 -0
  103. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.public.js.map +1 -0
  104. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.types.d.ts +736 -0
  105. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.types.js +48 -0
  106. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.types.js.map +1 -0
  107. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.universal.d.ts +1281 -0
  108. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.universal.js +727 -0
  109. package/build/internal/es/src/stores-catalog-v3-customization-customizations-v-3.universal.js.map +1 -0
  110. package/meta/package.json +3 -0
  111. package/package.json +52 -0
@@ -0,0 +1,727 @@
1
+ import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
2
+ import { queryBuilder } from '@wix/sdk-runtime/query-builder';
3
+ import { renameKeysFromSDKRequestToRESTRequest, renameKeysFromRESTResponseToSDKResponse, } from '@wix/sdk-runtime/rename-all-nested-keys';
4
+ import * as ambassadorWixStoresCatalogV3Customization from './stores-catalog-v3-customization-customizations-v-3.http.js';
5
+ // @ts-ignore
6
+ import { transformSDKImageToRESTImage } from '@wix/sdk-runtime/transformations/image';
7
+ import { transformRESTImageToSDKImage } from '@wix/sdk-runtime/transformations/image';
8
+ import { transformPaths } from '@wix/sdk-runtime/transformations/transform-paths';
9
+ export var CustomizationType;
10
+ (function (CustomizationType) {
11
+ CustomizationType["UNKNOWN_CUSTOMIZATION_TYPE"] = "UNKNOWN_CUSTOMIZATION_TYPE";
12
+ CustomizationType["PRODUCT_OPTION"] = "PRODUCT_OPTION";
13
+ CustomizationType["MODIFIER"] = "MODIFIER";
14
+ })(CustomizationType || (CustomizationType = {}));
15
+ export var CustomizationRenderType;
16
+ (function (CustomizationRenderType) {
17
+ CustomizationRenderType["UNKNOWN_CUSTOMIZATION_RENDER_TYPE"] = "UNKNOWN_CUSTOMIZATION_RENDER_TYPE";
18
+ CustomizationRenderType["FREE_TEXT"] = "FREE_TEXT";
19
+ CustomizationRenderType["TEXT_CHOICES"] = "TEXT_CHOICES";
20
+ CustomizationRenderType["SWATCH_CHOICES"] = "SWATCH_CHOICES";
21
+ })(CustomizationRenderType || (CustomizationRenderType = {}));
22
+ export var ChoiceType;
23
+ (function (ChoiceType) {
24
+ ChoiceType["UNKNOWN_CHOICE_TYPE"] = "UNKNOWN_CHOICE_TYPE";
25
+ /** For a `customizationRenderType` of `TEXT_CHOICES` and `FREE_TEXT`. */
26
+ ChoiceType["CHOICE_TEXT"] = "CHOICE_TEXT";
27
+ /** For `customizationRenderType: SWATCH_CHOICES`. */
28
+ ChoiceType["ONE_COLOR"] = "ONE_COLOR";
29
+ /** For `customizationRenderType: SWATCH_CHOICES`. */
30
+ ChoiceType["MULTIPLE_COLORS"] = "MULTIPLE_COLORS";
31
+ /** For `customizationRenderType: SWATCH_CHOICES`. */
32
+ ChoiceType["IMAGE"] = "IMAGE";
33
+ })(ChoiceType || (ChoiceType = {}));
34
+ export var RequestedFields;
35
+ (function (RequestedFields) {
36
+ /** Unknown requested field. */
37
+ RequestedFields["UNKNOWN_REQUESTED_FIELD"] = "UNKNOWN_REQUESTED_FIELD";
38
+ /** Assigned products count. */
39
+ RequestedFields["ASSIGNED_PRODUCTS_COUNT"] = "ASSIGNED_PRODUCTS_COUNT";
40
+ })(RequestedFields || (RequestedFields = {}));
41
+ export var SortOrder;
42
+ (function (SortOrder) {
43
+ /** Ascending order. */
44
+ SortOrder["ASC"] = "ASC";
45
+ /** Descending order. */
46
+ SortOrder["DESC"] = "DESC";
47
+ })(SortOrder || (SortOrder = {}));
48
+ export var WebhookIdentityType;
49
+ (function (WebhookIdentityType) {
50
+ WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
51
+ WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
52
+ WebhookIdentityType["MEMBER"] = "MEMBER";
53
+ WebhookIdentityType["WIX_USER"] = "WIX_USER";
54
+ WebhookIdentityType["APP"] = "APP";
55
+ })(WebhookIdentityType || (WebhookIdentityType = {}));
56
+ /**
57
+ * Creates a customization.
58
+ * @param customization - Customization to create.
59
+ * @public
60
+ * @documentationMaturity preview
61
+ * @requiredField customization
62
+ * @requiredField customization.choicesSettings.choices
63
+ * @requiredField customization.customizationRenderType
64
+ * @requiredField customization.customizationType
65
+ * @requiredField customization.freeTextInput.title
66
+ * @requiredField customization.name
67
+ * @permissionId WIX_STORES.CUSTOMIZATION_CREATE
68
+ * @permissionScope Customization write in v3 catalog
69
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
70
+ * @permissionScope Manage Products
71
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
72
+ * @permissionScope Product write in v3 catalog
73
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
74
+ * @permissionScope Manage v3 catalog
75
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
76
+ * @applicableIdentity APP
77
+ * @returns Created customization.
78
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.CreateCustomization
79
+ */
80
+ export async function createCustomization(customization) {
81
+ // @ts-ignore
82
+ const { httpClient, sideEffects } = arguments[1];
83
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({ customization: customization }), [
84
+ {
85
+ transformFn: transformSDKImageToRESTImage,
86
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
87
+ },
88
+ ]);
89
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.createCustomization(payload);
90
+ sideEffects?.onSiteCall?.();
91
+ try {
92
+ const result = await httpClient.request(reqOpts);
93
+ sideEffects?.onSuccess?.(result);
94
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
95
+ {
96
+ transformFn: transformRESTImageToSDKImage,
97
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
98
+ },
99
+ ]))?.customization;
100
+ }
101
+ catch (err) {
102
+ const transformedError = sdkTransformError(err, {
103
+ spreadPathsToArguments: {},
104
+ explicitPathsToArguments: { customization: '$[0]' },
105
+ singleArgumentUnchanged: false,
106
+ }, ['customization']);
107
+ sideEffects?.onError?.(err);
108
+ throw transformedError;
109
+ }
110
+ }
111
+ /**
112
+ * Retrieves a customization.
113
+ * @param customizationId - Customization ID.
114
+ * @public
115
+ * @documentationMaturity preview
116
+ * @requiredField customizationId
117
+ * @permissionId WIX_STORES.CUSTOMIZATION_READ
118
+ * @permissionScope Read v3 catalog
119
+ * @permissionScopeId SCOPE.STORES.CATALOG_READ
120
+ * @permissionScope Manage Products
121
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
122
+ * @permissionScope Read Products
123
+ * @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
124
+ * @permissionScope Product write in v3 catalog
125
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
126
+ * @permissionScope Read customizations in v3 catalog
127
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_READ
128
+ * @permissionScope Manage v3 catalog
129
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
130
+ * @permissionScope Manage Orders
131
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
132
+ * @applicableIdentity APP
133
+ * @applicableIdentity VISITOR
134
+ * @returns Customization.
135
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.GetCustomization
136
+ */
137
+ export async function getCustomization(customizationId, options) {
138
+ // @ts-ignore
139
+ const { httpClient, sideEffects } = arguments[2];
140
+ const payload = renameKeysFromSDKRequestToRESTRequest({
141
+ customizationId: customizationId,
142
+ fields: options?.fields,
143
+ });
144
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.getCustomization(payload);
145
+ sideEffects?.onSiteCall?.();
146
+ try {
147
+ const result = await httpClient.request(reqOpts);
148
+ sideEffects?.onSuccess?.(result);
149
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
150
+ {
151
+ transformFn: transformRESTImageToSDKImage,
152
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
153
+ },
154
+ ]))?.customization;
155
+ }
156
+ catch (err) {
157
+ const transformedError = sdkTransformError(err, {
158
+ spreadPathsToArguments: {},
159
+ explicitPathsToArguments: {
160
+ customizationId: '$[0]',
161
+ fields: '$[1].fields',
162
+ },
163
+ singleArgumentUnchanged: false,
164
+ }, ['customizationId', 'options']);
165
+ sideEffects?.onError?.(err);
166
+ throw transformedError;
167
+ }
168
+ }
169
+ /**
170
+ * Updates a customization.
171
+ *
172
+ * Each time the customization is updated, `revision` increments by 1.
173
+ * The current `revision` must be passed when updating the customization.
174
+ * This ensures you're working with the latest customization and prevents unintended overwrites.
175
+ * @param _id - Customization ID.
176
+ * @public
177
+ * @documentationMaturity preview
178
+ * @requiredField _id
179
+ * @requiredField customization
180
+ * @requiredField customization.revision
181
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
182
+ * @permissionScope Customization write in v3 catalog
183
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
184
+ * @permissionScope Manage Products
185
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
186
+ * @permissionScope Product write in v3 catalog
187
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
188
+ * @permissionScope Manage v3 catalog
189
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
190
+ * @applicableIdentity APP
191
+ * @returns Updated customization.
192
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.UpdateCustomization
193
+ */
194
+ export async function updateCustomization(_id, customization, options) {
195
+ // @ts-ignore
196
+ const { httpClient, sideEffects } = arguments[3];
197
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
198
+ customization: { ...customization, id: _id },
199
+ fields: options?.fields,
200
+ }), [
201
+ {
202
+ transformFn: transformSDKImageToRESTImage,
203
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
204
+ },
205
+ ]);
206
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.updateCustomization(payload);
207
+ sideEffects?.onSiteCall?.();
208
+ try {
209
+ const result = await httpClient.request(reqOpts);
210
+ sideEffects?.onSuccess?.(result);
211
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
212
+ {
213
+ transformFn: transformRESTImageToSDKImage,
214
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
215
+ },
216
+ ]))?.customization;
217
+ }
218
+ catch (err) {
219
+ const transformedError = sdkTransformError(err, {
220
+ spreadPathsToArguments: { customization: '$[1]' },
221
+ explicitPathsToArguments: {
222
+ 'customization.id': '$[0]',
223
+ fields: '$[2].fields',
224
+ },
225
+ singleArgumentUnchanged: false,
226
+ }, ['_id', 'customization', 'options']);
227
+ sideEffects?.onError?.(err);
228
+ throw transformedError;
229
+ }
230
+ }
231
+ /**
232
+ * Deletes a customization.
233
+ *
234
+ * > **Note:** A customization cannot be deleted if it is assigned to one or more products.
235
+ * @param customizationId - Customization ID.
236
+ * @public
237
+ * @documentationMaturity preview
238
+ * @requiredField customizationId
239
+ * @permissionId WIX_STORES.CUSTOMIZATION_DELETE
240
+ * @permissionScope Customization write in v3 catalog
241
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
242
+ * @permissionScope Manage Products
243
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
244
+ * @permissionScope Product write in v3 catalog
245
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
246
+ * @permissionScope Manage v3 catalog
247
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
248
+ * @applicableIdentity APP
249
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.DeleteCustomization
250
+ */
251
+ export async function deleteCustomization(customizationId) {
252
+ // @ts-ignore
253
+ const { httpClient, sideEffects } = arguments[1];
254
+ const payload = renameKeysFromSDKRequestToRESTRequest({
255
+ customizationId: customizationId,
256
+ });
257
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.deleteCustomization(payload);
258
+ sideEffects?.onSiteCall?.();
259
+ try {
260
+ const result = await httpClient.request(reqOpts);
261
+ sideEffects?.onSuccess?.(result);
262
+ }
263
+ catch (err) {
264
+ const transformedError = sdkTransformError(err, {
265
+ spreadPathsToArguments: {},
266
+ explicitPathsToArguments: { customizationId: '$[0]' },
267
+ singleArgumentUnchanged: false,
268
+ }, ['customizationId']);
269
+ sideEffects?.onError?.(err);
270
+ throw transformedError;
271
+ }
272
+ }
273
+ /**
274
+ * Retrieves a list of up to 100 customizations, given the provided filtering, sorting, and cursor paging.
275
+ * Pass supported values to the `fields` array in the request to include those fields in the response.
276
+ *
277
+ *
278
+ * Query Customizations runs with these defaults, which you can override:
279
+ *
280
+ * - `createdDate` is sorted in `DESC` order
281
+ * - `cursorPaging.limit` is `100`
282
+ *
283
+ * For field support for filters and sorting,
284
+ * see [Customizations: Supported Filters and Sorting](https://dev.wix.com/docs/rest/business-solutions/stores/catalog-v3/customizations-v3/supported-filters-and-sorting).
285
+ *
286
+ * To learn about working with _Query_ endpoints, see
287
+ * [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language),
288
+ * and [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging).
289
+ * @public
290
+ * @documentationMaturity preview
291
+ * @permissionScope Read v3 catalog
292
+ * @permissionScopeId SCOPE.STORES.CATALOG_READ
293
+ * @permissionScope Manage Products
294
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
295
+ * @permissionScope Read Products
296
+ * @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
297
+ * @permissionScope Product write in v3 catalog
298
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
299
+ * @permissionScope Read customizations in v3 catalog
300
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_READ
301
+ * @permissionScope Manage v3 catalog
302
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
303
+ * @permissionScope Manage Orders
304
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
305
+ * @permissionId WIX_STORES.CUSTOMIZATION_READ
306
+ * @applicableIdentity APP
307
+ * @applicableIdentity VISITOR
308
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.QueryCustomizations
309
+ */
310
+ export function queryCustomizations(options) {
311
+ // @ts-ignore
312
+ const { httpClient, sideEffects } = arguments[1];
313
+ return queryBuilder({
314
+ func: async (payload) => {
315
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.queryCustomizations({
316
+ ...payload,
317
+ ...(options ?? {}),
318
+ });
319
+ sideEffects?.onSiteCall?.();
320
+ try {
321
+ const result = await httpClient.request(reqOpts);
322
+ sideEffects?.onSuccess?.(result);
323
+ return result;
324
+ }
325
+ catch (err) {
326
+ sideEffects?.onError?.(err);
327
+ throw err;
328
+ }
329
+ },
330
+ requestTransformer: (query) => {
331
+ const args = [query, options];
332
+ return renameKeysFromSDKRequestToRESTRequest({
333
+ ...args?.[1],
334
+ query: args?.[0],
335
+ });
336
+ },
337
+ responseTransformer: ({ data, }) => {
338
+ const transformedData = renameKeysFromRESTResponseToSDKResponse(transformPaths(data, [
339
+ {
340
+ transformFn: transformRESTImageToSDKImage,
341
+ paths: [{ path: 'customizations.choicesSettings.choices.image' }],
342
+ },
343
+ ]));
344
+ return {
345
+ items: transformedData?.customizations,
346
+ pagingMetadata: transformedData?.pagingMetadata,
347
+ };
348
+ },
349
+ errorTransformer: (err) => {
350
+ const transformedError = sdkTransformError(err, {
351
+ spreadPathsToArguments: {},
352
+ explicitPathsToArguments: { query: '$[0]' },
353
+ singleArgumentUnchanged: false,
354
+ });
355
+ throw transformedError;
356
+ },
357
+ pagingMethod: 'CURSOR',
358
+ transformationPaths: {},
359
+ });
360
+ }
361
+ /**
362
+ * Creates multiple brands.
363
+ * @param customizations - Customizations to create.
364
+ * @public
365
+ * @documentationMaturity preview
366
+ * @requiredField customizations
367
+ * @permissionId WIX_STORES.CUSTOMIZATION_CREATE
368
+ * @permissionScope Customization write in v3 catalog
369
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
370
+ * @permissionScope Manage Products
371
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
372
+ * @permissionScope Product write in v3 catalog
373
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
374
+ * @permissionScope Manage v3 catalog
375
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
376
+ * @applicableIdentity APP
377
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.BulkCreateCustomizations
378
+ */
379
+ export async function bulkCreateCustomizations(customizations, options) {
380
+ // @ts-ignore
381
+ const { httpClient, sideEffects } = arguments[2];
382
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
383
+ customizations: customizations,
384
+ returnEntity: options?.returnEntity,
385
+ }), [
386
+ {
387
+ transformFn: transformSDKImageToRESTImage,
388
+ paths: [{ path: 'customizations.choicesSettings.choices.image' }],
389
+ },
390
+ ]);
391
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.bulkCreateCustomizations(payload);
392
+ sideEffects?.onSiteCall?.();
393
+ try {
394
+ const result = await httpClient.request(reqOpts);
395
+ sideEffects?.onSuccess?.(result);
396
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
397
+ {
398
+ transformFn: transformRESTImageToSDKImage,
399
+ paths: [
400
+ { path: 'results.customization.choicesSettings.choices.image' },
401
+ ],
402
+ },
403
+ ]));
404
+ }
405
+ catch (err) {
406
+ const transformedError = sdkTransformError(err, {
407
+ spreadPathsToArguments: {},
408
+ explicitPathsToArguments: {
409
+ customizations: '$[0]',
410
+ returnEntity: '$[1].returnEntity',
411
+ },
412
+ singleArgumentUnchanged: false,
413
+ }, ['customizations', 'options']);
414
+ sideEffects?.onError?.(err);
415
+ throw transformedError;
416
+ }
417
+ }
418
+ /**
419
+ * Adds choices to a customization.
420
+ * @param customizationId - Customization ID.
421
+ * @param choices - Choices to add.
422
+ * @public
423
+ * @documentationMaturity preview
424
+ * @requiredField choices
425
+ * @requiredField customizationId
426
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
427
+ * @permissionScope Customization write in v3 catalog
428
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
429
+ * @permissionScope Manage Products
430
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
431
+ * @permissionScope Product write in v3 catalog
432
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
433
+ * @permissionScope Manage v3 catalog
434
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
435
+ * @applicableIdentity APP
436
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.AddCustomizationChoices
437
+ */
438
+ export async function addCustomizationChoices(customizationId, choices, options) {
439
+ // @ts-ignore
440
+ const { httpClient, sideEffects } = arguments[3];
441
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
442
+ customizationId: customizationId,
443
+ choices: choices,
444
+ fields: options?.fields,
445
+ }), [
446
+ {
447
+ transformFn: transformSDKImageToRESTImage,
448
+ paths: [{ path: 'choices.image' }],
449
+ },
450
+ ]);
451
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.addCustomizationChoices(payload);
452
+ sideEffects?.onSiteCall?.();
453
+ try {
454
+ const result = await httpClient.request(reqOpts);
455
+ sideEffects?.onSuccess?.(result);
456
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
457
+ {
458
+ transformFn: transformRESTImageToSDKImage,
459
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
460
+ },
461
+ ]));
462
+ }
463
+ catch (err) {
464
+ const transformedError = sdkTransformError(err, {
465
+ spreadPathsToArguments: {},
466
+ explicitPathsToArguments: {
467
+ customizationId: '$[0]',
468
+ choices: '$[1]',
469
+ fields: '$[2].fields',
470
+ },
471
+ singleArgumentUnchanged: false,
472
+ }, ['customizationId', 'choices', 'options']);
473
+ sideEffects?.onError?.(err);
474
+ throw transformedError;
475
+ }
476
+ }
477
+ /**
478
+ * Sets a customization's choices. Any and all existing choices will be overridden.
479
+ *
480
+ * > **Note:** A choice cannot be overridden if it is assigned to one or more products.
481
+ * @param customizationId - Customization ID.
482
+ * @param choices - Choices to set.
483
+ * @public
484
+ * @documentationMaturity preview
485
+ * @requiredField choices
486
+ * @requiredField customizationId
487
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
488
+ * @permissionScope Customization write in v3 catalog
489
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
490
+ * @permissionScope Manage Products
491
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
492
+ * @permissionScope Product write in v3 catalog
493
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
494
+ * @permissionScope Manage v3 catalog
495
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
496
+ * @applicableIdentity APP
497
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.SetCustomizationChoices
498
+ */
499
+ export async function setCustomizationChoices(customizationId, choices, options) {
500
+ // @ts-ignore
501
+ const { httpClient, sideEffects } = arguments[3];
502
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
503
+ customizationId: customizationId,
504
+ choices: choices,
505
+ fields: options?.fields,
506
+ }), [
507
+ {
508
+ transformFn: transformSDKImageToRESTImage,
509
+ paths: [{ path: 'choices.image' }],
510
+ },
511
+ ]);
512
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.setCustomizationChoices(payload);
513
+ sideEffects?.onSiteCall?.();
514
+ try {
515
+ const result = await httpClient.request(reqOpts);
516
+ sideEffects?.onSuccess?.(result);
517
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
518
+ {
519
+ transformFn: transformRESTImageToSDKImage,
520
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
521
+ },
522
+ ]));
523
+ }
524
+ catch (err) {
525
+ const transformedError = sdkTransformError(err, {
526
+ spreadPathsToArguments: {},
527
+ explicitPathsToArguments: {
528
+ customizationId: '$[0]',
529
+ choices: '$[1]',
530
+ fields: '$[2].fields',
531
+ },
532
+ singleArgumentUnchanged: false,
533
+ }, ['customizationId', 'choices', 'options']);
534
+ sideEffects?.onError?.(err);
535
+ throw transformedError;
536
+ }
537
+ }
538
+ /**
539
+ * Removes choices from a customization.
540
+ *
541
+ * +> **Note:** A choice cannot be removed if it is assigned to one or more products.
542
+ * @param customizationId - Customization ID.
543
+ * @param choiceIds - IDs of choices to remove.
544
+ * @public
545
+ * @documentationMaturity preview
546
+ * @requiredField choiceIds
547
+ * @requiredField customizationId
548
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
549
+ * @permissionScope Customization write in v3 catalog
550
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
551
+ * @permissionScope Manage Products
552
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
553
+ * @permissionScope Product write in v3 catalog
554
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
555
+ * @permissionScope Manage v3 catalog
556
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
557
+ * @applicableIdentity APP
558
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.RemoveCustomizationChoices
559
+ */
560
+ export async function removeCustomizationChoices(customizationId, choiceIds, options) {
561
+ // @ts-ignore
562
+ const { httpClient, sideEffects } = arguments[3];
563
+ const payload = renameKeysFromSDKRequestToRESTRequest({
564
+ customizationId: customizationId,
565
+ choiceIds: choiceIds,
566
+ revision: options?.revision,
567
+ fields: options?.fields,
568
+ });
569
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.removeCustomizationChoices(payload);
570
+ sideEffects?.onSiteCall?.();
571
+ try {
572
+ const result = await httpClient.request(reqOpts);
573
+ sideEffects?.onSuccess?.(result);
574
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
575
+ {
576
+ transformFn: transformRESTImageToSDKImage,
577
+ paths: [{ path: 'customization.choicesSettings.choices.image' }],
578
+ },
579
+ ]));
580
+ }
581
+ catch (err) {
582
+ const transformedError = sdkTransformError(err, {
583
+ spreadPathsToArguments: {},
584
+ explicitPathsToArguments: {
585
+ customizationId: '$[0]',
586
+ choiceIds: '$[1]',
587
+ revision: '$[2].revision',
588
+ fields: '$[2].fields',
589
+ },
590
+ singleArgumentUnchanged: false,
591
+ }, ['customizationId', 'choiceIds', 'options']);
592
+ sideEffects?.onError?.(err);
593
+ throw transformedError;
594
+ }
595
+ }
596
+ /**
597
+ * Adds choices to multiple customizations.
598
+ * @param customizationsChoices - List of customization IDs and choices.
599
+ * @public
600
+ * @documentationMaturity preview
601
+ * @requiredField customizationsChoices
602
+ * @requiredField customizationsChoices.choices
603
+ * @requiredField customizationsChoices.customizationId
604
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
605
+ * @permissionScope Customization write in v3 catalog
606
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
607
+ * @permissionScope Manage Products
608
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
609
+ * @permissionScope Product write in v3 catalog
610
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
611
+ * @permissionScope Manage v3 catalog
612
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
613
+ * @applicableIdentity APP
614
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.BulkAddCustomizationChoices
615
+ */
616
+ export async function bulkAddCustomizationChoices(customizationsChoices, options) {
617
+ // @ts-ignore
618
+ const { httpClient, sideEffects } = arguments[2];
619
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
620
+ customizationsChoices: customizationsChoices,
621
+ returnEntity: options?.returnEntity,
622
+ fields: options?.fields,
623
+ }), [
624
+ {
625
+ transformFn: transformSDKImageToRESTImage,
626
+ paths: [{ path: 'customizationsChoices.choices.image' }],
627
+ },
628
+ ]);
629
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.bulkAddCustomizationChoices(payload);
630
+ sideEffects?.onSiteCall?.();
631
+ try {
632
+ const result = await httpClient.request(reqOpts);
633
+ sideEffects?.onSuccess?.(result);
634
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
635
+ {
636
+ transformFn: transformRESTImageToSDKImage,
637
+ paths: [
638
+ { path: 'results.customization.choicesSettings.choices.image' },
639
+ ],
640
+ },
641
+ ]));
642
+ }
643
+ catch (err) {
644
+ const transformedError = sdkTransformError(err, {
645
+ spreadPathsToArguments: {},
646
+ explicitPathsToArguments: {
647
+ customizationsChoices: '$[0]',
648
+ returnEntity: '$[1].returnEntity',
649
+ fields: '$[1].fields',
650
+ },
651
+ singleArgumentUnchanged: false,
652
+ }, ['customizationsChoices', 'options']);
653
+ sideEffects?.onError?.(err);
654
+ throw transformedError;
655
+ }
656
+ }
657
+ /**
658
+ * Updates multiple customizations.
659
+ *
660
+ * Each time the customization is updated, `revision` increments by 1.
661
+ * The current `revision` must be passed when updating the customization.
662
+ * This ensures you're working with the latest customization and prevents unintended overwrites.
663
+ * @param customizations - List of customizations to update.
664
+ * @public
665
+ * @documentationMaturity preview
666
+ * @requiredField customizations
667
+ * @requiredField customizations.customization._id
668
+ * @requiredField customizations.customization.name
669
+ * @requiredField customizations.customization.revision
670
+ * @permissionId WIX_STORES.CUSTOMIZATION_UPDATE
671
+ * @permissionScope Customization write in v3 catalog
672
+ * @permissionScopeId SCOPE.STORES.CUSTOMIZATION_WRITE
673
+ * @permissionScope Manage Products
674
+ * @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
675
+ * @permissionScope Product write in v3 catalog
676
+ * @permissionScopeId SCOPE.STORES.PRODUCT_WRITE
677
+ * @permissionScope Manage v3 catalog
678
+ * @permissionScopeId SCOPE.STORES.CATALOG_WRITE
679
+ * @applicableIdentity APP
680
+ * @fqn wix.stores.catalog.customization.v3.CustomizationService.BulkUpdateCustomizations
681
+ */
682
+ export async function bulkUpdateCustomizations(customizations, options) {
683
+ // @ts-ignore
684
+ const { httpClient, sideEffects } = arguments[2];
685
+ const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
686
+ customizations: customizations,
687
+ returnEntity: options?.returnEntity,
688
+ fields: options?.fields,
689
+ }), [
690
+ {
691
+ transformFn: transformSDKImageToRESTImage,
692
+ paths: [
693
+ {
694
+ path: 'customizations.customization.choicesSettings.choices.image',
695
+ },
696
+ ],
697
+ },
698
+ ]);
699
+ const reqOpts = ambassadorWixStoresCatalogV3Customization.bulkUpdateCustomizations(payload);
700
+ sideEffects?.onSiteCall?.();
701
+ try {
702
+ const result = await httpClient.request(reqOpts);
703
+ sideEffects?.onSuccess?.(result);
704
+ return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
705
+ {
706
+ transformFn: transformRESTImageToSDKImage,
707
+ paths: [
708
+ { path: 'results.customization.choicesSettings.choices.image' },
709
+ ],
710
+ },
711
+ ]));
712
+ }
713
+ catch (err) {
714
+ const transformedError = sdkTransformError(err, {
715
+ spreadPathsToArguments: {},
716
+ explicitPathsToArguments: {
717
+ customizations: '$[0]',
718
+ returnEntity: '$[1].returnEntity',
719
+ fields: '$[1].fields',
720
+ },
721
+ singleArgumentUnchanged: false,
722
+ }, ['customizations', 'options']);
723
+ sideEffects?.onError?.(err);
724
+ throw transformedError;
725
+ }
726
+ }
727
+ //# sourceMappingURL=stores-catalog-v3-customization-customizations-v-3.universal.js.map