@wix/media 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 (55) hide show
  1. package/build/cjs/index.d.ts +2 -0
  2. package/build/cjs/index.js +25 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/src/media-site-media-v1-file-descriptor.http.d.ts +107 -0
  5. package/build/cjs/src/media-site-media-v1-file-descriptor.http.js +555 -0
  6. package/build/cjs/src/media-site-media-v1-file-descriptor.http.js.map +1 -0
  7. package/build/cjs/src/media-site-media-v1-file-descriptor.public.d.ts +18 -0
  8. package/build/cjs/src/media-site-media-v1-file-descriptor.public.js +97 -0
  9. package/build/cjs/src/media-site-media-v1-file-descriptor.public.js.map +1 -0
  10. package/build/cjs/src/media-site-media-v1-file-descriptor.types.d.ts +562 -0
  11. package/build/cjs/src/media-site-media-v1-file-descriptor.types.js +52 -0
  12. package/build/cjs/src/media-site-media-v1-file-descriptor.types.js.map +1 -0
  13. package/build/cjs/src/media-site-media-v1-file-descriptor.universal.d.ts +845 -0
  14. package/build/cjs/src/media-site-media-v1-file-descriptor.universal.js +962 -0
  15. package/build/cjs/src/media-site-media-v1-file-descriptor.universal.js.map +1 -0
  16. package/build/cjs/src/media-site-media-v1-folder.http.d.ts +49 -0
  17. package/build/cjs/src/media-site-media-v1-folder.http.js +285 -0
  18. package/build/cjs/src/media-site-media-v1-folder.http.js.map +1 -0
  19. package/build/cjs/src/media-site-media-v1-folder.public.d.ts +13 -0
  20. package/build/cjs/src/media-site-media-v1-folder.public.js +63 -0
  21. package/build/cjs/src/media-site-media-v1-folder.public.js.map +1 -0
  22. package/build/cjs/src/media-site-media-v1-folder.types.d.ts +179 -0
  23. package/build/cjs/src/media-site-media-v1-folder.types.js +23 -0
  24. package/build/cjs/src/media-site-media-v1-folder.types.js.map +1 -0
  25. package/build/cjs/src/media-site-media-v1-folder.universal.d.ts +337 -0
  26. package/build/cjs/src/media-site-media-v1-folder.universal.js +584 -0
  27. package/build/cjs/src/media-site-media-v1-folder.universal.js.map +1 -0
  28. package/build/es/index.d.ts +2 -0
  29. package/build/es/index.js +3 -0
  30. package/build/es/index.js.map +1 -0
  31. package/build/es/src/media-site-media-v1-file-descriptor.http.d.ts +107 -0
  32. package/build/es/src/media-site-media-v1-file-descriptor.http.js +538 -0
  33. package/build/es/src/media-site-media-v1-file-descriptor.http.js.map +1 -0
  34. package/build/es/src/media-site-media-v1-file-descriptor.public.d.ts +18 -0
  35. package/build/es/src/media-site-media-v1-file-descriptor.public.js +73 -0
  36. package/build/es/src/media-site-media-v1-file-descriptor.public.js.map +1 -0
  37. package/build/es/src/media-site-media-v1-file-descriptor.types.d.ts +562 -0
  38. package/build/es/src/media-site-media-v1-file-descriptor.types.js +49 -0
  39. package/build/es/src/media-site-media-v1-file-descriptor.types.js.map +1 -0
  40. package/build/es/src/media-site-media-v1-file-descriptor.universal.d.ts +845 -0
  41. package/build/es/src/media-site-media-v1-file-descriptor.universal.js +926 -0
  42. package/build/es/src/media-site-media-v1-file-descriptor.universal.js.map +1 -0
  43. package/build/es/src/media-site-media-v1-folder.http.d.ts +49 -0
  44. package/build/es/src/media-site-media-v1-folder.http.js +273 -0
  45. package/build/es/src/media-site-media-v1-folder.http.js.map +1 -0
  46. package/build/es/src/media-site-media-v1-folder.public.d.ts +13 -0
  47. package/build/es/src/media-site-media-v1-folder.public.js +48 -0
  48. package/build/es/src/media-site-media-v1-folder.public.js.map +1 -0
  49. package/build/es/src/media-site-media-v1-folder.types.d.ts +179 -0
  50. package/build/es/src/media-site-media-v1-folder.types.js +20 -0
  51. package/build/es/src/media-site-media-v1-folder.types.js.map +1 -0
  52. package/build/es/src/media-site-media-v1-folder.universal.d.ts +337 -0
  53. package/build/es/src/media-site-media-v1-folder.universal.js +553 -0
  54. package/build/es/src/media-site-media-v1-folder.universal.js.map +1 -0
  55. package/package.json +37 -0
@@ -0,0 +1,962 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.listDeletedFiles = exports.bulkRestoreFilesFromTrashBin = exports.bulkDeleteFiles = exports.generateVideoStreamingUrl = exports.searchFiles = exports.listFiles = exports.bulkImportFiles = exports.importFile = exports.generateFileResumableUploadUrl = exports.generateFileUploadUrl = exports.updateFile = exports.getFileDescriptor = exports.generateFileDownloadUrl = exports.generateFilesDownloadUrl = exports.StreamFormat = exports.RootFolder = exports.SortOrder = exports.UploadProtocol = exports.State = exports.OperationStatus = exports.MediaType = exports.__debug = void 0;
32
+ const velo_1 = require("@wix/metro-runtime/velo");
33
+ const ambassadorWixMediaSiteMediaV1FileDescriptor = __importStar(require("./media-site-media-v1-file-descriptor.http"));
34
+ let __verbose = false;
35
+ function __log(...args) {
36
+ __verbose && console.log(...args);
37
+ }
38
+ function __inspect(obj) {
39
+ return obj;
40
+ }
41
+ exports.__debug = {
42
+ verboseLogging: {
43
+ on: () => (__verbose = true),
44
+ off: () => (__verbose = false),
45
+ },
46
+ };
47
+ const _toVeloEntity = '$';
48
+ const _fromVeloEntity = '$';
49
+ var MediaType;
50
+ (function (MediaType) {
51
+ MediaType["UNKNOWN"] = "UNKNOWN";
52
+ MediaType["IMAGE"] = "IMAGE";
53
+ MediaType["VIDEO"] = "VIDEO";
54
+ MediaType["AUDIO"] = "AUDIO";
55
+ MediaType["DOCUMENT"] = "DOCUMENT";
56
+ MediaType["VECTOR"] = "VECTOR";
57
+ })(MediaType = exports.MediaType || (exports.MediaType = {}));
58
+ var OperationStatus;
59
+ (function (OperationStatus) {
60
+ /** File upload or processing failed */
61
+ OperationStatus["FAILED"] = "FAILED";
62
+ /** File is ready for consumption */
63
+ OperationStatus["READY"] = "READY";
64
+ /** File is waiting for processing or currently being processed */
65
+ OperationStatus["PENDING"] = "PENDING";
66
+ })(OperationStatus = exports.OperationStatus || (exports.OperationStatus = {}));
67
+ var State;
68
+ (function (State) {
69
+ State["OK"] = "OK";
70
+ State["DELETED"] = "DELETED";
71
+ })(State = exports.State || (exports.State = {}));
72
+ var UploadProtocol;
73
+ (function (UploadProtocol) {
74
+ /** The upload protocol to use for implementing the resumable upload. */
75
+ UploadProtocol["TUS"] = "TUS";
76
+ })(UploadProtocol = exports.UploadProtocol || (exports.UploadProtocol = {}));
77
+ var SortOrder;
78
+ (function (SortOrder) {
79
+ SortOrder["ASC"] = "ASC";
80
+ SortOrder["DESC"] = "DESC";
81
+ })(SortOrder = exports.SortOrder || (exports.SortOrder = {}));
82
+ var RootFolder;
83
+ (function (RootFolder) {
84
+ /** Root of all site media */
85
+ RootFolder["MEDIA_ROOT"] = "MEDIA_ROOT";
86
+ /** Root of the trash system folder */
87
+ RootFolder["TRASH_ROOT"] = "TRASH_ROOT";
88
+ /** Root of all visitor uploads */
89
+ RootFolder["VISITOR_UPLOADS_ROOT"] = "VISITOR_UPLOADS_ROOT";
90
+ })(RootFolder = exports.RootFolder || (exports.RootFolder = {}));
91
+ var StreamFormat;
92
+ (function (StreamFormat) {
93
+ StreamFormat["UNKNOWN"] = "UNKNOWN";
94
+ StreamFormat["HLS"] = "HLS";
95
+ StreamFormat["DASH"] = "DASH";
96
+ })(StreamFormat = exports.StreamFormat || (exports.StreamFormat = {}));
97
+ const _audioV2 = { assets: 'wix.common.Audio' };
98
+ const _bulkDeleteFilesRequest = {};
99
+ const _bulkDeleteFilesResponse = {};
100
+ const _bulkImportFilesRequest = { importFileRequests: '_importFileRequest' };
101
+ const _bulkImportFilesResponse = { files: '_fileDescriptor' };
102
+ const _bulkRestoreFilesFromTrashBinRequest = {};
103
+ const _bulkRestoreFilesFromTrashBinResponse = {};
104
+ const _fileDescriptor = { media: '_fileMedia' };
105
+ const _fileMedia = {
106
+ video: 'wix.common.VideoV2',
107
+ document: 'wix.common.Document',
108
+ image: '_imageMedia',
109
+ audio: '_audioV2',
110
+ vector: '_imageMedia',
111
+ };
112
+ const _generateFileDownloadUrlRequest = {};
113
+ const _generateFileDownloadUrlResponse = {};
114
+ const _generateFileResumableUploadUrlRequest = {};
115
+ const _generateFileResumableUploadUrlResponse = {};
116
+ const _generateFilesDownloadUrlRequest = {};
117
+ const _generateFilesDownloadUrlResponse = {};
118
+ const _generateFileUploadUrlRequest = {};
119
+ const _generateFileUploadUrlResponse = {};
120
+ const _generateVideoStreamingUrlRequest = {};
121
+ const _generateVideoStreamingUrlResponse = {};
122
+ const _getFileDescriptorRequest = {};
123
+ const _getFileDescriptorResponse = { file: '_fileDescriptor' };
124
+ const _imageMedia = {
125
+ image: 'wix.common.Image',
126
+ previewImage: 'wix.common.Image',
127
+ };
128
+ const _importFileRequest = {};
129
+ const _importFileResponse = { file: '_fileDescriptor' };
130
+ const _listDeletedFilesRequest = {};
131
+ const _listDeletedFilesResponse = { files: '_fileDescriptor' };
132
+ const _listFilesRequest = {};
133
+ const _listFilesResponse = { files: '_fileDescriptor' };
134
+ const _searchFilesRequest = {};
135
+ const _searchFilesResponse = { files: '_fileDescriptor' };
136
+ const _updateFileRequest = {};
137
+ const _updateFileResponse = { file: '_fileDescriptor' };
138
+ /**
139
+ * Generates a URL for downloading a compressed file containing specific files in the Media Manager. <br/>
140
+ *
141
+ * The compressed file can contain up to 1000 files.
142
+ * @param fileIds - IDs of the files to download.
143
+ * @public
144
+ * @documentationMaturity preview
145
+ * @requiredField fileIds
146
+ */
147
+ function generateFilesDownloadUrl(fileIds) {
148
+ var _a, _b, _c;
149
+ return __awaiter(this, arguments, void 0, function* () {
150
+ const requestTransformation = { fileIds: '$[0]' };
151
+ const responseTransformation = '$';
152
+ // @ts-ignore
153
+ const { httpClient, sideEffects } = arguments[1];
154
+ const { toAmbassadorRequest } = velo_1.serializer({
155
+ rootSchema: _generateFilesDownloadUrlRequest,
156
+ depSchemas: {},
157
+ fqdnTransformation: {
158
+ paths: [],
159
+ transformation: _fromVeloEntity,
160
+ },
161
+ customTransformation: requestTransformation,
162
+ });
163
+ const { fromJSON } = velo_1.serializer({
164
+ rootSchema: _generateFilesDownloadUrlResponse,
165
+ depSchemas: {},
166
+ fqdnTransformation: {
167
+ paths: [],
168
+ transformation: _toVeloEntity,
169
+ },
170
+ customTransformation: responseTransformation,
171
+ });
172
+ const payload = toAmbassadorRequest([fileIds]);
173
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.generateFilesDownloadUrl(payload);
174
+ __log(`"GenerateFilesDownloadUrl" sending request with: ${__inspect(reqOpts)}`);
175
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
176
+ try {
177
+ const result = yield httpClient.request(reqOpts);
178
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
179
+ return fromJSON(result.data);
180
+ }
181
+ catch (err) {
182
+ const transformedError = velo_1.transformError(err, requestTransformation, [
183
+ 'fileIds',
184
+ ]);
185
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
186
+ throw transformedError;
187
+ }
188
+ });
189
+ }
190
+ exports.generateFilesDownloadUrl = generateFilesDownloadUrl;
191
+ /**
192
+ * Generates one or more temporary URLs for downloading a specific file in the Media Manager.
193
+ *
194
+ * To download different assets of the file, use the `assetKeys` parameter which generates a download URL for each asset.
195
+ * If no `assetKey` is specified, it defaults to `src`, which generates one download URL in the original file's format and quality.
196
+ *
197
+ * Use this endpoint to grant external clients access to a private media file. Use the `expirationInMinutes` parameter to set the URL expiration time, and the `expirationRedirectUrl` parameter to add a redirect url when the URL expires.
198
+ * @param fileId - File ID.
199
+ * @public
200
+ * @documentationMaturity preview
201
+ * @requiredField fileId
202
+ */
203
+ function generateFileDownloadUrl(fileId, options) {
204
+ var _a, _b, _c;
205
+ return __awaiter(this, arguments, void 0, function* () {
206
+ const requestTransformation = {
207
+ fileId: '$[0]',
208
+ downloadFileName: '$[1].downloadFileName',
209
+ expirationInMinutes: '$[1].expirationInMinutes',
210
+ expirationRedirectUrl: '$[1].expirationRedirectUrl',
211
+ assetKeys: '$[1].assetKeys',
212
+ };
213
+ const responseTransformation = '$';
214
+ // @ts-ignore
215
+ const { httpClient, sideEffects } = arguments[2];
216
+ const { toAmbassadorRequest } = velo_1.serializer({
217
+ rootSchema: _generateFileDownloadUrlRequest,
218
+ depSchemas: {},
219
+ fqdnTransformation: {
220
+ paths: [],
221
+ transformation: _fromVeloEntity,
222
+ },
223
+ customTransformation: requestTransformation,
224
+ });
225
+ const { fromJSON } = velo_1.serializer({
226
+ rootSchema: _generateFileDownloadUrlResponse,
227
+ depSchemas: {},
228
+ fqdnTransformation: {
229
+ paths: [],
230
+ transformation: _toVeloEntity,
231
+ },
232
+ customTransformation: responseTransformation,
233
+ });
234
+ const payload = toAmbassadorRequest([fileId, options]);
235
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.generateFileDownloadUrl(payload);
236
+ __log(`"GenerateFileDownloadUrl" sending request with: ${__inspect(reqOpts)}`);
237
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
238
+ try {
239
+ const result = yield httpClient.request(reqOpts);
240
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
241
+ return fromJSON(result.data);
242
+ }
243
+ catch (err) {
244
+ const transformedError = velo_1.transformError(err, requestTransformation, [
245
+ 'fileId',
246
+ 'options',
247
+ ]);
248
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
249
+ throw transformedError;
250
+ }
251
+ });
252
+ }
253
+ exports.generateFileDownloadUrl = generateFileDownloadUrl;
254
+ /**
255
+ * Gets information about a specific file in the Media Manager.
256
+ * @param fileId - File ID.
257
+ * @public
258
+ * @documentationMaturity preview
259
+ * @requiredField fileId
260
+ */
261
+ function getFileDescriptor(fileId) {
262
+ var _a, _b, _c;
263
+ return __awaiter(this, arguments, void 0, function* () {
264
+ const requestTransformation = { fileId: '$[0]' };
265
+ const responseTransformation = '$';
266
+ // @ts-ignore
267
+ const { httpClient, sideEffects } = arguments[1];
268
+ const { toAmbassadorRequest } = velo_1.serializer({
269
+ rootSchema: _getFileDescriptorRequest,
270
+ depSchemas: {},
271
+ fqdnTransformation: {
272
+ paths: [],
273
+ transformation: _fromVeloEntity,
274
+ },
275
+ customTransformation: requestTransformation,
276
+ });
277
+ const { fromJSON } = velo_1.serializer({
278
+ rootSchema: _getFileDescriptorResponse,
279
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
280
+ fqdnTransformation: {
281
+ paths: [...['file']],
282
+ transformation: _toVeloEntity,
283
+ },
284
+ customTransformation: responseTransformation,
285
+ });
286
+ const payload = toAmbassadorRequest([fileId]);
287
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.getFileDescriptor(payload);
288
+ __log(`"GetFileDescriptor" sending request with: ${__inspect(reqOpts)}`);
289
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
290
+ try {
291
+ const result = yield httpClient.request(reqOpts);
292
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
293
+ return fromJSON(result.data);
294
+ }
295
+ catch (err) {
296
+ const transformedError = velo_1.transformError(err, requestTransformation, [
297
+ 'fileId',
298
+ ]);
299
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
300
+ throw transformedError;
301
+ }
302
+ });
303
+ }
304
+ exports.getFileDescriptor = getFileDescriptor;
305
+ /**
306
+ * Updates a file. <br />
307
+ *
308
+ * You can use the `parentFolderId` parameter to move a file from its current folder to a different folder.
309
+ * @param fileId - ID of the file to update.
310
+ * @public
311
+ * @documentationMaturity preview
312
+ * @requiredField fileId
313
+ */
314
+ function updateFile(fileId, options) {
315
+ var _a, _b, _c;
316
+ return __awaiter(this, arguments, void 0, function* () {
317
+ const requestTransformation = {
318
+ fileId: '$[0]',
319
+ displayName: '$[1].displayName',
320
+ parentFolderId: '$[1].parentFolderId',
321
+ labels: '$[1].labels',
322
+ };
323
+ const responseTransformation = '$';
324
+ // @ts-ignore
325
+ const { httpClient, sideEffects } = arguments[2];
326
+ const { toAmbassadorRequest } = velo_1.serializer({
327
+ rootSchema: _updateFileRequest,
328
+ depSchemas: {},
329
+ fqdnTransformation: {
330
+ paths: [],
331
+ transformation: _fromVeloEntity,
332
+ },
333
+ customTransformation: requestTransformation,
334
+ });
335
+ const { fromJSON } = velo_1.serializer({
336
+ rootSchema: _updateFileResponse,
337
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
338
+ fqdnTransformation: {
339
+ paths: [...['file']],
340
+ transformation: _toVeloEntity,
341
+ },
342
+ customTransformation: responseTransformation,
343
+ });
344
+ const payload = toAmbassadorRequest([fileId, options]);
345
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.updateFile(payload);
346
+ __log(`"UpdateFile" sending request with: ${__inspect(reqOpts)}`);
347
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
348
+ try {
349
+ const result = yield httpClient.request(reqOpts);
350
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
351
+ return fromJSON(result.data);
352
+ }
353
+ catch (err) {
354
+ const transformedError = velo_1.transformError(err, requestTransformation, [
355
+ 'fileId',
356
+ 'options',
357
+ ]);
358
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
359
+ throw transformedError;
360
+ }
361
+ });
362
+ }
363
+ exports.updateFile = updateFile;
364
+ /**
365
+ * Generates an upload URL to allow external clients to upload a file to the Media Manager. <br/>
366
+ *
367
+ * To learn how external clients can use the generated upload URL in the response to upload a file to the Media Manager, see [Using the Upload Url](#upload-api) article.
368
+ * >**Note:** Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, use the [Generate File Resumable Upload Url](https://dev.wix.com/api/rest/all-apis/site-media---media-manager-backend/files/generate-file-resumable-upload-url) instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption.
369
+ * @param mimeType - File mime type.
370
+ * @public
371
+ * @documentationMaturity preview
372
+ * @requiredField mimeType
373
+ */
374
+ function generateFileUploadUrl(mimeType, options) {
375
+ var _a, _b, _c;
376
+ return __awaiter(this, arguments, void 0, function* () {
377
+ const requestTransformation = {
378
+ mimeType: '$[0]',
379
+ fileName: '$[1].fileName',
380
+ sizeInBytes: '$[1].sizeInBytes',
381
+ parentFolderId: '$[1].parentFolderId',
382
+ private: '$[1].private',
383
+ labels: '$[1].labels',
384
+ externalInfo: '$[1].externalInfo',
385
+ };
386
+ const responseTransformation = '$';
387
+ // @ts-ignore
388
+ const { httpClient, sideEffects } = arguments[2];
389
+ const { toAmbassadorRequest } = velo_1.serializer({
390
+ rootSchema: _generateFileUploadUrlRequest,
391
+ depSchemas: {},
392
+ fqdnTransformation: {
393
+ paths: [],
394
+ transformation: _fromVeloEntity,
395
+ },
396
+ customTransformation: requestTransformation,
397
+ });
398
+ const { fromJSON } = velo_1.serializer({
399
+ rootSchema: _generateFileUploadUrlResponse,
400
+ depSchemas: {},
401
+ fqdnTransformation: {
402
+ paths: [],
403
+ transformation: _toVeloEntity,
404
+ },
405
+ customTransformation: responseTransformation,
406
+ });
407
+ const payload = toAmbassadorRequest([mimeType, options]);
408
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.generateFileUploadUrl(payload);
409
+ __log(`"GenerateFileUploadUrl" sending request with: ${__inspect(reqOpts)}`);
410
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
411
+ try {
412
+ const result = yield httpClient.request(reqOpts);
413
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
414
+ return fromJSON(result.data);
415
+ }
416
+ catch (err) {
417
+ const transformedError = velo_1.transformError(err, requestTransformation, [
418
+ 'mimeType',
419
+ 'options',
420
+ ]);
421
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
422
+ throw transformedError;
423
+ }
424
+ });
425
+ }
426
+ exports.generateFileUploadUrl = generateFileUploadUrl;
427
+ /**
428
+ * Generates a resumable upload URL to allow external clients to easily upload large files over 10MB to the Media Manager. <br/>
429
+ *
430
+ * With the resumable upload URL, any interruptions in the upload process pauses the file upload, and resumes the file upload process after the interruption. The resumable upload URL is also helpful when network connection is poor.
431
+ * To learn how external clients can use the generated upload URL in the response to upload large files to the Media Manager, see [Using the Resumable Upload Url](#upload-api) article.
432
+ * @param mimeType - File mime type.
433
+ * @public
434
+ * @documentationMaturity preview
435
+ * @requiredField mimeType
436
+ */
437
+ function generateFileResumableUploadUrl(mimeType, options) {
438
+ var _a, _b, _c;
439
+ return __awaiter(this, arguments, void 0, function* () {
440
+ const requestTransformation = {
441
+ mimeType: '$[0]',
442
+ fileName: '$[1].fileName',
443
+ sizeInBytes: '$[1].sizeInBytes',
444
+ parentFolderId: '$[1].parentFolderId',
445
+ private: '$[1].private',
446
+ labels: '$[1].labels',
447
+ uploadProtocol: '$[1].uploadProtocol',
448
+ };
449
+ const responseTransformation = '$';
450
+ // @ts-ignore
451
+ const { httpClient, sideEffects } = arguments[2];
452
+ const { toAmbassadorRequest } = velo_1.serializer({
453
+ rootSchema: _generateFileResumableUploadUrlRequest,
454
+ depSchemas: {},
455
+ fqdnTransformation: {
456
+ paths: [],
457
+ transformation: _fromVeloEntity,
458
+ },
459
+ customTransformation: requestTransformation,
460
+ });
461
+ const { fromJSON } = velo_1.serializer({
462
+ rootSchema: _generateFileResumableUploadUrlResponse,
463
+ depSchemas: {},
464
+ fqdnTransformation: {
465
+ paths: [],
466
+ transformation: _toVeloEntity,
467
+ },
468
+ customTransformation: responseTransformation,
469
+ });
470
+ const payload = toAmbassadorRequest([mimeType, options]);
471
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.generateFileResumableUploadUrl(payload);
472
+ __log(`"GenerateFileResumableUploadUrl" sending request with: ${__inspect(reqOpts)}`);
473
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
474
+ try {
475
+ const result = yield httpClient.request(reqOpts);
476
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
477
+ return fromJSON(result.data);
478
+ }
479
+ catch (err) {
480
+ const transformedError = velo_1.transformError(err, requestTransformation, [
481
+ 'mimeType',
482
+ 'options',
483
+ ]);
484
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
485
+ throw transformedError;
486
+ }
487
+ });
488
+ }
489
+ exports.generateFileResumableUploadUrl = generateFileResumableUploadUrl;
490
+ /**
491
+ * Imports a file to the Media Manager using an external url.
492
+ *
493
+ * Returns information about the imported file.
494
+ * Use the `parentFolderId` parameter to specify which folder you want the file to be imported to.
495
+ * If no folder is specified, the file is imported to the `media-root` folder.
496
+ *
497
+ * To import a file, you need to provide one of the following:
498
+ * 1. Pass the file's [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` parameter of the request. For example, 'image/png'.
499
+ * 2. Pass the file's name and extenstion. For example, 'my-image.png'.
500
+ * 3. If you don't know the file's extension or MIME type, pass its media type in the `mediaType` parameter of the request. For example, 'IMAGE'. Note that this option only works if the server hosting the media allows a 'HEAD' request.
501
+ *
502
+ * >**Note:** The `media` property isn't returned in the `files` response object.
503
+ * @param url - Publicly accessible external file url.
504
+ * @public
505
+ * @documentationMaturity preview
506
+ * @requiredField url
507
+ */
508
+ function importFile(url, options) {
509
+ var _a, _b, _c;
510
+ return __awaiter(this, arguments, void 0, function* () {
511
+ const requestTransformation = {
512
+ url: '$[0]',
513
+ mediaType: '$[1].mediaType',
514
+ displayName: '$[1].displayName',
515
+ parentFolderId: '$[1].parentFolderId',
516
+ private: '$[1].private',
517
+ labels: '$[1].labels',
518
+ mimeType: '$[1].mimeType',
519
+ externalInfo: '$[1].externalInfo',
520
+ };
521
+ const responseTransformation = '$';
522
+ // @ts-ignore
523
+ const { httpClient, sideEffects } = arguments[2];
524
+ const { toAmbassadorRequest } = velo_1.serializer({
525
+ rootSchema: _importFileRequest,
526
+ depSchemas: {},
527
+ fqdnTransformation: {
528
+ paths: [],
529
+ transformation: _fromVeloEntity,
530
+ },
531
+ customTransformation: requestTransformation,
532
+ });
533
+ const { fromJSON } = velo_1.serializer({
534
+ rootSchema: _importFileResponse,
535
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
536
+ fqdnTransformation: {
537
+ paths: [...['file']],
538
+ transformation: _toVeloEntity,
539
+ },
540
+ customTransformation: responseTransformation,
541
+ });
542
+ const payload = toAmbassadorRequest([url, options]);
543
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.importFile(payload);
544
+ __log(`"ImportFile" sending request with: ${__inspect(reqOpts)}`);
545
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
546
+ try {
547
+ const result = yield httpClient.request(reqOpts);
548
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
549
+ return fromJSON(result.data);
550
+ }
551
+ catch (err) {
552
+ const transformedError = velo_1.transformError(err, requestTransformation, [
553
+ 'url',
554
+ 'options',
555
+ ]);
556
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
557
+ throw transformedError;
558
+ }
559
+ });
560
+ }
561
+ exports.importFile = importFile;
562
+ /**
563
+ * Imports a bulk of files to the Media Manager using external urls. <br/>
564
+ *
565
+ * Returns information about the imported files. Use the `parentFolderId` parameter to specify in which folder you want each file to be imported to.
566
+ * If no folder is specified, the file is imported to the `media-root` folder.
567
+ *
568
+ * To import files, you need to provide one of the following:
569
+ * 1. Pass each file's [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` parameter of the request. For example, 'image/png'.
570
+ * 2. Pass each file's name and extenstion. For example, 'my-image.png'.
571
+ * 3. If you don't know a file's extension or MIME type, pass its media type in the `mediaType` parameter of the request. For example, 'IMAGE'. Note that this option only works if the server hosting the media allows a 'HEAD' request.
572
+ *
573
+ * >**Note:** The `media` property isn't returned in the `files` response object.
574
+ * @public
575
+ * @documentationMaturity preview
576
+ * @requiredField options.importFileRequests.url
577
+ */
578
+ function bulkImportFiles(options) {
579
+ var _a, _b, _c;
580
+ return __awaiter(this, arguments, void 0, function* () {
581
+ const requestTransformation = {
582
+ importFileRequests: '$[0].importFileRequests',
583
+ };
584
+ const responseTransformation = '$';
585
+ // @ts-ignore
586
+ const { httpClient, sideEffects } = arguments[1];
587
+ const { toAmbassadorRequest } = velo_1.serializer({
588
+ rootSchema: _bulkImportFilesRequest,
589
+ depSchemas: { _importFileRequest },
590
+ fqdnTransformation: {
591
+ paths: [],
592
+ transformation: _fromVeloEntity,
593
+ },
594
+ customTransformation: requestTransformation,
595
+ });
596
+ const { fromJSON } = velo_1.serializer({
597
+ rootSchema: _bulkImportFilesResponse,
598
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
599
+ fqdnTransformation: {
600
+ paths: [...['Array#files']],
601
+ transformation: _toVeloEntity,
602
+ },
603
+ customTransformation: responseTransformation,
604
+ });
605
+ const payload = toAmbassadorRequest([options]);
606
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.bulkImportFiles(payload);
607
+ __log(`"BulkImportFiles" sending request with: ${__inspect(reqOpts)}`);
608
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
609
+ try {
610
+ const result = yield httpClient.request(reqOpts);
611
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
612
+ return fromJSON(result.data);
613
+ }
614
+ catch (err) {
615
+ const transformedError = velo_1.transformError(err, requestTransformation, [
616
+ 'options',
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
+ exports.bulkImportFiles = bulkImportFiles;
624
+ /**
625
+ * Retrieves a list of files in the Media Manager.
626
+ *
627
+ * To retrieve a list of files within a specific folder in the Media Manager, pass the folder's ID in the `parentFolderId` parameter. If no folder is specified, the endpoint retrieves the list of files in the root folder of the Media Manager.
628
+ * @public
629
+ * @documentationMaturity preview
630
+ */
631
+ function listFiles(options) {
632
+ var _a, _b, _c;
633
+ return __awaiter(this, arguments, void 0, function* () {
634
+ const requestTransformation = {
635
+ parentFolderId: '$[0].parentFolderId',
636
+ mediaTypes: '$[0].mediaTypes',
637
+ private: '$[0].private',
638
+ sort: '$[0].sort',
639
+ paging: '$[0].paging',
640
+ };
641
+ const responseTransformation = '$';
642
+ // @ts-ignore
643
+ const { httpClient, sideEffects } = arguments[1];
644
+ const { toAmbassadorRequest } = velo_1.serializer({
645
+ rootSchema: _listFilesRequest,
646
+ depSchemas: {},
647
+ fqdnTransformation: {
648
+ paths: [],
649
+ transformation: _fromVeloEntity,
650
+ },
651
+ customTransformation: requestTransformation,
652
+ });
653
+ const { fromJSON } = velo_1.serializer({
654
+ rootSchema: _listFilesResponse,
655
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
656
+ fqdnTransformation: {
657
+ paths: [...['Array#files']],
658
+ transformation: _toVeloEntity,
659
+ },
660
+ customTransformation: responseTransformation,
661
+ });
662
+ const payload = toAmbassadorRequest([options]);
663
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.listFiles(payload);
664
+ __log(`"ListFiles" sending request with: ${__inspect(reqOpts)}`);
665
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
666
+ try {
667
+ const result = yield httpClient.request(reqOpts);
668
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
669
+ return fromJSON(result.data);
670
+ }
671
+ catch (err) {
672
+ const transformedError = velo_1.transformError(err, requestTransformation, [
673
+ 'options',
674
+ ]);
675
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
676
+ throw transformedError;
677
+ }
678
+ });
679
+ }
680
+ exports.listFiles = listFiles;
681
+ /**
682
+ * Searches all folders in the Media Manager and returns a list of files that match the terms specified in the parameters. <br/>
683
+ *
684
+ * If no parameters are specified, the endpoint returns all files in the `MEDIA_ROOT` folder.
685
+ * @public
686
+ * @documentationMaturity preview
687
+ */
688
+ function searchFiles(options) {
689
+ var _a, _b, _c;
690
+ return __awaiter(this, arguments, void 0, function* () {
691
+ const requestTransformation = {
692
+ search: '$[0].search',
693
+ rootFolder: '$[0].rootFolder',
694
+ mediaTypes: '$[0].mediaTypes',
695
+ private: '$[0].private',
696
+ sort: '$[0].sort',
697
+ paging: '$[0].paging',
698
+ };
699
+ const responseTransformation = '$';
700
+ // @ts-ignore
701
+ const { httpClient, sideEffects } = arguments[1];
702
+ const { toAmbassadorRequest } = velo_1.serializer({
703
+ rootSchema: _searchFilesRequest,
704
+ depSchemas: {},
705
+ fqdnTransformation: {
706
+ paths: [],
707
+ transformation: _fromVeloEntity,
708
+ },
709
+ customTransformation: requestTransformation,
710
+ });
711
+ const { fromJSON } = velo_1.serializer({
712
+ rootSchema: _searchFilesResponse,
713
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
714
+ fqdnTransformation: {
715
+ paths: [...['Array#files']],
716
+ transformation: _toVeloEntity,
717
+ },
718
+ customTransformation: responseTransformation,
719
+ });
720
+ const payload = toAmbassadorRequest([options]);
721
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.searchFiles(payload);
722
+ __log(`"SearchFiles" sending request with: ${__inspect(reqOpts)}`);
723
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
724
+ try {
725
+ const result = yield httpClient.request(reqOpts);
726
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
727
+ return fromJSON(result.data);
728
+ }
729
+ catch (err) {
730
+ const transformedError = velo_1.transformError(err, requestTransformation, [
731
+ 'options',
732
+ ]);
733
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
734
+ throw transformedError;
735
+ }
736
+ });
737
+ }
738
+ exports.searchFiles = searchFiles;
739
+ /**
740
+ * Generates a URL for streaming a specific video file in the Media Manager. <br/>
741
+ *
742
+ * To stream different assets of the file, use the `assetKeys` parameter which generates a video streaming URL for each asset. If no assetKey is specified, it defaults to `src`, which generates one video streaming URL in the original file's format and quality.
743
+ * @param fileId - File ID.
744
+ * @public
745
+ * @documentationMaturity preview
746
+ * @requiredField fileId
747
+ */
748
+ function generateVideoStreamingUrl(fileId, options) {
749
+ var _a, _b, _c;
750
+ return __awaiter(this, arguments, void 0, function* () {
751
+ const requestTransformation = { fileId: '$[0]', format: '$[1].format' };
752
+ const responseTransformation = '$';
753
+ // @ts-ignore
754
+ const { httpClient, sideEffects } = arguments[2];
755
+ const { toAmbassadorRequest } = velo_1.serializer({
756
+ rootSchema: _generateVideoStreamingUrlRequest,
757
+ depSchemas: {},
758
+ fqdnTransformation: {
759
+ paths: [],
760
+ transformation: _fromVeloEntity,
761
+ },
762
+ customTransformation: requestTransformation,
763
+ });
764
+ const { fromJSON } = velo_1.serializer({
765
+ rootSchema: _generateVideoStreamingUrlResponse,
766
+ depSchemas: {},
767
+ fqdnTransformation: {
768
+ paths: [],
769
+ transformation: _toVeloEntity,
770
+ },
771
+ customTransformation: responseTransformation,
772
+ });
773
+ const payload = toAmbassadorRequest([fileId, options]);
774
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.generateVideoStreamingUrl(payload);
775
+ __log(`"GenerateVideoStreamingUrl" sending request with: ${__inspect(reqOpts)}`);
776
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
777
+ try {
778
+ const result = yield httpClient.request(reqOpts);
779
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
780
+ return fromJSON(result.data);
781
+ }
782
+ catch (err) {
783
+ const transformedError = velo_1.transformError(err, requestTransformation, [
784
+ 'fileId',
785
+ 'options',
786
+ ]);
787
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
788
+ throw transformedError;
789
+ }
790
+ });
791
+ }
792
+ exports.generateVideoStreamingUrl = generateVideoStreamingUrl;
793
+ /**
794
+ * Deletes the specified files from the Media Manager. <br/>
795
+ *
796
+ * The deleted files are moved to the Media Manager's trash bin (`TRASH-ROOT` folder) unless permanently deleted. To permanently delete files, pass the `permanent` parameter with the value `true`. Permanently deleting files isn't reversible, so make sure that these files aren't being used in a site or in any other way as the files will no longer be accessible.
797
+ *
798
+ * Note the following:
799
+ * * The specified files can be from different folders.
800
+ * * Moving multiple files at once is an asynchronous action, and may take time for the changes to appear in the Media Manager.
801
+ * * Attempting to delete files that are already in the trash bin doesn't result in an error.
802
+ * * If your site contains deleted media files, the deleted media files still appear on your site as the files are still in the Media Manager (in the trash bin).
803
+ * * You can use the [Bulk Restore Files From Trash Bin](bulk-restore-files-from-trash-bin) endpoint to restore files from the Media Manager's trash bin.
804
+ * @public
805
+ * @documentationMaturity preview
806
+ */
807
+ function bulkDeleteFiles(options) {
808
+ var _a, _b, _c;
809
+ return __awaiter(this, arguments, void 0, function* () {
810
+ const requestTransformation = {
811
+ fileIds: '$[0].fileIds',
812
+ permanent: '$[0].permanent',
813
+ };
814
+ const responseTransformation = '$';
815
+ // @ts-ignore
816
+ const { httpClient, sideEffects } = arguments[1];
817
+ const { toAmbassadorRequest } = velo_1.serializer({
818
+ rootSchema: _bulkDeleteFilesRequest,
819
+ depSchemas: {},
820
+ fqdnTransformation: {
821
+ paths: [],
822
+ transformation: _fromVeloEntity,
823
+ },
824
+ customTransformation: requestTransformation,
825
+ });
826
+ const { fromJSON } = velo_1.serializer({
827
+ rootSchema: _bulkDeleteFilesResponse,
828
+ depSchemas: {},
829
+ fqdnTransformation: {
830
+ paths: [],
831
+ transformation: _toVeloEntity,
832
+ },
833
+ customTransformation: responseTransformation,
834
+ });
835
+ const payload = toAmbassadorRequest([options]);
836
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.bulkDeleteFiles(payload);
837
+ __log(`"BulkDeleteFiles" sending request with: ${__inspect(reqOpts)}`);
838
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
839
+ try {
840
+ const result = yield httpClient.request(reqOpts);
841
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
842
+ return fromJSON(result.data);
843
+ }
844
+ catch (err) {
845
+ const transformedError = velo_1.transformError(err, requestTransformation, [
846
+ 'options',
847
+ ]);
848
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
849
+ throw transformedError;
850
+ }
851
+ });
852
+ }
853
+ exports.bulkDeleteFiles = bulkDeleteFiles;
854
+ /**
855
+ * Restores the specified files from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
856
+ * @param fileIds - IDs of the files to restore from the Media Manager's trash bin.
857
+ * @public
858
+ * @documentationMaturity preview
859
+ * @requiredField fileIds
860
+ */
861
+ function bulkRestoreFilesFromTrashBin(fileIds) {
862
+ var _a, _b, _c;
863
+ return __awaiter(this, arguments, void 0, function* () {
864
+ const requestTransformation = { fileIds: '$[0]' };
865
+ const responseTransformation = '$';
866
+ // @ts-ignore
867
+ const { httpClient, sideEffects } = arguments[1];
868
+ const { toAmbassadorRequest } = velo_1.serializer({
869
+ rootSchema: _bulkRestoreFilesFromTrashBinRequest,
870
+ depSchemas: {},
871
+ fqdnTransformation: {
872
+ paths: [],
873
+ transformation: _fromVeloEntity,
874
+ },
875
+ customTransformation: requestTransformation,
876
+ });
877
+ const { fromJSON } = velo_1.serializer({
878
+ rootSchema: _bulkRestoreFilesFromTrashBinResponse,
879
+ depSchemas: {},
880
+ fqdnTransformation: {
881
+ paths: [],
882
+ transformation: _toVeloEntity,
883
+ },
884
+ customTransformation: responseTransformation,
885
+ });
886
+ const payload = toAmbassadorRequest([fileIds]);
887
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.bulkRestoreFilesFromTrashBin(payload);
888
+ __log(`"BulkRestoreFilesFromTrashBin" sending request with: ${__inspect(reqOpts)}`);
889
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
890
+ try {
891
+ const result = yield httpClient.request(reqOpts);
892
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
893
+ return fromJSON(result.data);
894
+ }
895
+ catch (err) {
896
+ const transformedError = velo_1.transformError(err, requestTransformation, [
897
+ 'fileIds',
898
+ ]);
899
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
900
+ throw transformedError;
901
+ }
902
+ });
903
+ }
904
+ exports.bulkRestoreFilesFromTrashBin = bulkRestoreFilesFromTrashBin;
905
+ /**
906
+ * Retrieves a list of files in the Media Manager's trash bin. <br/>
907
+ *
908
+ * >**Note:** The Media Manager's trash bin (`TRASH-ROOT` folder) only contains temporarily deleted files, not permanently deleted files.
909
+ * @public
910
+ * @documentationMaturity preview
911
+ */
912
+ function listDeletedFiles(options) {
913
+ var _a, _b, _c;
914
+ return __awaiter(this, arguments, void 0, function* () {
915
+ const requestTransformation = {
916
+ parentFolderId: '$[0].parentFolderId',
917
+ mediaTypes: '$[0].mediaTypes',
918
+ private: '$[0].private',
919
+ sort: '$[0].sort',
920
+ paging: '$[0].paging',
921
+ };
922
+ const responseTransformation = '$';
923
+ // @ts-ignore
924
+ const { httpClient, sideEffects } = arguments[1];
925
+ const { toAmbassadorRequest } = velo_1.serializer({
926
+ rootSchema: _listDeletedFilesRequest,
927
+ depSchemas: {},
928
+ fqdnTransformation: {
929
+ paths: [],
930
+ transformation: _fromVeloEntity,
931
+ },
932
+ customTransformation: requestTransformation,
933
+ });
934
+ const { fromJSON } = velo_1.serializer({
935
+ rootSchema: _listDeletedFilesResponse,
936
+ depSchemas: { _audioV2, _fileDescriptor, _fileMedia, _imageMedia },
937
+ fqdnTransformation: {
938
+ paths: [...['Array#files']],
939
+ transformation: _toVeloEntity,
940
+ },
941
+ customTransformation: responseTransformation,
942
+ });
943
+ const payload = toAmbassadorRequest([options]);
944
+ const reqOpts = ambassadorWixMediaSiteMediaV1FileDescriptor.listDeletedFiles(payload);
945
+ __log(`"ListDeletedFiles" sending request with: ${__inspect(reqOpts)}`);
946
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
947
+ try {
948
+ const result = yield httpClient.request(reqOpts);
949
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
950
+ return fromJSON(result.data);
951
+ }
952
+ catch (err) {
953
+ const transformedError = velo_1.transformError(err, requestTransformation, [
954
+ 'options',
955
+ ]);
956
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
957
+ throw transformedError;
958
+ }
959
+ });
960
+ }
961
+ exports.listDeletedFiles = listDeletedFiles;
962
+ //# sourceMappingURL=media-site-media-v1-file-descriptor.universal.js.map