@wix/pro-gallery 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.
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +24 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/src/pro-gallery-v2-gallery.http.d.ts +88 -0
- package/build/cjs/src/pro-gallery-v2-gallery.http.js +537 -0
- package/build/cjs/src/pro-gallery-v2-gallery.http.js.map +1 -0
- package/build/cjs/src/pro-gallery-v2-gallery.public.d.ts +14 -0
- package/build/cjs/src/pro-gallery-v2-gallery.public.js +73 -0
- package/build/cjs/src/pro-gallery-v2-gallery.public.js.map +1 -0
- package/build/cjs/src/pro-gallery-v2-gallery.types.d.ts +867 -0
- package/build/cjs/src/pro-gallery-v2-gallery.types.js +64 -0
- package/build/cjs/src/pro-gallery-v2-gallery.types.js.map +1 -0
- package/build/cjs/src/pro-gallery-v2-gallery.universal.d.ts +1106 -0
- package/build/cjs/src/pro-gallery-v2-gallery.universal.js +703 -0
- package/build/cjs/src/pro-gallery-v2-gallery.universal.js.map +1 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +2 -0
- package/build/es/index.js.map +1 -0
- package/build/es/src/pro-gallery-v2-gallery.http.d.ts +88 -0
- package/build/es/src/pro-gallery-v2-gallery.http.js +524 -0
- package/build/es/src/pro-gallery-v2-gallery.http.js.map +1 -0
- package/build/es/src/pro-gallery-v2-gallery.public.d.ts +14 -0
- package/build/es/src/pro-gallery-v2-gallery.public.js +53 -0
- package/build/es/src/pro-gallery-v2-gallery.public.js.map +1 -0
- package/build/es/src/pro-gallery-v2-gallery.types.d.ts +867 -0
- package/build/es/src/pro-gallery-v2-gallery.types.js +61 -0
- package/build/es/src/pro-gallery-v2-gallery.types.js.map +1 -0
- package/build/es/src/pro-gallery-v2-gallery.universal.d.ts +1106 -0
- package/build/es/src/pro-gallery-v2-gallery.universal.js +671 -0
- package/build/es/src/pro-gallery-v2-gallery.universal.js.map +1 -0
- package/package.json +37 -0
@@ -0,0 +1,671 @@
|
|
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 } from '@wix/metro-runtime/velo';
|
11
|
+
import * as ambassadorWixProGalleryV2Gallery from './pro-gallery-v2-gallery.http';
|
12
|
+
let __verbose = false;
|
13
|
+
function __log(...args) {
|
14
|
+
__verbose && console.log(...args);
|
15
|
+
}
|
16
|
+
function __inspect(obj) {
|
17
|
+
return obj;
|
18
|
+
}
|
19
|
+
export const __debug = {
|
20
|
+
verboseLogging: {
|
21
|
+
on: () => (__verbose = true),
|
22
|
+
off: () => (__verbose = false),
|
23
|
+
},
|
24
|
+
};
|
25
|
+
const _toVeloEntity = '$';
|
26
|
+
const _fromVeloEntity = '$';
|
27
|
+
export var LinkType;
|
28
|
+
(function (LinkType) {
|
29
|
+
LinkType["UNDEFINED"] = "UNDEFINED";
|
30
|
+
/** external link */
|
31
|
+
LinkType["EXTERNAL"] = "EXTERNAL";
|
32
|
+
/** for internal usage using wixLinkData */
|
33
|
+
LinkType["INTERNAL"] = "INTERNAL";
|
34
|
+
})(LinkType || (LinkType = {}));
|
35
|
+
export var Type;
|
36
|
+
(function (Type) {
|
37
|
+
Type["UNDEFINED"] = "UNDEFINED";
|
38
|
+
Type["IMAGE"] = "IMAGE";
|
39
|
+
Type["VIDEO"] = "VIDEO";
|
40
|
+
Type["TEXT"] = "TEXT";
|
41
|
+
})(Type || (Type = {}));
|
42
|
+
export var ImageType;
|
43
|
+
(function (ImageType) {
|
44
|
+
ImageType["UNDEFINED"] = "UNDEFINED";
|
45
|
+
ImageType["WIX_MEDIA"] = "WIX_MEDIA";
|
46
|
+
ImageType["EXTERNAL"] = "EXTERNAL";
|
47
|
+
})(ImageType || (ImageType = {}));
|
48
|
+
export var VideoType;
|
49
|
+
(function (VideoType) {
|
50
|
+
VideoType["UNDEFINED"] = "UNDEFINED";
|
51
|
+
VideoType["WIX_MEDIA"] = "WIX_MEDIA";
|
52
|
+
VideoType["YOUTUBE"] = "YOUTUBE";
|
53
|
+
VideoType["VIMEO"] = "VIMEO";
|
54
|
+
})(VideoType || (VideoType = {}));
|
55
|
+
export var Enum;
|
56
|
+
(function (Enum) {
|
57
|
+
/** Default value. Means that permission not set */
|
58
|
+
Enum["UNKNOWN"] = "UNKNOWN";
|
59
|
+
/** Protected exposure. Exposed to members and owners */
|
60
|
+
Enum["PROTECTED"] = "PROTECTED";
|
61
|
+
/** Private exposure. Exposed to owners */
|
62
|
+
Enum["PRIVATE"] = "PRIVATE";
|
63
|
+
/** Public exposure. Visible to everyone */
|
64
|
+
Enum["PUBLIC"] = "PUBLIC";
|
65
|
+
/** Used for partial updates, to state that exposure is not changing */
|
66
|
+
Enum["UNCHANGED"] = "UNCHANGED";
|
67
|
+
/** Protected to members of permitted groups and owners */
|
68
|
+
Enum["GROUP_PROTECTED"] = "GROUP_PROTECTED";
|
69
|
+
})(Enum || (Enum = {}));
|
70
|
+
export var SearchIndexingNotificationState;
|
71
|
+
(function (SearchIndexingNotificationState) {
|
72
|
+
/** default state */
|
73
|
+
SearchIndexingNotificationState["Unknown"] = "Unknown";
|
74
|
+
/** metasite does not require site search indexing */
|
75
|
+
SearchIndexingNotificationState["Off"] = "Off";
|
76
|
+
/** metasite requires site search indexing */
|
77
|
+
SearchIndexingNotificationState["On"] = "On";
|
78
|
+
})(SearchIndexingNotificationState || (SearchIndexingNotificationState = {}));
|
79
|
+
export var State;
|
80
|
+
(function (State) {
|
81
|
+
State["UNDEFINED"] = "UNDEFINED";
|
82
|
+
/** The gallery in the Editor segment */
|
83
|
+
State["SAVED"] = "SAVED";
|
84
|
+
/** The gallery in the LiveSite segment */
|
85
|
+
State["PUBLISHED"] = "PUBLISHED";
|
86
|
+
})(State || (State = {}));
|
87
|
+
const _createGalleryItemRequest = { item: '_item' };
|
88
|
+
const _createGalleryItemResponse = { item: '_item' };
|
89
|
+
const _createGalleryRequest = { gallery: '_gallery' };
|
90
|
+
const _createGalleryResponse = { gallery: '_gallery' };
|
91
|
+
const _deleteGalleryItemRequest = {};
|
92
|
+
const _deleteGalleryItemResponse = {};
|
93
|
+
const _deleteGalleryRequest = {};
|
94
|
+
const _deleteGalleryResponse = {};
|
95
|
+
const _gallery = { items: '_item' };
|
96
|
+
const _getGalleryItemRequest = {};
|
97
|
+
const _getGalleryItemResponse = { item: '_item' };
|
98
|
+
const _getGalleryRequest = {};
|
99
|
+
const _getGalleryResponse = { gallery: '_gallery' };
|
100
|
+
const _image = { imageInfo: 'wix.common.Image' };
|
101
|
+
const _item = {
|
102
|
+
secondaryMedia: '_secondaryMedia',
|
103
|
+
image: '_image',
|
104
|
+
video: '_video',
|
105
|
+
};
|
106
|
+
const _listGalleriesRequest = {};
|
107
|
+
const _listGalleriesResponse = { galleries: '_gallery' };
|
108
|
+
const _listGalleryItemsRequest = {};
|
109
|
+
const _listGalleryItemsResponse = { items: '_item' };
|
110
|
+
const _secondaryMedia = { image: '_image' };
|
111
|
+
const _updateGalleryItemRequest = { item: '_item' };
|
112
|
+
const _updateGalleryItemResponse = { item: '_item' };
|
113
|
+
const _updateGalleryRequest = { gallery: '_gallery' };
|
114
|
+
const _updateGalleryResponse = { gallery: '_gallery' };
|
115
|
+
const _video = { videoInfo: 'wix.common.VideoV2' };
|
116
|
+
/**
|
117
|
+
* Lists galleries.
|
118
|
+
*
|
119
|
+
* The `listGalleries()` function returns a Promise that resolves to a list of up to 10 galleries at a given time. To list the next 10 galleries in your site's backend, use the `offset` parameter.
|
120
|
+
* @public
|
121
|
+
* @param options - Options to use when getting the list of galleries.
|
122
|
+
*/
|
123
|
+
export function listGalleries(options) {
|
124
|
+
return __awaiter(this, arguments, void 0, function* () {
|
125
|
+
const requestTransformation = {
|
126
|
+
itemLimit: '$[0].itemLimit',
|
127
|
+
offset: '$[0].offset',
|
128
|
+
limit: '$[0].limit',
|
129
|
+
};
|
130
|
+
const responseTransformation = '$';
|
131
|
+
// @ts-ignore
|
132
|
+
const httpClient = arguments[1].httpClient;
|
133
|
+
const { toAmbassadorRequest } = serializer({
|
134
|
+
rootSchema: _listGalleriesRequest,
|
135
|
+
depSchemas: {},
|
136
|
+
fqdnTransformation: {
|
137
|
+
paths: [],
|
138
|
+
transformation: _fromVeloEntity,
|
139
|
+
},
|
140
|
+
customTransformation: requestTransformation,
|
141
|
+
});
|
142
|
+
const { fromJSON } = serializer({
|
143
|
+
rootSchema: _listGalleriesResponse,
|
144
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
145
|
+
fqdnTransformation: {
|
146
|
+
paths: [...['Array#galleries']],
|
147
|
+
transformation: _toVeloEntity,
|
148
|
+
},
|
149
|
+
customTransformation: responseTransformation,
|
150
|
+
});
|
151
|
+
const payload = toAmbassadorRequest([options]);
|
152
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.listGalleries(payload);
|
153
|
+
__log(`"ListGalleries" sending request with: ${__inspect(reqOpts)}`);
|
154
|
+
try {
|
155
|
+
const { data } = yield httpClient.request(reqOpts);
|
156
|
+
return fromJSON(data);
|
157
|
+
}
|
158
|
+
catch (err) {
|
159
|
+
const transformedError = transformError(err, requestTransformation, [
|
160
|
+
'options',
|
161
|
+
]);
|
162
|
+
throw transformedError;
|
163
|
+
}
|
164
|
+
});
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Gets an existing gallery by ID.
|
168
|
+
*
|
169
|
+
* The `getGallery()` function returns a Promise that resolves to a gallery whose ID matches the given ID.
|
170
|
+
* @param galleryId - Gallery ID.
|
171
|
+
* @public
|
172
|
+
* @requiredField galleryId
|
173
|
+
* @param options - Options to use when getting the gallery.
|
174
|
+
* @returns Returned gallery.
|
175
|
+
*/
|
176
|
+
export function getGallery(galleryId, options) {
|
177
|
+
return __awaiter(this, arguments, void 0, function* () {
|
178
|
+
const requestTransformation = {
|
179
|
+
galleryId: '$[0]',
|
180
|
+
itemOffset: '$[1].itemOffset',
|
181
|
+
itemLimit: '$[1].itemLimit',
|
182
|
+
};
|
183
|
+
const responseTransformation = '$.gallery';
|
184
|
+
// @ts-ignore
|
185
|
+
const httpClient = arguments[2].httpClient;
|
186
|
+
const { toAmbassadorRequest } = serializer({
|
187
|
+
rootSchema: _getGalleryRequest,
|
188
|
+
depSchemas: {},
|
189
|
+
fqdnTransformation: {
|
190
|
+
paths: [],
|
191
|
+
transformation: _fromVeloEntity,
|
192
|
+
},
|
193
|
+
customTransformation: requestTransformation,
|
194
|
+
});
|
195
|
+
const { fromJSON } = serializer({
|
196
|
+
rootSchema: _getGalleryResponse,
|
197
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
198
|
+
fqdnTransformation: {
|
199
|
+
paths: [...['gallery']],
|
200
|
+
transformation: _toVeloEntity,
|
201
|
+
},
|
202
|
+
customTransformation: responseTransformation,
|
203
|
+
});
|
204
|
+
const payload = toAmbassadorRequest([galleryId, options]);
|
205
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.getGallery(payload);
|
206
|
+
__log(`"GetGallery" sending request with: ${__inspect(reqOpts)}`);
|
207
|
+
try {
|
208
|
+
const { data } = yield httpClient.request(reqOpts);
|
209
|
+
return fromJSON(data);
|
210
|
+
}
|
211
|
+
catch (err) {
|
212
|
+
const transformedError = transformError(err, requestTransformation, [
|
213
|
+
'galleryId',
|
214
|
+
'options',
|
215
|
+
]);
|
216
|
+
throw transformedError;
|
217
|
+
}
|
218
|
+
});
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Lists media items in a specified gallery.
|
222
|
+
*
|
223
|
+
* The `listGalleryItems()` function returns a Promise that resolves to a list of up to 100 gallery items.
|
224
|
+
* @param galleryId - Gallery ID.
|
225
|
+
* @public
|
226
|
+
* @requiredField galleryId
|
227
|
+
* @param options - Options to use when getting the list of gallery items.
|
228
|
+
*/
|
229
|
+
export function listGalleryItems(galleryId, options) {
|
230
|
+
return __awaiter(this, arguments, void 0, function* () {
|
231
|
+
const requestTransformation = {
|
232
|
+
galleryId: '$[0]',
|
233
|
+
itemOffset: '$[1].itemOffset',
|
234
|
+
itemLimit: '$[1].itemLimit',
|
235
|
+
};
|
236
|
+
const responseTransformation = '$';
|
237
|
+
// @ts-ignore
|
238
|
+
const httpClient = arguments[2].httpClient;
|
239
|
+
const { toAmbassadorRequest } = serializer({
|
240
|
+
rootSchema: _listGalleryItemsRequest,
|
241
|
+
depSchemas: {},
|
242
|
+
fqdnTransformation: {
|
243
|
+
paths: [],
|
244
|
+
transformation: _fromVeloEntity,
|
245
|
+
},
|
246
|
+
customTransformation: requestTransformation,
|
247
|
+
});
|
248
|
+
const { fromJSON } = serializer({
|
249
|
+
rootSchema: _listGalleryItemsResponse,
|
250
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
251
|
+
fqdnTransformation: {
|
252
|
+
paths: [],
|
253
|
+
transformation: _toVeloEntity,
|
254
|
+
},
|
255
|
+
customTransformation: responseTransformation,
|
256
|
+
});
|
257
|
+
const payload = toAmbassadorRequest([galleryId, options]);
|
258
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.listGalleryItems(payload);
|
259
|
+
__log(`"ListGalleryItems" sending request with: ${__inspect(reqOpts)}`);
|
260
|
+
try {
|
261
|
+
const { data } = yield httpClient.request(reqOpts);
|
262
|
+
return fromJSON(data);
|
263
|
+
}
|
264
|
+
catch (err) {
|
265
|
+
const transformedError = transformError(err, requestTransformation, [
|
266
|
+
'galleryId',
|
267
|
+
'options',
|
268
|
+
]);
|
269
|
+
throw transformedError;
|
270
|
+
}
|
271
|
+
});
|
272
|
+
}
|
273
|
+
/**
|
274
|
+
* Gets an existing gallery item by ID.
|
275
|
+
*
|
276
|
+
* The `getGalleryItem()` function returns a Promise that resolves to a media item in a specified gallery whose ID matches the given ID.
|
277
|
+
* @public
|
278
|
+
* @requiredField identifiers
|
279
|
+
* @requiredField identifiers.galleryId
|
280
|
+
* @requiredField identifiers.itemId
|
281
|
+
* @param identifiers - Gallery ID and Item ID.
|
282
|
+
* @returns Returned media item.
|
283
|
+
*/
|
284
|
+
export function getGalleryItem(identifiers) {
|
285
|
+
return __awaiter(this, arguments, void 0, function* () {
|
286
|
+
const requestTransformation = {
|
287
|
+
galleryId: '$[0].galleryId',
|
288
|
+
itemId: '$[0].itemId',
|
289
|
+
};
|
290
|
+
const responseTransformation = '$.item';
|
291
|
+
// @ts-ignore
|
292
|
+
const httpClient = arguments[1].httpClient;
|
293
|
+
const { toAmbassadorRequest } = serializer({
|
294
|
+
rootSchema: _getGalleryItemRequest,
|
295
|
+
depSchemas: {},
|
296
|
+
fqdnTransformation: {
|
297
|
+
paths: [],
|
298
|
+
transformation: _fromVeloEntity,
|
299
|
+
},
|
300
|
+
customTransformation: requestTransformation,
|
301
|
+
});
|
302
|
+
const { fromJSON } = serializer({
|
303
|
+
rootSchema: _getGalleryItemResponse,
|
304
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
305
|
+
fqdnTransformation: {
|
306
|
+
paths: [],
|
307
|
+
transformation: _toVeloEntity,
|
308
|
+
},
|
309
|
+
customTransformation: responseTransformation,
|
310
|
+
});
|
311
|
+
const payload = toAmbassadorRequest([identifiers]);
|
312
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.getGalleryItem(payload);
|
313
|
+
__log(`"GetGalleryItem" sending request with: ${__inspect(reqOpts)}`);
|
314
|
+
try {
|
315
|
+
const { data } = yield httpClient.request(reqOpts);
|
316
|
+
return fromJSON(data);
|
317
|
+
}
|
318
|
+
catch (err) {
|
319
|
+
const transformedError = transformError(err, requestTransformation, [
|
320
|
+
'identifiers',
|
321
|
+
]);
|
322
|
+
throw transformedError;
|
323
|
+
}
|
324
|
+
});
|
325
|
+
}
|
326
|
+
/**
|
327
|
+
* Creates a gallery.
|
328
|
+
*
|
329
|
+
* The `createGallery()` function returns a Promise that resolves to a newly-created gallery after it has successfully been created.
|
330
|
+
*
|
331
|
+
* You can create your own gallery by providing the gallery information, or clone an existing gallery using the ID of that existing gallery. When a gallery is cloned, the newly-created gallery includes the same properties as the existing gallery except for the gallery and item IDs, sort order, and created and updated dates.
|
332
|
+
*
|
333
|
+
* The newly-created gallery is only available on your backend, and doesn't appear on your live site. To display your backend gallery on your live site, you need to connect it to a gallery component on your live site. To do this, import the `createGallery()` function to your page code, and write code to convert the backend gallery object to the frontend gallery component object. Once converted, the newly created backend gallery is visible on your live site. For reference, check out the code example, "Create a gallery and display it on your live site". To learn more, see [Displaying a Pro Gallery on Your Site Using the Pro Gallery Backend API](https://support.wix.com/en/article/velo-tutorial-displaying-a-pro-gallery-on-your-site-using-the-pro-gallery-backend-api).
|
334
|
+
*
|
335
|
+
*
|
336
|
+
* Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can create a gallery. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
337
|
+
*
|
338
|
+
* <blockquote class="important">
|
339
|
+
*
|
340
|
+
* __Important:__
|
341
|
+
* When creating `image` items in your gallery, the images must be uploaded to the [Wix Media Manager](https://support.wix.com/en/article/wix-media-uploading-media-to-the-media-manager) first as the `imageInfo` parameter currently only supports the Wix media URL.
|
342
|
+
*
|
343
|
+
* </blockquote>
|
344
|
+
* @public
|
345
|
+
* @requiredField options.gallery.items.image.imageInfo
|
346
|
+
* @requiredField options.gallery.items.text.html
|
347
|
+
* @requiredField options.gallery.items.video.videoInfo
|
348
|
+
* @param options - Options to use when creating the gallery.
|
349
|
+
* @returns Created gallery.
|
350
|
+
*/
|
351
|
+
export function createGallery(options) {
|
352
|
+
return __awaiter(this, arguments, void 0, function* () {
|
353
|
+
const requestTransformation = {
|
354
|
+
gallery: '$[0].gallery',
|
355
|
+
cloneFromGalleryId: '$[0].cloneFromGalleryId',
|
356
|
+
};
|
357
|
+
const responseTransformation = '$.gallery';
|
358
|
+
// @ts-ignore
|
359
|
+
const httpClient = arguments[1].httpClient;
|
360
|
+
const { toAmbassadorRequest } = serializer({
|
361
|
+
rootSchema: _createGalleryRequest,
|
362
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
363
|
+
fqdnTransformation: {
|
364
|
+
paths: [...['gallery']],
|
365
|
+
transformation: _fromVeloEntity,
|
366
|
+
},
|
367
|
+
customTransformation: requestTransformation,
|
368
|
+
});
|
369
|
+
const { fromJSON } = serializer({
|
370
|
+
rootSchema: _createGalleryResponse,
|
371
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
372
|
+
fqdnTransformation: {
|
373
|
+
paths: [...['gallery']],
|
374
|
+
transformation: _toVeloEntity,
|
375
|
+
},
|
376
|
+
customTransformation: responseTransformation,
|
377
|
+
});
|
378
|
+
const payload = toAmbassadorRequest([options]);
|
379
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.createGallery(payload);
|
380
|
+
__log(`"CreateGallery" sending request with: ${__inspect(reqOpts)}`);
|
381
|
+
try {
|
382
|
+
const { data } = yield httpClient.request(reqOpts);
|
383
|
+
return fromJSON(data);
|
384
|
+
}
|
385
|
+
catch (err) {
|
386
|
+
const transformedError = transformError(err, requestTransformation, [
|
387
|
+
'options',
|
388
|
+
]);
|
389
|
+
throw transformedError;
|
390
|
+
}
|
391
|
+
});
|
392
|
+
}
|
393
|
+
/**
|
394
|
+
* Updates a gallery.
|
395
|
+
*
|
396
|
+
* The `updateGallery()` function returns a Promise that resolves to an updated gallery. Only the fields in the `gallery` object parameter can be updated. Specify which fields to update. Unspecified fields remain the same.
|
397
|
+
*
|
398
|
+
* >**Note:** Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can update a gallery. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
399
|
+
* @public
|
400
|
+
* @requiredField _id
|
401
|
+
* @requiredField gallery
|
402
|
+
* @requiredField gallery.items.image.imageInfo
|
403
|
+
* @requiredField gallery.items.text.html
|
404
|
+
* @requiredField gallery.items.video.videoInfo
|
405
|
+
* @param _id - ID of the gallery to update.
|
406
|
+
* @param gallery - The information for the gallery being updated.
|
407
|
+
* @returns Updated gallery.
|
408
|
+
*/
|
409
|
+
export function updateGallery(_id, gallery) {
|
410
|
+
return __awaiter(this, arguments, void 0, function* () {
|
411
|
+
const requestTransformation = { gallery: { '*': '$[1]', id: '$[0]' } };
|
412
|
+
const responseTransformation = '$.gallery';
|
413
|
+
// @ts-ignore
|
414
|
+
const httpClient = arguments[2].httpClient;
|
415
|
+
const { toAmbassadorRequest } = serializer({
|
416
|
+
rootSchema: _updateGalleryRequest,
|
417
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
418
|
+
fqdnTransformation: {
|
419
|
+
paths: [...['gallery']],
|
420
|
+
transformation: _fromVeloEntity,
|
421
|
+
},
|
422
|
+
customTransformation: requestTransformation,
|
423
|
+
});
|
424
|
+
const { fromJSON } = serializer({
|
425
|
+
rootSchema: _updateGalleryResponse,
|
426
|
+
depSchemas: { _gallery, _image, _item, _secondaryMedia, _video },
|
427
|
+
fqdnTransformation: {
|
428
|
+
paths: [...['gallery']],
|
429
|
+
transformation: _toVeloEntity,
|
430
|
+
},
|
431
|
+
customTransformation: responseTransformation,
|
432
|
+
});
|
433
|
+
const payload = toAmbassadorRequest([_id, gallery]);
|
434
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.updateGallery(payload);
|
435
|
+
__log(`"UpdateGallery" sending request with: ${__inspect(reqOpts)}`);
|
436
|
+
try {
|
437
|
+
const { data } = yield httpClient.request(reqOpts);
|
438
|
+
return fromJSON(data);
|
439
|
+
}
|
440
|
+
catch (err) {
|
441
|
+
const transformedError = transformError(err, requestTransformation, [
|
442
|
+
'_id',
|
443
|
+
'gallery',
|
444
|
+
]);
|
445
|
+
throw transformedError;
|
446
|
+
}
|
447
|
+
});
|
448
|
+
}
|
449
|
+
/**
|
450
|
+
* Deletes a gallery.
|
451
|
+
*
|
452
|
+
* The `deleteGallery()` function returns a Promise that resolves to the ID of the deleted gallery. When a gallery is deleted, the deleted gallery is no longer returned when calling the [`listGalleries()`](#listgalleries) function.
|
453
|
+
*
|
454
|
+
* >**Note:** Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can delete a gallery. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
455
|
+
* @param galleryId - ID of the gallery to delete.
|
456
|
+
* @public
|
457
|
+
* @requiredField galleryId
|
458
|
+
*/
|
459
|
+
export function deleteGallery(galleryId) {
|
460
|
+
return __awaiter(this, arguments, void 0, function* () {
|
461
|
+
const requestTransformation = { galleryId: '$[0]' };
|
462
|
+
const responseTransformation = '$';
|
463
|
+
// @ts-ignore
|
464
|
+
const httpClient = arguments[1].httpClient;
|
465
|
+
const { toAmbassadorRequest } = serializer({
|
466
|
+
rootSchema: _deleteGalleryRequest,
|
467
|
+
depSchemas: {},
|
468
|
+
fqdnTransformation: {
|
469
|
+
paths: [],
|
470
|
+
transformation: _fromVeloEntity,
|
471
|
+
},
|
472
|
+
customTransformation: requestTransformation,
|
473
|
+
});
|
474
|
+
const { fromJSON } = serializer({
|
475
|
+
rootSchema: _deleteGalleryResponse,
|
476
|
+
depSchemas: {},
|
477
|
+
fqdnTransformation: {
|
478
|
+
paths: [],
|
479
|
+
transformation: _toVeloEntity,
|
480
|
+
},
|
481
|
+
customTransformation: responseTransformation,
|
482
|
+
});
|
483
|
+
const payload = toAmbassadorRequest([galleryId]);
|
484
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.deleteGallery(payload);
|
485
|
+
__log(`"DeleteGallery" sending request with: ${__inspect(reqOpts)}`);
|
486
|
+
try {
|
487
|
+
const { data } = yield httpClient.request(reqOpts);
|
488
|
+
return fromJSON(data);
|
489
|
+
}
|
490
|
+
catch (err) {
|
491
|
+
const transformedError = transformError(err, requestTransformation, [
|
492
|
+
'galleryId',
|
493
|
+
]);
|
494
|
+
throw transformedError;
|
495
|
+
}
|
496
|
+
});
|
497
|
+
}
|
498
|
+
/**
|
499
|
+
* Creates a media item in a specified gallery.
|
500
|
+
*
|
501
|
+
* The `createGalleryItem()` function returns a Promise that resolves to a newly-created gallery item after it has successfully been created.
|
502
|
+
*
|
503
|
+
* When creating `image` items, the images in your gallery must be uploaded to the [Wix Media Manager](https://support.wix.com/en/article/wix-media-uploading-media-to-the-media-manager) first as the `imageInfo` parameter currently only supports the Wix media URL.
|
504
|
+
*
|
505
|
+
* >**Note:** Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can create a gallery item. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
506
|
+
* @param galleryId - Gallery ID.
|
507
|
+
* @param item - Media item to create.
|
508
|
+
* @public
|
509
|
+
* @requiredField galleryId
|
510
|
+
* @requiredField item
|
511
|
+
* @requiredField item.image.imageInfo
|
512
|
+
* @requiredField item.text.html
|
513
|
+
* @requiredField item.video.videoInfo
|
514
|
+
* @returns Created media item.
|
515
|
+
*/
|
516
|
+
export function createGalleryItem(galleryId, item) {
|
517
|
+
return __awaiter(this, arguments, void 0, function* () {
|
518
|
+
const requestTransformation = { galleryId: '$[0]', item: '$[1]' };
|
519
|
+
const responseTransformation = '$.item';
|
520
|
+
// @ts-ignore
|
521
|
+
const httpClient = arguments[2].httpClient;
|
522
|
+
const { toAmbassadorRequest } = serializer({
|
523
|
+
rootSchema: _createGalleryItemRequest,
|
524
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
525
|
+
fqdnTransformation: {
|
526
|
+
paths: [],
|
527
|
+
transformation: _fromVeloEntity,
|
528
|
+
},
|
529
|
+
customTransformation: requestTransformation,
|
530
|
+
});
|
531
|
+
const { fromJSON } = serializer({
|
532
|
+
rootSchema: _createGalleryItemResponse,
|
533
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
534
|
+
fqdnTransformation: {
|
535
|
+
paths: [],
|
536
|
+
transformation: _toVeloEntity,
|
537
|
+
},
|
538
|
+
customTransformation: responseTransformation,
|
539
|
+
});
|
540
|
+
const payload = toAmbassadorRequest([galleryId, item]);
|
541
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.createGalleryItem(payload);
|
542
|
+
__log(`"CreateGalleryItem" sending request with: ${__inspect(reqOpts)}`);
|
543
|
+
try {
|
544
|
+
const { data } = yield httpClient.request(reqOpts);
|
545
|
+
return fromJSON(data);
|
546
|
+
}
|
547
|
+
catch (err) {
|
548
|
+
const transformedError = transformError(err, requestTransformation, [
|
549
|
+
'galleryId',
|
550
|
+
'item',
|
551
|
+
]);
|
552
|
+
throw transformedError;
|
553
|
+
}
|
554
|
+
});
|
555
|
+
}
|
556
|
+
/**
|
557
|
+
* Updates a media item in a specified gallery.
|
558
|
+
*
|
559
|
+
* The `updateGalleryItem()` function returns a Promise that resolves to an updated gallery item. Only the fields in the `item` object parameter can be updated. Specify which fields to update. Unspecified fields remain the same.
|
560
|
+
*
|
561
|
+
* >**Note:** Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can update a gallery item. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
562
|
+
* @public
|
563
|
+
* @requiredField identifiers
|
564
|
+
* @requiredField identifiers.galleryId
|
565
|
+
* @requiredField identifiers.itemId
|
566
|
+
* @requiredField item
|
567
|
+
* @requiredField item.image.imageInfo
|
568
|
+
* @requiredField item.text.html
|
569
|
+
* @requiredField item.video.videoInfo
|
570
|
+
* @param item - The information for the gallery item being updated.
|
571
|
+
* @param identifiers - Gallery ID and Item ID.
|
572
|
+
* @returns Updated media item.
|
573
|
+
*/
|
574
|
+
export function updateGalleryItem(identifiers, item) {
|
575
|
+
return __awaiter(this, arguments, void 0, function* () {
|
576
|
+
const requestTransformation = {
|
577
|
+
galleryId: '$[0].galleryId',
|
578
|
+
item: { '*': '$[1]', id: '$[0].itemId' },
|
579
|
+
};
|
580
|
+
const responseTransformation = '$.item';
|
581
|
+
// @ts-ignore
|
582
|
+
const httpClient = arguments[2].httpClient;
|
583
|
+
const { toAmbassadorRequest } = serializer({
|
584
|
+
rootSchema: _updateGalleryItemRequest,
|
585
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
586
|
+
fqdnTransformation: {
|
587
|
+
paths: [],
|
588
|
+
transformation: _fromVeloEntity,
|
589
|
+
},
|
590
|
+
customTransformation: requestTransformation,
|
591
|
+
});
|
592
|
+
const { fromJSON } = serializer({
|
593
|
+
rootSchema: _updateGalleryItemResponse,
|
594
|
+
depSchemas: { _image, _item, _secondaryMedia, _video },
|
595
|
+
fqdnTransformation: {
|
596
|
+
paths: [],
|
597
|
+
transformation: _toVeloEntity,
|
598
|
+
},
|
599
|
+
customTransformation: responseTransformation,
|
600
|
+
});
|
601
|
+
const payload = toAmbassadorRequest([identifiers, item]);
|
602
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.updateGalleryItem(payload);
|
603
|
+
__log(`"UpdateGalleryItem" sending request with: ${__inspect(reqOpts)}`);
|
604
|
+
try {
|
605
|
+
const { data } = yield httpClient.request(reqOpts);
|
606
|
+
return fromJSON(data);
|
607
|
+
}
|
608
|
+
catch (err) {
|
609
|
+
const transformedError = transformError(err, requestTransformation, [
|
610
|
+
'identifiers',
|
611
|
+
'item',
|
612
|
+
]);
|
613
|
+
throw transformedError;
|
614
|
+
}
|
615
|
+
});
|
616
|
+
}
|
617
|
+
/**
|
618
|
+
* Deletes a media item from a gallery.
|
619
|
+
*
|
620
|
+
* The `deleteGalleryItem()` function returns a Promise that resolves to the ID of the deleted gallery item. When a gallery item is deleted, the deleted gallery item is no longer returned when calling the [`listGalleryItems()`](#listgalleryitems) function.
|
621
|
+
*
|
622
|
+
* >**Note:** Only [site admins](https://support.wix.com/en/article/roles-permissions-overview) can delete a gallery item. You can override the permissions with the `wix-auth` [`elevate()`](https://www.wix.com/velo/reference/wix-auth/elevate) function.
|
623
|
+
* @public
|
624
|
+
* @requiredField identifiers
|
625
|
+
* @requiredField identifiers.galleryId
|
626
|
+
* @requiredField identifiers.itemId
|
627
|
+
* @param identifiers - Gallery ID and Item ID.
|
628
|
+
*/
|
629
|
+
export function deleteGalleryItem(identifiers) {
|
630
|
+
return __awaiter(this, arguments, void 0, function* () {
|
631
|
+
const requestTransformation = {
|
632
|
+
galleryId: '$[0].galleryId',
|
633
|
+
itemId: '$[0].itemId',
|
634
|
+
};
|
635
|
+
const responseTransformation = '$';
|
636
|
+
// @ts-ignore
|
637
|
+
const httpClient = arguments[1].httpClient;
|
638
|
+
const { toAmbassadorRequest } = serializer({
|
639
|
+
rootSchema: _deleteGalleryItemRequest,
|
640
|
+
depSchemas: {},
|
641
|
+
fqdnTransformation: {
|
642
|
+
paths: [],
|
643
|
+
transformation: _fromVeloEntity,
|
644
|
+
},
|
645
|
+
customTransformation: requestTransformation,
|
646
|
+
});
|
647
|
+
const { fromJSON } = serializer({
|
648
|
+
rootSchema: _deleteGalleryItemResponse,
|
649
|
+
depSchemas: {},
|
650
|
+
fqdnTransformation: {
|
651
|
+
paths: [],
|
652
|
+
transformation: _toVeloEntity,
|
653
|
+
},
|
654
|
+
customTransformation: responseTransformation,
|
655
|
+
});
|
656
|
+
const payload = toAmbassadorRequest([identifiers]);
|
657
|
+
const reqOpts = ambassadorWixProGalleryV2Gallery.deleteGalleryItem(payload);
|
658
|
+
__log(`"DeleteGalleryItem" sending request with: ${__inspect(reqOpts)}`);
|
659
|
+
try {
|
660
|
+
const { data } = yield httpClient.request(reqOpts);
|
661
|
+
return fromJSON(data);
|
662
|
+
}
|
663
|
+
catch (err) {
|
664
|
+
const transformedError = transformError(err, requestTransformation, [
|
665
|
+
'identifiers',
|
666
|
+
]);
|
667
|
+
throw transformedError;
|
668
|
+
}
|
669
|
+
});
|
670
|
+
}
|
671
|
+
//# sourceMappingURL=pro-gallery-v2-gallery.universal.js.map
|