@atlaskit/media-client 25.0.1 → 25.0.3

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.
@@ -0,0 +1,624 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ 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; }
7
+ 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) { _defineProperty(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; }
8
+ import { getRandomHex } from '@atlaskit/media-common';
9
+ import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
10
+ import { getArtifactUrl } from '../../models/artifacts';
11
+ import { request as _request } from '../../utils/request';
12
+ import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
13
+ import { resolveAuth, resolveInitialAuth } from './resolveAuth';
14
+ var MEDIA_API_REGION = 'media-api-region';
15
+ var MEDIA_API_ENVIRONMENT = 'media-api-environment';
16
+ var defaultImageOptions = {
17
+ 'max-age': FILE_CACHE_MAX_AGE,
18
+ allowAnimated: true,
19
+ mode: 'crop'
20
+ };
21
+ var extendImageParams = function extendImageParams(params) {
22
+ var fetchMaxRes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
23
+ return _objectSpread(_objectSpread(_objectSpread({}, defaultImageOptions), params), fetchMaxRes ? {
24
+ width: MAX_RESOLUTION,
25
+ height: MAX_RESOLUTION
26
+ } : {});
27
+ };
28
+ var jsonHeaders = {
29
+ Accept: 'application/json',
30
+ 'Content-Type': 'application/json'
31
+ };
32
+ export var MediaStore = /*#__PURE__*/function () {
33
+ function MediaStore(config) {
34
+ var _this = this;
35
+ _classCallCheck(this, MediaStore);
36
+ _defineProperty(this, "resolveAuth", function (authContext) {
37
+ return resolveAuth(_this.config.authProvider, authContext);
38
+ });
39
+ _defineProperty(this, "resolveInitialAuth", function () {
40
+ return resolveInitialAuth(_this.config.initialAuth);
41
+ });
42
+ this.config = config;
43
+ }
44
+ _createClass(MediaStore, [{
45
+ key: "removeCollectionFile",
46
+ value: function () {
47
+ var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
48
+ var metadata, body, options;
49
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
51
+ case 0:
52
+ metadata = {
53
+ method: 'PUT',
54
+ endpoint: '/collection/{collectionName}'
55
+ };
56
+ body = {
57
+ actions: [{
58
+ action: 'remove',
59
+ item: {
60
+ type: 'file',
61
+ id: id,
62
+ occurrenceKey: occurrenceKey
63
+ }
64
+ }]
65
+ };
66
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
67
+ authContext: {
68
+ collectionName: collectionName
69
+ },
70
+ headers: {
71
+ Accept: 'application/json',
72
+ 'Content-Type': 'application/json'
73
+ },
74
+ body: JSON.stringify(body),
75
+ traceContext: traceContext
76
+ });
77
+ _context.next = 5;
78
+ return this.request("/collection/".concat(collectionName), options);
79
+ case 5:
80
+ case "end":
81
+ return _context.stop();
82
+ }
83
+ }, _callee, this);
84
+ }));
85
+ function removeCollectionFile(_x, _x2, _x3, _x4) {
86
+ return _removeCollectionFile.apply(this, arguments);
87
+ }
88
+ return removeCollectionFile;
89
+ }()
90
+ }, {
91
+ key: "createUpload",
92
+ value: function createUpload() {
93
+ var createUpTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
94
+ var collectionName = arguments.length > 1 ? arguments[1] : undefined;
95
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
96
+ var metadata = {
97
+ method: 'POST',
98
+ endpoint: '/upload'
99
+ };
100
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
101
+ authContext: {
102
+ collectionName: collectionName
103
+ },
104
+ params: {
105
+ createUpTo: createUpTo
106
+ },
107
+ headers: {
108
+ Accept: 'application/json'
109
+ },
110
+ traceContext: traceContext
111
+ });
112
+ return this.request("/upload", options).then(createMapResponseToJson(metadata));
113
+ }
114
+ }, {
115
+ key: "uploadChunk",
116
+ value: function () {
117
+ var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
118
+ var metadata, options;
119
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
120
+ while (1) switch (_context2.prev = _context2.next) {
121
+ case 0:
122
+ metadata = {
123
+ method: 'PUT',
124
+ endpoint: '/chunk/{etag}'
125
+ };
126
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
127
+ params: {
128
+ uploadId: uploadId,
129
+ partNumber: partNumber
130
+ },
131
+ authContext: {
132
+ collectionName: collectionName
133
+ },
134
+ body: blob,
135
+ traceContext: traceContext
136
+ });
137
+ _context2.next = 4;
138
+ return this.request("/chunk/".concat(etag), options);
139
+ case 4:
140
+ case "end":
141
+ return _context2.stop();
142
+ }
143
+ }, _callee2, this);
144
+ }));
145
+ function uploadChunk(_x5, _x6, _x7, _x8, _x9, _x10) {
146
+ return _uploadChunk.apply(this, arguments);
147
+ }
148
+ return uploadChunk;
149
+ }()
150
+ }, {
151
+ key: "probeChunks",
152
+ value: function probeChunks(chunks, uploadId, collectionName, traceContext) {
153
+ var metadata = {
154
+ method: 'POST',
155
+ endpoint: '/chunk/probe'
156
+ };
157
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
158
+ params: {
159
+ uploadId: uploadId
160
+ },
161
+ authContext: {
162
+ collectionName: collectionName
163
+ },
164
+ headers: jsonHeaders,
165
+ body: JSON.stringify({
166
+ chunks: chunks
167
+ }),
168
+ traceContext: traceContext
169
+ });
170
+ return this.request("/chunk/probe", options).then(createMapResponseToJson(metadata));
171
+ }
172
+ }, {
173
+ key: "createFileFromUpload",
174
+ value: function createFileFromUpload(body) {
175
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
176
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
177
+ var metadata = {
178
+ method: 'POST',
179
+ endpoint: '/file/upload'
180
+ };
181
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
182
+ authContext: {
183
+ collectionName: params.collection
184
+ },
185
+ params: params,
186
+ headers: jsonHeaders,
187
+ body: JSON.stringify(body),
188
+ traceContext: traceContext
189
+ });
190
+ return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
191
+ }
192
+ }, {
193
+ key: "getRejectedResponseFromDescriptor",
194
+ value: function getRejectedResponseFromDescriptor(descriptor, limit) {
195
+ return {
196
+ fileId: descriptor.fileId,
197
+ error: {
198
+ code: 'ExceedMaxFileSizeLimit',
199
+ title: 'The expected file size exceeded the maximum size limit.',
200
+ href: 'https://dt-api-filestore--app.ap-southeast-2.dev.atl-paas.net/api.html#BadRequest',
201
+ limit: limit,
202
+ size: descriptor.size
203
+ }
204
+ };
205
+ }
206
+ }, {
207
+ key: "touchFiles",
208
+ value: function () {
209
+ var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(body) {
210
+ var params,
211
+ traceContext,
212
+ metadata,
213
+ options,
214
+ _args3 = arguments;
215
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
216
+ while (1) switch (_context3.prev = _context3.next) {
217
+ case 0:
218
+ params = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
219
+ traceContext = _args3.length > 2 ? _args3[2] : undefined;
220
+ metadata = {
221
+ method: 'POST',
222
+ endpoint: '/upload/createWithFiles'
223
+ };
224
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
225
+ authContext: {
226
+ collectionName: params.collection
227
+ },
228
+ headers: jsonHeaders,
229
+ body: JSON.stringify(body),
230
+ traceContext: traceContext
231
+ });
232
+ return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)));
233
+ case 5:
234
+ case "end":
235
+ return _context3.stop();
236
+ }
237
+ }, _callee3, this);
238
+ }));
239
+ function touchFiles(_x11) {
240
+ return _touchFiles.apply(this, arguments);
241
+ }
242
+ return touchFiles;
243
+ }()
244
+ }, {
245
+ key: "getFile",
246
+ value: function getFile(fileId) {
247
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
248
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
249
+ var metadata = {
250
+ method: 'GET',
251
+ endpoint: '/file/{fileId}'
252
+ };
253
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
254
+ authContext: {
255
+ collectionName: params.collection
256
+ },
257
+ params: params,
258
+ traceContext: traceContext
259
+ });
260
+ return this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata));
261
+ }
262
+ }, {
263
+ key: "getFileImageURL",
264
+ value: function () {
265
+ var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
266
+ var _ref, collectionName, auth;
267
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
268
+ while (1) switch (_context4.prev = _context4.next) {
269
+ case 0:
270
+ _ref = params || {}, collectionName = _ref.collection;
271
+ _context4.next = 3;
272
+ return this.resolveAuth({
273
+ collectionName: collectionName
274
+ });
275
+ case 3:
276
+ auth = _context4.sent;
277
+ return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
278
+ case 5:
279
+ case "end":
280
+ return _context4.stop();
281
+ }
282
+ }, _callee4, this);
283
+ }));
284
+ function getFileImageURL(_x12, _x13) {
285
+ return _getFileImageURL.apply(this, arguments);
286
+ }
287
+ return getFileImageURL;
288
+ }() // TODO Create ticket in case Trace Id can be supported through query params
289
+ }, {
290
+ key: "getFileImageURLSync",
291
+ value: function getFileImageURLSync(id, params) {
292
+ var auth = this.resolveInitialAuth();
293
+ return this.createFileImageURL(id, auth, params);
294
+ }
295
+ }, {
296
+ key: "createFileImageURL",
297
+ value: function createFileImageURL(id, auth, params) {
298
+ var options = {
299
+ params: extendImageParams(params),
300
+ auth: auth
301
+ };
302
+ return createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/image"), options);
303
+ }
304
+ }, {
305
+ key: "getFileBinaryURL",
306
+ value: function () {
307
+ var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
308
+ var auth, options;
309
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
310
+ while (1) switch (_context5.prev = _context5.next) {
311
+ case 0:
312
+ _context5.next = 2;
313
+ return this.resolveAuth({
314
+ collectionName: collectionName
315
+ });
316
+ case 2:
317
+ auth = _context5.sent;
318
+ options = {
319
+ params: {
320
+ dl: true,
321
+ collection: collectionName,
322
+ 'max-age': FILE_CACHE_MAX_AGE
323
+ },
324
+ auth: auth
325
+ };
326
+ return _context5.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
327
+ case 5:
328
+ case "end":
329
+ return _context5.stop();
330
+ }
331
+ }, _callee5, this);
332
+ }));
333
+ function getFileBinaryURL(_x14, _x15) {
334
+ return _getFileBinaryURL.apply(this, arguments);
335
+ }
336
+ return getFileBinaryURL;
337
+ }()
338
+ }, {
339
+ key: "getArtifactURL",
340
+ value: function () {
341
+ var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(artifacts, artifactName, collectionName) {
342
+ var artifactUrl, auth, options;
343
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
344
+ while (1) switch (_context6.prev = _context6.next) {
345
+ case 0:
346
+ artifactUrl = getArtifactUrl(artifacts, artifactName);
347
+ if (artifactUrl) {
348
+ _context6.next = 3;
349
+ break;
350
+ }
351
+ throw new Error("artifact ".concat(artifactName, " not found"));
352
+ case 3:
353
+ _context6.next = 5;
354
+ return this.resolveAuth({
355
+ collectionName: collectionName
356
+ });
357
+ case 5:
358
+ auth = _context6.sent;
359
+ options = {
360
+ params: {
361
+ collection: collectionName,
362
+ 'max-age': FILE_CACHE_MAX_AGE
363
+ },
364
+ auth: auth
365
+ };
366
+ return _context6.abrupt("return", createUrl("".concat(auth.baseUrl).concat(artifactUrl), options));
367
+ case 8:
368
+ case "end":
369
+ return _context6.stop();
370
+ }
371
+ }, _callee6, this);
372
+ }));
373
+ function getArtifactURL(_x16, _x17, _x18) {
374
+ return _getArtifactURL.apply(this, arguments);
375
+ }
376
+ return getArtifactURL;
377
+ }()
378
+ }, {
379
+ key: "getImage",
380
+ value: function () {
381
+ var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
382
+ var isWebpSupported, headers, metadata, options;
383
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
384
+ while (1) switch (_context7.prev = _context7.next) {
385
+ case 0:
386
+ // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
387
+ isWebpSupported = false;
388
+ headers = {};
389
+ if (isWebpSupported) {
390
+ headers.accept = 'image/webp,image/*,*/*;q=0.8';
391
+ }
392
+ metadata = {
393
+ method: 'GET',
394
+ endpoint: '/file/{fileId}/image'
395
+ };
396
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
397
+ authContext: {
398
+ collectionName: params && params.collection
399
+ },
400
+ params: extendImageParams(params, fetchMaxRes),
401
+ headers: headers,
402
+ traceContext: traceContext
403
+ });
404
+ return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
405
+ case 6:
406
+ case "end":
407
+ return _context7.stop();
408
+ }
409
+ }, _callee7, this);
410
+ }));
411
+ function getImage(_x19, _x20, _x21, _x22, _x23) {
412
+ return _getImage.apply(this, arguments);
413
+ }
414
+ return getImage;
415
+ }()
416
+ }, {
417
+ key: "getItems",
418
+ value: function () {
419
+ var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
420
+ var descriptors, metadata, options;
421
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
422
+ while (1) switch (_context8.prev = _context8.next) {
423
+ case 0:
424
+ descriptors = ids.map(function (id) {
425
+ return {
426
+ type: 'file',
427
+ id: id,
428
+ collection: collectionName
429
+ };
430
+ });
431
+ metadata = {
432
+ method: 'POST',
433
+ endpoint: '/items'
434
+ };
435
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
436
+ authContext: {
437
+ collectionName: collectionName
438
+ },
439
+ headers: jsonHeaders,
440
+ body: JSON.stringify({
441
+ descriptors: descriptors
442
+ }),
443
+ traceContext: traceContext
444
+ });
445
+ return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
446
+ case 4:
447
+ case "end":
448
+ return _context8.stop();
449
+ }
450
+ }, _callee8, this);
451
+ }));
452
+ function getItems(_x24, _x25, _x26) {
453
+ return _getItems.apply(this, arguments);
454
+ }
455
+ return getItems;
456
+ }()
457
+ }, {
458
+ key: "getImageMetadata",
459
+ value: function () {
460
+ var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
461
+ var metadata, options;
462
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
463
+ while (1) switch (_context9.prev = _context9.next) {
464
+ case 0:
465
+ metadata = {
466
+ method: 'GET',
467
+ endpoint: '/file/{fileId}/image/metadata'
468
+ };
469
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
470
+ authContext: {
471
+ collectionName: params && params.collection
472
+ },
473
+ params: params,
474
+ traceContext: traceContext
475
+ });
476
+ return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
477
+ case 3:
478
+ case "end":
479
+ return _context9.stop();
480
+ }
481
+ }, _callee9, this);
482
+ }));
483
+ function getImageMetadata(_x27, _x28, _x29) {
484
+ return _getImageMetadata.apply(this, arguments);
485
+ }
486
+ return getImageMetadata;
487
+ }()
488
+ }, {
489
+ key: "appendChunksToUpload",
490
+ value: function () {
491
+ var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
492
+ var metadata, options;
493
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
494
+ while (1) switch (_context10.prev = _context10.next) {
495
+ case 0:
496
+ metadata = {
497
+ method: 'PUT',
498
+ endpoint: '/upload/{uploadId}/chunks'
499
+ };
500
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
501
+ authContext: {
502
+ collectionName: collectionName
503
+ },
504
+ headers: jsonHeaders,
505
+ body: JSON.stringify(body),
506
+ traceContext: traceContext
507
+ });
508
+ _context10.next = 4;
509
+ return this.request("/upload/".concat(uploadId, "/chunks"), options);
510
+ case 4:
511
+ case "end":
512
+ return _context10.stop();
513
+ }
514
+ }, _callee10, this);
515
+ }));
516
+ function appendChunksToUpload(_x30, _x31, _x32, _x33) {
517
+ return _appendChunksToUpload.apply(this, arguments);
518
+ }
519
+ return appendChunksToUpload;
520
+ }()
521
+ }, {
522
+ key: "copyFileWithToken",
523
+ value: function copyFileWithToken(body, params, traceContext) {
524
+ var metadata = {
525
+ method: 'POST',
526
+ endpoint: '/file/copy/withToken'
527
+ };
528
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
529
+ authContext: {
530
+ collectionName: params.collection
531
+ },
532
+ // Contains collection name to write to
533
+ params: params,
534
+ // Contains collection name to write to
535
+ headers: jsonHeaders,
536
+ body: JSON.stringify(body),
537
+ // Contains collection name to read from
538
+ traceContext: traceContext
539
+ });
540
+ return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
541
+ }
542
+ }, {
543
+ key: "request",
544
+ value: function () {
545
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(path) {
546
+ var options,
547
+ controller,
548
+ method,
549
+ endpoint,
550
+ authContext,
551
+ params,
552
+ headers,
553
+ body,
554
+ clientOptions,
555
+ traceContext,
556
+ auth,
557
+ extendedTraceContext,
558
+ response,
559
+ _args11 = arguments;
560
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
561
+ while (1) switch (_context11.prev = _context11.next) {
562
+ case 0:
563
+ options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {
564
+ method: 'GET',
565
+ endpoint: undefined,
566
+ authContext: {}
567
+ };
568
+ controller = _args11.length > 2 ? _args11[2] : undefined;
569
+ method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
570
+ _context11.next = 5;
571
+ return this.resolveAuth(authContext);
572
+ case 5:
573
+ auth = _context11.sent;
574
+ extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
575
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
576
+ }) : undefined;
577
+ _context11.next = 9;
578
+ return _request("".concat(auth.baseUrl).concat(path), {
579
+ method: method,
580
+ endpoint: endpoint,
581
+ auth: auth,
582
+ params: params,
583
+ headers: headers,
584
+ body: body,
585
+ clientOptions: clientOptions,
586
+ traceContext: extendedTraceContext
587
+ }, controller);
588
+ case 9:
589
+ response = _context11.sent;
590
+ setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
591
+ setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
592
+ return _context11.abrupt("return", response);
593
+ case 13:
594
+ case "end":
595
+ return _context11.stop();
596
+ }
597
+ }, _callee11, this);
598
+ }));
599
+ function request(_x34) {
600
+ return _request2.apply(this, arguments);
601
+ }
602
+ return request;
603
+ }()
604
+ }]);
605
+ return MediaStore;
606
+ }();
607
+ var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
608
+ return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
609
+ };
610
+ var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
611
+ if (!value || !(window && window.sessionStorage)) {
612
+ return;
613
+ }
614
+ var currentValue = window.sessionStorage.getItem(key);
615
+ if (currentValue !== value) {
616
+ window.sessionStorage.setItem(key, value);
617
+ }
618
+ };
619
+ export var getMediaEnvironment = function getMediaEnvironment() {
620
+ return getValueFromSessionStorage(MEDIA_API_ENVIRONMENT);
621
+ };
622
+ export var getMediaRegion = function getMediaRegion() {
623
+ return getValueFromSessionStorage(MEDIA_API_REGION);
624
+ };