@atlaskit/media-client 27.0.1 → 27.2.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/CHANGELOG.md +16 -0
- package/dist/cjs/client/media-store/MediaStore.js +32 -15
- package/dist/cjs/models/artifacts.js +2 -5
- package/dist/cjs/utils/request/helpers.js +1 -1
- package/dist/es2019/client/media-store/MediaStore.js +14 -9
- package/dist/es2019/models/artifacts.js +2 -5
- package/dist/es2019/utils/request/helpers.js +1 -1
- package/dist/esm/client/media-store/MediaStore.js +32 -15
- package/dist/esm/models/artifacts.js +2 -5
- package/dist/esm/utils/request/helpers.js +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 27.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#101187](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101187)
|
|
8
|
+
[`021415681643`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/021415681643) -
|
|
9
|
+
Added SVG sample files
|
|
10
|
+
|
|
11
|
+
## 27.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#103718](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103718)
|
|
16
|
+
[`5bdb1cb0f2b7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5bdb1cb0f2b7) -
|
|
17
|
+
CXP-3328 Integrate CDN delivery to media-client
|
|
18
|
+
|
|
3
19
|
## 27.0.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -17,6 +17,7 @@ var _request3 = require("../../utils/request");
|
|
|
17
17
|
var _helpers = require("../../utils/request/helpers");
|
|
18
18
|
var _resolveAuth = require("./resolveAuth");
|
|
19
19
|
var _mediaCore = require("@atlaskit/media-core");
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
23
|
var MEDIA_API_REGION = 'media-api-region';
|
|
@@ -290,7 +291,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
290
291
|
params: extendImageParams(params),
|
|
291
292
|
auth: auth
|
|
292
293
|
};
|
|
293
|
-
|
|
294
|
+
var imageEndpoint = (0, _platformFeatureFlags.getBooleanFF)('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
295
|
+
return (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options);
|
|
294
296
|
}
|
|
295
297
|
}, {
|
|
296
298
|
key: "getFileBinary",
|
|
@@ -298,6 +300,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
298
300
|
var _getFileBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName) {
|
|
299
301
|
var maxAge,
|
|
300
302
|
headers,
|
|
303
|
+
binaryEndpoint,
|
|
301
304
|
metadata,
|
|
302
305
|
options,
|
|
303
306
|
_args5 = arguments;
|
|
@@ -306,9 +309,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
306
309
|
case 0:
|
|
307
310
|
maxAge = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : _constants.FILE_CACHE_MAX_AGE;
|
|
308
311
|
headers = {};
|
|
312
|
+
binaryEndpoint = (0, _platformFeatureFlags.getBooleanFF)('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
309
313
|
metadata = {
|
|
310
314
|
method: 'GET',
|
|
311
|
-
endpoint:
|
|
315
|
+
endpoint: "/file/{fileId}/".concat(binaryEndpoint)
|
|
312
316
|
};
|
|
313
317
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
314
318
|
authContext: {
|
|
@@ -319,8 +323,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
319
323
|
'max-age': "".concat(maxAge)
|
|
320
324
|
}
|
|
321
325
|
});
|
|
322
|
-
return _context5.abrupt("return", this.request("/file/".concat(id, "/
|
|
323
|
-
case
|
|
326
|
+
return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
327
|
+
case 6:
|
|
324
328
|
case "end":
|
|
325
329
|
return _context5.stop();
|
|
326
330
|
}
|
|
@@ -338,6 +342,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
338
342
|
var maxAge,
|
|
339
343
|
auth,
|
|
340
344
|
options,
|
|
345
|
+
binaryEndpoint,
|
|
341
346
|
_args6 = arguments;
|
|
342
347
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
343
348
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -357,8 +362,9 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
357
362
|
},
|
|
358
363
|
auth: auth
|
|
359
364
|
};
|
|
360
|
-
|
|
361
|
-
|
|
365
|
+
binaryEndpoint = (0, _platformFeatureFlags.getBooleanFF)('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
366
|
+
return _context6.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options));
|
|
367
|
+
case 7:
|
|
362
368
|
case "end":
|
|
363
369
|
return _context6.stop();
|
|
364
370
|
}
|
|
@@ -384,12 +390,22 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
384
390
|
}
|
|
385
391
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
386
392
|
case 3:
|
|
387
|
-
|
|
393
|
+
if (artifactUrl.includes('media-cdn')) {
|
|
394
|
+
_context7.next = 9;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
_context7.next = 6;
|
|
388
398
|
return this.resolveAuth({
|
|
389
399
|
collectionName: collectionName
|
|
390
400
|
});
|
|
391
|
-
case
|
|
392
|
-
|
|
401
|
+
case 6:
|
|
402
|
+
_context7.t0 = _context7.sent;
|
|
403
|
+
_context7.next = 10;
|
|
404
|
+
break;
|
|
405
|
+
case 9:
|
|
406
|
+
_context7.t0 = undefined;
|
|
407
|
+
case 10:
|
|
408
|
+
auth = _context7.t0;
|
|
393
409
|
options = {
|
|
394
410
|
params: {
|
|
395
411
|
collection: collectionName,
|
|
@@ -397,8 +413,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
397
413
|
},
|
|
398
414
|
auth: auth
|
|
399
415
|
};
|
|
400
|
-
return _context7.abrupt("return", (0, _helpers.createUrl)(
|
|
401
|
-
case
|
|
416
|
+
return _context7.abrupt("return", (0, _helpers.createUrl)(artifactUrl, options));
|
|
417
|
+
case 13:
|
|
402
418
|
case "end":
|
|
403
419
|
return _context7.stop();
|
|
404
420
|
}
|
|
@@ -413,7 +429,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
413
429
|
key: "getImage",
|
|
414
430
|
value: function () {
|
|
415
431
|
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(id, params, controller, fetchMaxRes, traceContext) {
|
|
416
|
-
var isWebpSupported, headers, metadata, options;
|
|
432
|
+
var isWebpSupported, headers, imageEndpoint, metadata, options;
|
|
417
433
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
418
434
|
while (1) switch (_context8.prev = _context8.next) {
|
|
419
435
|
case 0:
|
|
@@ -423,9 +439,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
423
439
|
if (isWebpSupported) {
|
|
424
440
|
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
425
441
|
}
|
|
442
|
+
imageEndpoint = (0, _platformFeatureFlags.getBooleanFF)('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
426
443
|
metadata = {
|
|
427
444
|
method: 'GET',
|
|
428
|
-
endpoint:
|
|
445
|
+
endpoint: "/file/{fileId}/".concat(imageEndpoint)
|
|
429
446
|
};
|
|
430
447
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
431
448
|
authContext: {
|
|
@@ -435,8 +452,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
435
452
|
headers: headers,
|
|
436
453
|
traceContext: traceContext
|
|
437
454
|
});
|
|
438
|
-
return _context8.abrupt("return", this.request("/file/".concat(id, "/
|
|
439
|
-
case
|
|
455
|
+
return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
456
|
+
case 7:
|
|
440
457
|
case "end":
|
|
441
458
|
return _context8.stop();
|
|
442
459
|
}
|
|
@@ -5,9 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getArtifactUrl = void 0;
|
|
7
7
|
var getArtifactUrl = exports.getArtifactUrl = function getArtifactUrl(artifacts, prop) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return artifact.url;
|
|
8
|
+
var _artifacts$prop, _artifacts$prop2;
|
|
9
|
+
return ((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.cdnUrl) || ((_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url);
|
|
13
10
|
};
|
|
@@ -75,7 +75,7 @@ function mapAuthToRequestHeaders(auth) {
|
|
|
75
75
|
function createUrl(url, _ref2) {
|
|
76
76
|
var params = _ref2.params,
|
|
77
77
|
auth = _ref2.auth;
|
|
78
|
-
var parsedUrl = new URL(url);
|
|
78
|
+
var parsedUrl = new URL(url, auth === null || auth === void 0 ? void 0 : auth.baseUrl);
|
|
79
79
|
var authParams = auth && (0, _authQueryParameters.mapAuthToQueryParameters)(auth) || {};
|
|
80
80
|
var paramsToAppend = _objectSpread(_objectSpread({}, params), authParams);
|
|
81
81
|
Object.entries(paramsToAppend).filter(function (_ref3) {
|
|
@@ -6,6 +6,7 @@ import { request } from '../../utils/request';
|
|
|
6
6
|
import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
|
|
7
7
|
import { resolveAuth, resolveInitialAuth } from './resolveAuth';
|
|
8
8
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
const MEDIA_API_REGION = 'media-api-region';
|
|
10
11
|
const MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
11
12
|
const extendImageParams = (params, fetchMaxRes = false) => {
|
|
@@ -184,13 +185,15 @@ export class MediaStore {
|
|
|
184
185
|
params: extendImageParams(params),
|
|
185
186
|
auth
|
|
186
187
|
};
|
|
187
|
-
|
|
188
|
+
const imageEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
189
|
+
return createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options);
|
|
188
190
|
}
|
|
189
191
|
async getFileBinary(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
|
|
190
192
|
const headers = {};
|
|
193
|
+
const binaryEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
191
194
|
const metadata = {
|
|
192
195
|
method: 'GET',
|
|
193
|
-
endpoint:
|
|
196
|
+
endpoint: `/file/{fileId}/${binaryEndpoint}`
|
|
194
197
|
};
|
|
195
198
|
const options = {
|
|
196
199
|
...metadata,
|
|
@@ -202,7 +205,7 @@ export class MediaStore {
|
|
|
202
205
|
'max-age': `${maxAge}`
|
|
203
206
|
}
|
|
204
207
|
};
|
|
205
|
-
return this.request(`/file/${id}
|
|
208
|
+
return this.request(`/file/${id}/${binaryEndpoint}`, options).then(createMapResponseToBlob(metadata));
|
|
206
209
|
}
|
|
207
210
|
async getFileBinaryURL(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
|
|
208
211
|
const auth = await this.resolveAuth({
|
|
@@ -216,16 +219,17 @@ export class MediaStore {
|
|
|
216
219
|
},
|
|
217
220
|
auth
|
|
218
221
|
};
|
|
219
|
-
|
|
222
|
+
const binaryEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
223
|
+
return createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options);
|
|
220
224
|
}
|
|
221
225
|
async getArtifactURL(artifacts, artifactName, collectionName) {
|
|
222
226
|
const artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
223
227
|
if (!artifactUrl) {
|
|
224
228
|
throw new Error(`artifact ${artifactName} not found`);
|
|
225
229
|
}
|
|
226
|
-
const auth = await this.resolveAuth({
|
|
230
|
+
const auth = !artifactUrl.includes('media-cdn') ? await this.resolveAuth({
|
|
227
231
|
collectionName
|
|
228
|
-
});
|
|
232
|
+
}) : undefined;
|
|
229
233
|
const options = {
|
|
230
234
|
params: {
|
|
231
235
|
collection: collectionName,
|
|
@@ -233,7 +237,7 @@ export class MediaStore {
|
|
|
233
237
|
},
|
|
234
238
|
auth
|
|
235
239
|
};
|
|
236
|
-
return createUrl(
|
|
240
|
+
return createUrl(artifactUrl, options);
|
|
237
241
|
}
|
|
238
242
|
async getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
239
243
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
@@ -242,9 +246,10 @@ export class MediaStore {
|
|
|
242
246
|
if (isWebpSupported) {
|
|
243
247
|
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
244
248
|
}
|
|
249
|
+
const imageEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
245
250
|
const metadata = {
|
|
246
251
|
method: 'GET',
|
|
247
|
-
endpoint:
|
|
252
|
+
endpoint: `/file/{fileId}/${imageEndpoint}`
|
|
248
253
|
};
|
|
249
254
|
const options = {
|
|
250
255
|
...metadata,
|
|
@@ -255,7 +260,7 @@ export class MediaStore {
|
|
|
255
260
|
headers,
|
|
256
261
|
traceContext
|
|
257
262
|
};
|
|
258
|
-
return this.request(`/file/${id}
|
|
263
|
+
return this.request(`/file/${id}/${imageEndpoint}`, options, controller).then(createMapResponseToBlob(metadata));
|
|
259
264
|
}
|
|
260
265
|
async getItems(ids, collectionName, traceContext) {
|
|
261
266
|
const descriptors = ids.map(id => ({
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export const getArtifactUrl = (artifacts, prop) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return undefined;
|
|
5
|
-
}
|
|
6
|
-
return artifact.url;
|
|
2
|
+
var _artifacts$prop, _artifacts$prop2;
|
|
3
|
+
return ((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.cdnUrl) || ((_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url);
|
|
7
4
|
};
|
|
@@ -47,7 +47,7 @@ export function createUrl(url, {
|
|
|
47
47
|
params,
|
|
48
48
|
auth
|
|
49
49
|
}) {
|
|
50
|
-
const parsedUrl = new URL(url);
|
|
50
|
+
const parsedUrl = new URL(url, auth === null || auth === void 0 ? void 0 : auth.baseUrl);
|
|
51
51
|
const authParams = auth && mapAuthToQueryParameters(auth) || {};
|
|
52
52
|
const paramsToAppend = {
|
|
53
53
|
...params,
|
|
@@ -12,6 +12,7 @@ import { request as _request } from '../../utils/request';
|
|
|
12
12
|
import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
|
|
13
13
|
import { resolveAuth, resolveInitialAuth } from './resolveAuth';
|
|
14
14
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
15
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
var MEDIA_API_REGION = 'media-api-region';
|
|
16
17
|
var MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
17
18
|
var extendImageParams = function extendImageParams(params) {
|
|
@@ -283,7 +284,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
283
284
|
params: extendImageParams(params),
|
|
284
285
|
auth: auth
|
|
285
286
|
};
|
|
286
|
-
|
|
287
|
+
var imageEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
288
|
+
return createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options);
|
|
287
289
|
}
|
|
288
290
|
}, {
|
|
289
291
|
key: "getFileBinary",
|
|
@@ -291,6 +293,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
291
293
|
var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
|
|
292
294
|
var maxAge,
|
|
293
295
|
headers,
|
|
296
|
+
binaryEndpoint,
|
|
294
297
|
metadata,
|
|
295
298
|
options,
|
|
296
299
|
_args5 = arguments;
|
|
@@ -299,9 +302,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
299
302
|
case 0:
|
|
300
303
|
maxAge = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : FILE_CACHE_MAX_AGE;
|
|
301
304
|
headers = {};
|
|
305
|
+
binaryEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
302
306
|
metadata = {
|
|
303
307
|
method: 'GET',
|
|
304
|
-
endpoint:
|
|
308
|
+
endpoint: "/file/{fileId}/".concat(binaryEndpoint)
|
|
305
309
|
};
|
|
306
310
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
307
311
|
authContext: {
|
|
@@ -312,8 +316,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
312
316
|
'max-age': "".concat(maxAge)
|
|
313
317
|
}
|
|
314
318
|
});
|
|
315
|
-
return _context5.abrupt("return", this.request("/file/".concat(id, "/
|
|
316
|
-
case
|
|
319
|
+
return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options).then(createMapResponseToBlob(metadata)));
|
|
320
|
+
case 6:
|
|
317
321
|
case "end":
|
|
318
322
|
return _context5.stop();
|
|
319
323
|
}
|
|
@@ -331,6 +335,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
331
335
|
var maxAge,
|
|
332
336
|
auth,
|
|
333
337
|
options,
|
|
338
|
+
binaryEndpoint,
|
|
334
339
|
_args6 = arguments;
|
|
335
340
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
336
341
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -350,8 +355,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
350
355
|
},
|
|
351
356
|
auth: auth
|
|
352
357
|
};
|
|
353
|
-
|
|
354
|
-
|
|
358
|
+
binaryEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
359
|
+
return _context6.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options));
|
|
360
|
+
case 7:
|
|
355
361
|
case "end":
|
|
356
362
|
return _context6.stop();
|
|
357
363
|
}
|
|
@@ -377,12 +383,22 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
377
383
|
}
|
|
378
384
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
379
385
|
case 3:
|
|
380
|
-
|
|
386
|
+
if (artifactUrl.includes('media-cdn')) {
|
|
387
|
+
_context7.next = 9;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
_context7.next = 6;
|
|
381
391
|
return this.resolveAuth({
|
|
382
392
|
collectionName: collectionName
|
|
383
393
|
});
|
|
384
|
-
case
|
|
385
|
-
|
|
394
|
+
case 6:
|
|
395
|
+
_context7.t0 = _context7.sent;
|
|
396
|
+
_context7.next = 10;
|
|
397
|
+
break;
|
|
398
|
+
case 9:
|
|
399
|
+
_context7.t0 = undefined;
|
|
400
|
+
case 10:
|
|
401
|
+
auth = _context7.t0;
|
|
386
402
|
options = {
|
|
387
403
|
params: {
|
|
388
404
|
collection: collectionName,
|
|
@@ -390,8 +406,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
390
406
|
},
|
|
391
407
|
auth: auth
|
|
392
408
|
};
|
|
393
|
-
return _context7.abrupt("return", createUrl(
|
|
394
|
-
case
|
|
409
|
+
return _context7.abrupt("return", createUrl(artifactUrl, options));
|
|
410
|
+
case 13:
|
|
395
411
|
case "end":
|
|
396
412
|
return _context7.stop();
|
|
397
413
|
}
|
|
@@ -406,7 +422,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
406
422
|
key: "getImage",
|
|
407
423
|
value: function () {
|
|
408
424
|
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, params, controller, fetchMaxRes, traceContext) {
|
|
409
|
-
var isWebpSupported, headers, metadata, options;
|
|
425
|
+
var isWebpSupported, headers, imageEndpoint, metadata, options;
|
|
410
426
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
411
427
|
while (1) switch (_context8.prev = _context8.next) {
|
|
412
428
|
case 0:
|
|
@@ -416,9 +432,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
416
432
|
if (isWebpSupported) {
|
|
417
433
|
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
418
434
|
}
|
|
435
|
+
imageEndpoint = getBooleanFF('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
419
436
|
metadata = {
|
|
420
437
|
method: 'GET',
|
|
421
|
-
endpoint:
|
|
438
|
+
endpoint: "/file/{fileId}/".concat(imageEndpoint)
|
|
422
439
|
};
|
|
423
440
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
424
441
|
authContext: {
|
|
@@ -428,8 +445,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
428
445
|
headers: headers,
|
|
429
446
|
traceContext: traceContext
|
|
430
447
|
});
|
|
431
|
-
return _context8.abrupt("return", this.request("/file/".concat(id, "/
|
|
432
|
-
case
|
|
448
|
+
return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller).then(createMapResponseToBlob(metadata)));
|
|
449
|
+
case 7:
|
|
433
450
|
case "end":
|
|
434
451
|
return _context8.stop();
|
|
435
452
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export var getArtifactUrl = function getArtifactUrl(artifacts, prop) {
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
return undefined;
|
|
5
|
-
}
|
|
6
|
-
return artifact.url;
|
|
2
|
+
var _artifacts$prop, _artifacts$prop2;
|
|
3
|
+
return ((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.cdnUrl) || ((_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url);
|
|
7
4
|
};
|
|
@@ -53,7 +53,7 @@ export function mapAuthToRequestHeaders(auth) {
|
|
|
53
53
|
export function createUrl(url, _ref2) {
|
|
54
54
|
var params = _ref2.params,
|
|
55
55
|
auth = _ref2.auth;
|
|
56
|
-
var parsedUrl = new URL(url);
|
|
56
|
+
var parsedUrl = new URL(url, auth === null || auth === void 0 ? void 0 : auth.baseUrl);
|
|
57
57
|
var authParams = auth && mapAuthToQueryParameters(auth) || {};
|
|
58
58
|
var paramsToAppend = _objectSpread(_objectSpread({}, params), authParams);
|
|
59
59
|
Object.entries(paramsToAppend).filter(function (_ref3) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "27.0
|
|
3
|
+
"version": "27.2.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@atlaskit/media-core": "^34.2.0",
|
|
61
|
-
"@atlaskit/media-state": "^1.
|
|
61
|
+
"@atlaskit/media-state": "^1.1.0",
|
|
62
62
|
"@atlaskit/ssr": "*",
|
|
63
63
|
"@atlaskit/tokens": "^1.49.0",
|
|
64
64
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
@@ -88,6 +88,9 @@
|
|
|
88
88
|
"platform-feature-flags": {
|
|
89
89
|
"platform.media-svg-rendering": {
|
|
90
90
|
"type": "boolean"
|
|
91
|
+
},
|
|
92
|
+
"platform.media-cdn-delivery": {
|
|
93
|
+
"type": "boolean"
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
}
|