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