@atlaskit/media-client 34.1.0 → 35.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/CHANGELOG.md +20 -0
- package/dist/cjs/client/file-fetcher/index.js +3 -3
- package/dist/cjs/client/media-store/MediaStore.js +42 -22
- package/dist/cjs/utils/request/helpers.js +4 -0
- package/dist/es2019/client/file-fetcher/index.js +3 -3
- package/dist/es2019/client/media-store/MediaStore.js +32 -12
- package/dist/es2019/utils/request/helpers.js +4 -0
- package/dist/esm/client/file-fetcher/index.js +3 -3
- package/dist/esm/client/media-store/MediaStore.js +42 -22
- package/dist/esm/utils/request/helpers.js +4 -0
- package/dist/types/client/file-fetcher/index.d.ts +2 -2
- package/dist/types/client/media-store/MediaStore.d.ts +2 -2
- package/dist/types/client/media-store/types.d.ts +3 -6
- package/dist/types/models/document.d.ts +3 -0
- package/dist/types/models/errors/types.d.ts +1 -1
- package/dist/types/utils/request/types.d.ts +1 -1
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +2 -2
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +2 -2
- package/dist/types-ts4.5/client/media-store/types.d.ts +3 -6
- package/dist/types-ts4.5/models/document.d.ts +3 -0
- package/dist/types-ts4.5/models/errors/types.d.ts +1 -1
- package/dist/types-ts4.5/utils/request/types.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 35.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#179845](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/179845)
|
|
8
|
+
[`8a03175bb502a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8a03175bb502a) -
|
|
9
|
+
Updated Delete Artifact interface
|
|
10
|
+
|
|
11
|
+
## 34.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#177492](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/177492)
|
|
16
|
+
[`77d01c4bd4ead`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/77d01c4bd4ead) -
|
|
17
|
+
Added password option and traceContext for getting Media Document Contents and Page
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 34.1.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -219,19 +219,19 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
219
219
|
};
|
|
220
220
|
}());
|
|
221
221
|
(0, _defineProperty2.default)(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
222
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id,
|
|
222
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
223
223
|
var file, updatedArtifacts, updatedFileState;
|
|
224
224
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
225
225
|
while (1) switch (_context3.prev = _context3.next) {
|
|
226
226
|
case 0:
|
|
227
227
|
_context3.next = 2;
|
|
228
|
-
return _this.mediaApi.deleteArtifact(id,
|
|
228
|
+
return _this.mediaApi.deleteArtifact(id, artifactName, collectionName, traceContext);
|
|
229
229
|
case 2:
|
|
230
230
|
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
231
231
|
file = _this.store.getState().files[id];
|
|
232
232
|
if (file && file.status === 'processed' && file.artifacts) {
|
|
233
233
|
updatedArtifacts = _objectSpread({}, file.artifacts);
|
|
234
|
-
delete updatedArtifacts[
|
|
234
|
+
delete updatedArtifacts[artifactName];
|
|
235
235
|
updatedFileState = _objectSpread(_objectSpread({}, file), {}, {
|
|
236
236
|
artifacts: updatedArtifacts
|
|
237
237
|
});
|
|
@@ -125,7 +125,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
125
125
|
};
|
|
126
126
|
}());
|
|
127
127
|
(0, _defineProperty2.default)(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
128
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id,
|
|
128
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
129
129
|
var metadata, authContext, options;
|
|
130
130
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
131
131
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -144,10 +144,13 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
144
144
|
};
|
|
145
145
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
146
146
|
authContext: authContext,
|
|
147
|
-
traceContext: traceContext
|
|
147
|
+
traceContext: traceContext,
|
|
148
|
+
params: {
|
|
149
|
+
collection: collectionName
|
|
150
|
+
}
|
|
148
151
|
});
|
|
149
152
|
_context3.next = 5;
|
|
150
|
-
return _this.request("/file/".concat(id, "/artifact/").concat(
|
|
153
|
+
return _this.request("/file/".concat(id, "/artifact/").concat(artifactName), options);
|
|
151
154
|
case 5:
|
|
152
155
|
case "end":
|
|
153
156
|
return _context3.stop();
|
|
@@ -665,35 +668,44 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
665
668
|
}, {
|
|
666
669
|
key: "getDocumentContent",
|
|
667
670
|
value: function () {
|
|
668
|
-
var _getDocumentContent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(id, options) {
|
|
669
|
-
var endpoint, metadata, requestOptions;
|
|
671
|
+
var _getDocumentContent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(id, options, traceContext) {
|
|
672
|
+
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
670
673
|
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
671
674
|
while (1) switch (_context12.prev = _context12.next) {
|
|
672
675
|
case 0:
|
|
673
|
-
|
|
676
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
677
|
+
// this is deliberate to avoid caching Password protected files
|
|
678
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
679
|
+
shouldCache = !options.password;
|
|
680
|
+
endpoint = shouldCache ? cdnFeatureFlag('contents') : 'contents';
|
|
674
681
|
metadata = {
|
|
675
682
|
method: 'GET',
|
|
676
683
|
endpoint: "/file/{fileId}/document/".concat(endpoint)
|
|
677
684
|
};
|
|
685
|
+
headers = options.password ? {
|
|
686
|
+
'x-document-authorization': "Basic ".concat(options.password)
|
|
687
|
+
} : {};
|
|
678
688
|
requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
679
689
|
authContext: {
|
|
680
690
|
collectionName: options.collectionName
|
|
681
691
|
},
|
|
692
|
+
headers: headers,
|
|
682
693
|
params: {
|
|
683
694
|
collection: options.collectionName,
|
|
684
695
|
pageStart: options.pageStart,
|
|
685
696
|
pageEnd: options.pageEnd,
|
|
686
|
-
'max-age': _constants.FILE_CACHE_MAX_AGE
|
|
687
|
-
}
|
|
697
|
+
'max-age': shouldCache ? _constants.FILE_CACHE_MAX_AGE : 0
|
|
698
|
+
},
|
|
699
|
+
traceContext: traceContext
|
|
688
700
|
});
|
|
689
701
|
return _context12.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
690
|
-
case
|
|
702
|
+
case 6:
|
|
691
703
|
case "end":
|
|
692
704
|
return _context12.stop();
|
|
693
705
|
}
|
|
694
706
|
}, _callee12, this);
|
|
695
707
|
}));
|
|
696
|
-
function getDocumentContent(_x44, _x45) {
|
|
708
|
+
function getDocumentContent(_x44, _x45, _x46) {
|
|
697
709
|
return _getDocumentContent.apply(this, arguments);
|
|
698
710
|
}
|
|
699
711
|
return getDocumentContent;
|
|
@@ -701,36 +713,44 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
701
713
|
}, {
|
|
702
714
|
key: "getDocumentPageImage",
|
|
703
715
|
value: function () {
|
|
704
|
-
var _getDocumentPageImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(id, options) {
|
|
705
|
-
var endpoint, metadata, requestOptions;
|
|
716
|
+
var _getDocumentPageImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(id, options, traceContext) {
|
|
717
|
+
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
706
718
|
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
707
719
|
while (1) switch (_context13.prev = _context13.next) {
|
|
708
720
|
case 0:
|
|
709
|
-
//
|
|
710
|
-
|
|
721
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
722
|
+
// this is deliberate to avoid caching Password protected files
|
|
723
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
724
|
+
shouldCache = !options.password;
|
|
725
|
+
endpoint = shouldCache ? cdnFeatureFlag('page') : 'page';
|
|
711
726
|
metadata = {
|
|
712
727
|
method: 'GET',
|
|
713
728
|
endpoint: "/file/{fileId}/document/".concat(endpoint)
|
|
714
729
|
};
|
|
730
|
+
headers = options.password ? {
|
|
731
|
+
'x-document-authorization': "Basic ".concat(options.password)
|
|
732
|
+
} : {};
|
|
715
733
|
requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
716
734
|
authContext: {
|
|
717
735
|
collectionName: options.collectionName
|
|
718
736
|
},
|
|
737
|
+
headers: headers,
|
|
719
738
|
params: {
|
|
720
739
|
collection: options.collectionName,
|
|
721
740
|
page: options.page,
|
|
722
741
|
zoom: options.zoom,
|
|
723
|
-
'max-age': _constants.FILE_CACHE_MAX_AGE
|
|
724
|
-
}
|
|
742
|
+
'max-age': shouldCache ? _constants.FILE_CACHE_MAX_AGE : 0
|
|
743
|
+
},
|
|
744
|
+
traceContext: traceContext
|
|
725
745
|
});
|
|
726
746
|
return _context13.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
727
|
-
case
|
|
747
|
+
case 6:
|
|
728
748
|
case "end":
|
|
729
749
|
return _context13.stop();
|
|
730
750
|
}
|
|
731
751
|
}, _callee13, this);
|
|
732
752
|
}));
|
|
733
|
-
function getDocumentPageImage(
|
|
753
|
+
function getDocumentPageImage(_x47, _x48, _x49) {
|
|
734
754
|
return _getDocumentPageImage.apply(this, arguments);
|
|
735
755
|
}
|
|
736
756
|
return getDocumentPageImage;
|
|
@@ -763,7 +783,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
763
783
|
}
|
|
764
784
|
}, _callee14, this);
|
|
765
785
|
}));
|
|
766
|
-
function appendChunksToUpload(
|
|
786
|
+
function appendChunksToUpload(_x50, _x51, _x52, _x53) {
|
|
767
787
|
return _appendChunksToUpload.apply(this, arguments);
|
|
768
788
|
}
|
|
769
789
|
return appendChunksToUpload;
|
|
@@ -845,7 +865,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
845
865
|
}
|
|
846
866
|
}, _callee15, this);
|
|
847
867
|
}));
|
|
848
|
-
function registerCopyIntents(
|
|
868
|
+
function registerCopyIntents(_x54, _x55, _x56) {
|
|
849
869
|
return _registerCopyIntents.apply(this, arguments);
|
|
850
870
|
}
|
|
851
871
|
return registerCopyIntents;
|
|
@@ -930,7 +950,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
930
950
|
}
|
|
931
951
|
}, _callee16, this);
|
|
932
952
|
}));
|
|
933
|
-
function request(
|
|
953
|
+
function request(_x57) {
|
|
934
954
|
return _request2.apply(this, arguments);
|
|
935
955
|
}
|
|
936
956
|
return request;
|
|
@@ -963,7 +983,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
963
983
|
}
|
|
964
984
|
}, _callee17);
|
|
965
985
|
}));
|
|
966
|
-
function testUrl(
|
|
986
|
+
function testUrl(_x58) {
|
|
967
987
|
return _testUrl.apply(this, arguments);
|
|
968
988
|
}
|
|
969
989
|
return testUrl;
|
|
@@ -291,6 +291,10 @@ function createRequestErrorReason(statusCode) {
|
|
|
291
291
|
return 'serverForbidden';
|
|
292
292
|
case 404:
|
|
293
293
|
return 'serverNotFound';
|
|
294
|
+
case 422:
|
|
295
|
+
return 'serverUnprocessableEntity';
|
|
296
|
+
case 423:
|
|
297
|
+
return 'serverEntityLocked';
|
|
294
298
|
case 429:
|
|
295
299
|
return 'serverRateLimited';
|
|
296
300
|
case 500:
|
|
@@ -155,8 +155,8 @@ export class FileFetcherImpl {
|
|
|
155
155
|
this.setFileState(id, mapMediaItemToFileState(id, itemDetails));
|
|
156
156
|
return data;
|
|
157
157
|
});
|
|
158
|
-
_defineProperty(this, "deleteArtifact", async (id,
|
|
159
|
-
await this.mediaApi.deleteArtifact(id,
|
|
158
|
+
_defineProperty(this, "deleteArtifact", async (id, artifactName, collectionName, traceContext) => {
|
|
159
|
+
await this.mediaApi.deleteArtifact(id, artifactName, collectionName, traceContext);
|
|
160
160
|
|
|
161
161
|
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
162
162
|
const file = this.store.getState().files[id];
|
|
@@ -164,7 +164,7 @@ export class FileFetcherImpl {
|
|
|
164
164
|
const updatedArtifacts = {
|
|
165
165
|
...file.artifacts
|
|
166
166
|
};
|
|
167
|
-
delete updatedArtifacts[
|
|
167
|
+
delete updatedArtifacts[artifactName];
|
|
168
168
|
const updatedFileState = {
|
|
169
169
|
...file,
|
|
170
170
|
artifacts: updatedArtifacts
|
|
@@ -87,7 +87,7 @@ export class MediaStore {
|
|
|
87
87
|
};
|
|
88
88
|
return this.request(`/file/${id}/artifact/binary`, options).then(createMapResponseToJson(metadata));
|
|
89
89
|
});
|
|
90
|
-
_defineProperty(this, "deleteArtifact", async (id,
|
|
90
|
+
_defineProperty(this, "deleteArtifact", async (id, artifactName, collectionName, traceContext) => {
|
|
91
91
|
const metadata = {
|
|
92
92
|
method: 'DELETE',
|
|
93
93
|
endpoint: '/file/{fileId}/artifact/{artifactName}'
|
|
@@ -103,9 +103,12 @@ export class MediaStore {
|
|
|
103
103
|
const options = {
|
|
104
104
|
...metadata,
|
|
105
105
|
authContext,
|
|
106
|
-
traceContext
|
|
106
|
+
traceContext,
|
|
107
|
+
params: {
|
|
108
|
+
collection: collectionName
|
|
109
|
+
}
|
|
107
110
|
};
|
|
108
|
-
await this.request(`/file/${id}/artifact/${
|
|
111
|
+
await this.request(`/file/${id}/artifact/${artifactName}`, options);
|
|
109
112
|
});
|
|
110
113
|
_defineProperty(this, "resolveAuth", authContext => resolveAuth(this.config.authProvider, authContext, this.config.authProviderTimeout));
|
|
111
114
|
_defineProperty(this, "resolveInitialAuth", () => resolveInitialAuth(this.config.initialAuth));
|
|
@@ -395,44 +398,61 @@ export class MediaStore {
|
|
|
395
398
|
};
|
|
396
399
|
return this.request(`/file/${id}/image/metadata`, options).then(createMapResponseToJson(metadata));
|
|
397
400
|
}
|
|
398
|
-
async getDocumentContent(id, options) {
|
|
399
|
-
|
|
401
|
+
async getDocumentContent(id, options, traceContext) {
|
|
402
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
403
|
+
// this is deliberate to avoid caching Password protected files
|
|
404
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
405
|
+
const shouldCache = !options.password;
|
|
406
|
+
const endpoint = shouldCache ? cdnFeatureFlag('contents') : 'contents';
|
|
400
407
|
const metadata = {
|
|
401
408
|
method: 'GET',
|
|
402
409
|
endpoint: `/file/{fileId}/document/${endpoint}`
|
|
403
410
|
};
|
|
411
|
+
const headers = options.password ? {
|
|
412
|
+
'x-document-authorization': `Basic ${options.password}`
|
|
413
|
+
} : {};
|
|
404
414
|
const requestOptions = {
|
|
405
415
|
...metadata,
|
|
406
416
|
authContext: {
|
|
407
417
|
collectionName: options.collectionName
|
|
408
418
|
},
|
|
419
|
+
headers,
|
|
409
420
|
params: {
|
|
410
421
|
collection: options.collectionName,
|
|
411
422
|
pageStart: options.pageStart,
|
|
412
423
|
pageEnd: options.pageEnd,
|
|
413
|
-
'max-age': FILE_CACHE_MAX_AGE
|
|
414
|
-
}
|
|
424
|
+
'max-age': shouldCache ? FILE_CACHE_MAX_AGE : 0
|
|
425
|
+
},
|
|
426
|
+
traceContext
|
|
415
427
|
};
|
|
416
428
|
return this.request(`/file/${id}/document/${endpoint}`, requestOptions).then(createMapResponseToJson(metadata));
|
|
417
429
|
}
|
|
418
|
-
async getDocumentPageImage(id, options) {
|
|
419
|
-
//
|
|
420
|
-
|
|
430
|
+
async getDocumentPageImage(id, options, traceContext) {
|
|
431
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
432
|
+
// this is deliberate to avoid caching Password protected files
|
|
433
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
434
|
+
const shouldCache = !options.password;
|
|
435
|
+
const endpoint = shouldCache ? cdnFeatureFlag('page') : 'page';
|
|
421
436
|
const metadata = {
|
|
422
437
|
method: 'GET',
|
|
423
438
|
endpoint: `/file/{fileId}/document/${endpoint}`
|
|
424
439
|
};
|
|
440
|
+
const headers = options.password ? {
|
|
441
|
+
'x-document-authorization': `Basic ${options.password}`
|
|
442
|
+
} : {};
|
|
425
443
|
const requestOptions = {
|
|
426
444
|
...metadata,
|
|
427
445
|
authContext: {
|
|
428
446
|
collectionName: options.collectionName
|
|
429
447
|
},
|
|
448
|
+
headers,
|
|
430
449
|
params: {
|
|
431
450
|
collection: options.collectionName,
|
|
432
451
|
page: options.page,
|
|
433
452
|
zoom: options.zoom,
|
|
434
|
-
'max-age': FILE_CACHE_MAX_AGE
|
|
435
|
-
}
|
|
453
|
+
'max-age': shouldCache ? FILE_CACHE_MAX_AGE : 0
|
|
454
|
+
},
|
|
455
|
+
traceContext
|
|
436
456
|
};
|
|
437
457
|
return this.request(`/file/${id}/document/${endpoint}`, requestOptions).then(createMapResponseToBlob(metadata));
|
|
438
458
|
}
|
|
@@ -184,6 +184,10 @@ export function createRequestErrorReason(statusCode) {
|
|
|
184
184
|
return 'serverForbidden';
|
|
185
185
|
case 404:
|
|
186
186
|
return 'serverNotFound';
|
|
187
|
+
case 422:
|
|
188
|
+
return 'serverUnprocessableEntity';
|
|
189
|
+
case 423:
|
|
190
|
+
return 'serverEntityLocked';
|
|
187
191
|
case 429:
|
|
188
192
|
return 'serverRateLimited';
|
|
189
193
|
case 500:
|
|
@@ -201,19 +201,19 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
201
201
|
};
|
|
202
202
|
}());
|
|
203
203
|
_defineProperty(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
204
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id,
|
|
204
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
205
205
|
var file, updatedArtifacts, updatedFileState;
|
|
206
206
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
207
207
|
while (1) switch (_context3.prev = _context3.next) {
|
|
208
208
|
case 0:
|
|
209
209
|
_context3.next = 2;
|
|
210
|
-
return _this.mediaApi.deleteArtifact(id,
|
|
210
|
+
return _this.mediaApi.deleteArtifact(id, artifactName, collectionName, traceContext);
|
|
211
211
|
case 2:
|
|
212
212
|
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
213
213
|
file = _this.store.getState().files[id];
|
|
214
214
|
if (file && file.status === 'processed' && file.artifacts) {
|
|
215
215
|
updatedArtifacts = _objectSpread({}, file.artifacts);
|
|
216
|
-
delete updatedArtifacts[
|
|
216
|
+
delete updatedArtifacts[artifactName];
|
|
217
217
|
updatedFileState = _objectSpread(_objectSpread({}, file), {}, {
|
|
218
218
|
artifacts: updatedArtifacts
|
|
219
219
|
});
|
|
@@ -119,7 +119,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
119
119
|
};
|
|
120
120
|
}());
|
|
121
121
|
_defineProperty(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
122
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id,
|
|
122
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
123
123
|
var metadata, authContext, options;
|
|
124
124
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
125
125
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -138,10 +138,13 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
138
138
|
};
|
|
139
139
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
140
140
|
authContext: authContext,
|
|
141
|
-
traceContext: traceContext
|
|
141
|
+
traceContext: traceContext,
|
|
142
|
+
params: {
|
|
143
|
+
collection: collectionName
|
|
144
|
+
}
|
|
142
145
|
});
|
|
143
146
|
_context3.next = 5;
|
|
144
|
-
return _this.request("/file/".concat(id, "/artifact/").concat(
|
|
147
|
+
return _this.request("/file/".concat(id, "/artifact/").concat(artifactName), options);
|
|
145
148
|
case 5:
|
|
146
149
|
case "end":
|
|
147
150
|
return _context3.stop();
|
|
@@ -659,35 +662,44 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
659
662
|
}, {
|
|
660
663
|
key: "getDocumentContent",
|
|
661
664
|
value: function () {
|
|
662
|
-
var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, options) {
|
|
663
|
-
var endpoint, metadata, requestOptions;
|
|
665
|
+
var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, options, traceContext) {
|
|
666
|
+
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
664
667
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
665
668
|
while (1) switch (_context12.prev = _context12.next) {
|
|
666
669
|
case 0:
|
|
667
|
-
|
|
670
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
671
|
+
// this is deliberate to avoid caching Password protected files
|
|
672
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
673
|
+
shouldCache = !options.password;
|
|
674
|
+
endpoint = shouldCache ? cdnFeatureFlag('contents') : 'contents';
|
|
668
675
|
metadata = {
|
|
669
676
|
method: 'GET',
|
|
670
677
|
endpoint: "/file/{fileId}/document/".concat(endpoint)
|
|
671
678
|
};
|
|
679
|
+
headers = options.password ? {
|
|
680
|
+
'x-document-authorization': "Basic ".concat(options.password)
|
|
681
|
+
} : {};
|
|
672
682
|
requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
673
683
|
authContext: {
|
|
674
684
|
collectionName: options.collectionName
|
|
675
685
|
},
|
|
686
|
+
headers: headers,
|
|
676
687
|
params: {
|
|
677
688
|
collection: options.collectionName,
|
|
678
689
|
pageStart: options.pageStart,
|
|
679
690
|
pageEnd: options.pageEnd,
|
|
680
|
-
'max-age': FILE_CACHE_MAX_AGE
|
|
681
|
-
}
|
|
691
|
+
'max-age': shouldCache ? FILE_CACHE_MAX_AGE : 0
|
|
692
|
+
},
|
|
693
|
+
traceContext: traceContext
|
|
682
694
|
});
|
|
683
695
|
return _context12.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToJson(metadata)));
|
|
684
|
-
case
|
|
696
|
+
case 6:
|
|
685
697
|
case "end":
|
|
686
698
|
return _context12.stop();
|
|
687
699
|
}
|
|
688
700
|
}, _callee12, this);
|
|
689
701
|
}));
|
|
690
|
-
function getDocumentContent(_x44, _x45) {
|
|
702
|
+
function getDocumentContent(_x44, _x45, _x46) {
|
|
691
703
|
return _getDocumentContent.apply(this, arguments);
|
|
692
704
|
}
|
|
693
705
|
return getDocumentContent;
|
|
@@ -695,36 +707,44 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
695
707
|
}, {
|
|
696
708
|
key: "getDocumentPageImage",
|
|
697
709
|
value: function () {
|
|
698
|
-
var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, options) {
|
|
699
|
-
var endpoint, metadata, requestOptions;
|
|
710
|
+
var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, options, traceContext) {
|
|
711
|
+
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
700
712
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
701
713
|
while (1) switch (_context13.prev = _context13.next) {
|
|
702
714
|
case 0:
|
|
703
|
-
//
|
|
704
|
-
|
|
715
|
+
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
716
|
+
// this is deliberate to avoid caching Password protected files
|
|
717
|
+
// Note: this should be removed once endpoint implements server side Cache-Control headers
|
|
718
|
+
shouldCache = !options.password;
|
|
719
|
+
endpoint = shouldCache ? cdnFeatureFlag('page') : 'page';
|
|
705
720
|
metadata = {
|
|
706
721
|
method: 'GET',
|
|
707
722
|
endpoint: "/file/{fileId}/document/".concat(endpoint)
|
|
708
723
|
};
|
|
724
|
+
headers = options.password ? {
|
|
725
|
+
'x-document-authorization': "Basic ".concat(options.password)
|
|
726
|
+
} : {};
|
|
709
727
|
requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
710
728
|
authContext: {
|
|
711
729
|
collectionName: options.collectionName
|
|
712
730
|
},
|
|
731
|
+
headers: headers,
|
|
713
732
|
params: {
|
|
714
733
|
collection: options.collectionName,
|
|
715
734
|
page: options.page,
|
|
716
735
|
zoom: options.zoom,
|
|
717
|
-
'max-age': FILE_CACHE_MAX_AGE
|
|
718
|
-
}
|
|
736
|
+
'max-age': shouldCache ? FILE_CACHE_MAX_AGE : 0
|
|
737
|
+
},
|
|
738
|
+
traceContext: traceContext
|
|
719
739
|
});
|
|
720
740
|
return _context13.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToBlob(metadata)));
|
|
721
|
-
case
|
|
741
|
+
case 6:
|
|
722
742
|
case "end":
|
|
723
743
|
return _context13.stop();
|
|
724
744
|
}
|
|
725
745
|
}, _callee13, this);
|
|
726
746
|
}));
|
|
727
|
-
function getDocumentPageImage(
|
|
747
|
+
function getDocumentPageImage(_x47, _x48, _x49) {
|
|
728
748
|
return _getDocumentPageImage.apply(this, arguments);
|
|
729
749
|
}
|
|
730
750
|
return getDocumentPageImage;
|
|
@@ -757,7 +777,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
757
777
|
}
|
|
758
778
|
}, _callee14, this);
|
|
759
779
|
}));
|
|
760
|
-
function appendChunksToUpload(
|
|
780
|
+
function appendChunksToUpload(_x50, _x51, _x52, _x53) {
|
|
761
781
|
return _appendChunksToUpload.apply(this, arguments);
|
|
762
782
|
}
|
|
763
783
|
return appendChunksToUpload;
|
|
@@ -839,7 +859,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
839
859
|
}
|
|
840
860
|
}, _callee15, this);
|
|
841
861
|
}));
|
|
842
|
-
function registerCopyIntents(
|
|
862
|
+
function registerCopyIntents(_x54, _x55, _x56) {
|
|
843
863
|
return _registerCopyIntents.apply(this, arguments);
|
|
844
864
|
}
|
|
845
865
|
return registerCopyIntents;
|
|
@@ -924,7 +944,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
924
944
|
}
|
|
925
945
|
}, _callee16, this);
|
|
926
946
|
}));
|
|
927
|
-
function request(
|
|
947
|
+
function request(_x57) {
|
|
928
948
|
return _request2.apply(this, arguments);
|
|
929
949
|
}
|
|
930
950
|
return request;
|
|
@@ -957,7 +977,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
957
977
|
}
|
|
958
978
|
}, _callee17);
|
|
959
979
|
}));
|
|
960
|
-
function testUrl(
|
|
980
|
+
function testUrl(_x58) {
|
|
961
981
|
return _testUrl.apply(this, arguments);
|
|
962
982
|
}
|
|
963
983
|
return testUrl;
|
|
@@ -267,6 +267,10 @@ export function createRequestErrorReason(statusCode) {
|
|
|
267
267
|
return 'serverForbidden';
|
|
268
268
|
case 404:
|
|
269
269
|
return 'serverNotFound';
|
|
270
|
+
case 422:
|
|
271
|
+
return 'serverUnprocessableEntity';
|
|
272
|
+
case 423:
|
|
273
|
+
return 'serverEntityLocked';
|
|
270
274
|
case 429:
|
|
271
275
|
return 'serverRateLimited';
|
|
272
276
|
case 500:
|
|
@@ -9,7 +9,7 @@ import { type MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
|
9
9
|
import { type Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
10
10
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
11
11
|
import { type FilePreview, type FileState, type MediaStore } from '@atlaskit/media-state';
|
|
12
|
-
import { type UploadArtifactParams
|
|
12
|
+
import { type UploadArtifactParams } from '../media-store/types';
|
|
13
13
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason } from './error';
|
|
14
14
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
15
15
|
export interface CopySourceFile {
|
|
@@ -42,7 +42,7 @@ export interface FileFetcher {
|
|
|
42
42
|
getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
|
|
43
43
|
registerCopyIntent(id: string, collectionName?: string): Promise<void>;
|
|
44
44
|
uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaItemDetails>;
|
|
45
|
-
deleteArtifact(id: string,
|
|
45
|
+
deleteArtifact(id: string, artifactName: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
46
46
|
/** @exprimental This is exprimental for the purposes of COMMIT-18082 and is prone to breaking changes */
|
|
47
47
|
getVideoDurations(files: Array<{
|
|
48
48
|
id: string;
|
|
@@ -30,8 +30,8 @@ export declare class MediaStore implements MediaApi {
|
|
|
30
30
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
31
31
|
metadata: ImageMetadata;
|
|
32
32
|
}>;
|
|
33
|
-
getDocumentContent(id: string, options: GetDocumentContentOptions): Promise<DocumentPageRangeContent>;
|
|
34
|
-
getDocumentPageImage(id: string, options: GetDocumentPageImage): Promise<Blob>;
|
|
33
|
+
getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
|
|
34
|
+
getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
35
35
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
36
36
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
37
37
|
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
@@ -164,9 +164,6 @@ export type UploadArtifactCaptionsParams = {
|
|
|
164
164
|
language: string;
|
|
165
165
|
};
|
|
166
166
|
export type UploadArtifactParams = UploadArtifactCaptionsParams;
|
|
167
|
-
export type DeleteArtifactParams = {
|
|
168
|
-
artifactName: string;
|
|
169
|
-
};
|
|
170
167
|
export interface MediaApi {
|
|
171
168
|
removeCollectionFile: (id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
172
169
|
createUpload: (createUpTo: number, collectionName?: string, traceContext?: MediaTraceContext, chunkChunkHashAlgorithm?: ChunkHashAlgorithm) => Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
@@ -182,7 +179,7 @@ export interface MediaApi {
|
|
|
182
179
|
getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
|
|
183
180
|
getArtifactBinary(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, options: GetArtifactBinaryOptions): Promise<Blob>;
|
|
184
181
|
uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaItemDetails>>;
|
|
185
|
-
deleteArtifact(id: string,
|
|
182
|
+
deleteArtifact(id: string, artifactName: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
186
183
|
getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
|
|
187
184
|
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
188
185
|
getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
|
|
@@ -202,7 +199,7 @@ export interface MediaApi {
|
|
|
202
199
|
resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
|
|
203
200
|
resolveInitialAuth: () => Auth;
|
|
204
201
|
/** @exprimental This is exprimental for the purposes of enabling the document viewer and not ready for external use, it is prone to breaking changes */
|
|
205
|
-
getDocumentContent(id: string, options: GetDocumentContentOptions): Promise<DocumentPageRangeContent>;
|
|
202
|
+
getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
|
|
206
203
|
/** @exprimental This is exprimental for the purposes of enabling the document viewer and not ready for external use, it is prone to breaking changes */
|
|
207
|
-
getDocumentPageImage(id: string, options: GetDocumentPageImage): Promise<Blob>;
|
|
204
|
+
getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
208
205
|
}
|
|
@@ -69,6 +69,7 @@ export type DocumentPageContent = {
|
|
|
69
69
|
lines: readonly Line[];
|
|
70
70
|
annotations: DocumentAnnotations;
|
|
71
71
|
links: readonly DocumentLink[];
|
|
72
|
+
password?: string;
|
|
72
73
|
};
|
|
73
74
|
export type DocumentPageRangeContent = {
|
|
74
75
|
total_pages: number;
|
|
@@ -82,10 +83,12 @@ export type GetDocumentContentOptions = {
|
|
|
82
83
|
pageEnd: number;
|
|
83
84
|
collectionName?: string;
|
|
84
85
|
maxAge?: number;
|
|
86
|
+
password?: string;
|
|
85
87
|
};
|
|
86
88
|
export type GetDocumentPageImage = {
|
|
87
89
|
page: number;
|
|
88
90
|
zoom: number;
|
|
89
91
|
collectionName?: string;
|
|
90
92
|
maxAge?: number;
|
|
93
|
+
password?: string;
|
|
91
94
|
};
|
|
@@ -2,7 +2,7 @@ import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
|
2
2
|
export interface SerializableObject {
|
|
3
3
|
[key: string]: string | number | boolean | null | undefined | SerializableObject;
|
|
4
4
|
}
|
|
5
|
-
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
5
|
+
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'serverUnprocessableEntity' | 'serverEntityLocked' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
6
6
|
export type MediaClientErrorMetadata = SerializableObject & {
|
|
7
7
|
traceContext?: MediaTraceContext;
|
|
8
8
|
};
|
|
@@ -36,7 +36,7 @@ export type CreateUrlOptions = {
|
|
|
36
36
|
readonly params?: RequestParams;
|
|
37
37
|
readonly auth?: Auth;
|
|
38
38
|
};
|
|
39
|
-
export type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError';
|
|
39
|
+
export type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnprocessableEntity' | 'serverEntityLocked' | 'serverUnexpectedError';
|
|
40
40
|
export type RequestErrorMetadata = RequestMetadata & {
|
|
41
41
|
readonly attempts?: number;
|
|
42
42
|
readonly clientExhaustedRetries?: boolean;
|
|
@@ -9,7 +9,7 @@ import { type MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
|
9
9
|
import { type Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
10
10
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
11
11
|
import { type FilePreview, type FileState, type MediaStore } from '@atlaskit/media-state';
|
|
12
|
-
import { type UploadArtifactParams
|
|
12
|
+
import { type UploadArtifactParams } from '../media-store/types';
|
|
13
13
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason } from './error';
|
|
14
14
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
15
15
|
export interface CopySourceFile {
|
|
@@ -42,7 +42,7 @@ export interface FileFetcher {
|
|
|
42
42
|
getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
|
|
43
43
|
registerCopyIntent(id: string, collectionName?: string): Promise<void>;
|
|
44
44
|
uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaItemDetails>;
|
|
45
|
-
deleteArtifact(id: string,
|
|
45
|
+
deleteArtifact(id: string, artifactName: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
46
46
|
/** @exprimental This is exprimental for the purposes of COMMIT-18082 and is prone to breaking changes */
|
|
47
47
|
getVideoDurations(files: Array<{
|
|
48
48
|
id: string;
|
|
@@ -30,8 +30,8 @@ export declare class MediaStore implements MediaApi {
|
|
|
30
30
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
31
31
|
metadata: ImageMetadata;
|
|
32
32
|
}>;
|
|
33
|
-
getDocumentContent(id: string, options: GetDocumentContentOptions): Promise<DocumentPageRangeContent>;
|
|
34
|
-
getDocumentPageImage(id: string, options: GetDocumentPageImage): Promise<Blob>;
|
|
33
|
+
getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
|
|
34
|
+
getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
35
35
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
36
36
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
37
37
|
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
@@ -164,9 +164,6 @@ export type UploadArtifactCaptionsParams = {
|
|
|
164
164
|
language: string;
|
|
165
165
|
};
|
|
166
166
|
export type UploadArtifactParams = UploadArtifactCaptionsParams;
|
|
167
|
-
export type DeleteArtifactParams = {
|
|
168
|
-
artifactName: string;
|
|
169
|
-
};
|
|
170
167
|
export interface MediaApi {
|
|
171
168
|
removeCollectionFile: (id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
172
169
|
createUpload: (createUpTo: number, collectionName?: string, traceContext?: MediaTraceContext, chunkChunkHashAlgorithm?: ChunkHashAlgorithm) => Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
@@ -182,7 +179,7 @@ export interface MediaApi {
|
|
|
182
179
|
getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
|
|
183
180
|
getArtifactBinary(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, options: GetArtifactBinaryOptions): Promise<Blob>;
|
|
184
181
|
uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaItemDetails>>;
|
|
185
|
-
deleteArtifact(id: string,
|
|
182
|
+
deleteArtifact(id: string, artifactName: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
186
183
|
getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
|
|
187
184
|
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
188
185
|
getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
|
|
@@ -202,7 +199,7 @@ export interface MediaApi {
|
|
|
202
199
|
resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
|
|
203
200
|
resolveInitialAuth: () => Auth;
|
|
204
201
|
/** @exprimental This is exprimental for the purposes of enabling the document viewer and not ready for external use, it is prone to breaking changes */
|
|
205
|
-
getDocumentContent(id: string, options: GetDocumentContentOptions): Promise<DocumentPageRangeContent>;
|
|
202
|
+
getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
|
|
206
203
|
/** @exprimental This is exprimental for the purposes of enabling the document viewer and not ready for external use, it is prone to breaking changes */
|
|
207
|
-
getDocumentPageImage(id: string, options: GetDocumentPageImage): Promise<Blob>;
|
|
204
|
+
getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
208
205
|
}
|
|
@@ -69,6 +69,7 @@ export type DocumentPageContent = {
|
|
|
69
69
|
lines: readonly Line[];
|
|
70
70
|
annotations: DocumentAnnotations;
|
|
71
71
|
links: readonly DocumentLink[];
|
|
72
|
+
password?: string;
|
|
72
73
|
};
|
|
73
74
|
export type DocumentPageRangeContent = {
|
|
74
75
|
total_pages: number;
|
|
@@ -82,10 +83,12 @@ export type GetDocumentContentOptions = {
|
|
|
82
83
|
pageEnd: number;
|
|
83
84
|
collectionName?: string;
|
|
84
85
|
maxAge?: number;
|
|
86
|
+
password?: string;
|
|
85
87
|
};
|
|
86
88
|
export type GetDocumentPageImage = {
|
|
87
89
|
page: number;
|
|
88
90
|
zoom: number;
|
|
89
91
|
collectionName?: string;
|
|
90
92
|
maxAge?: number;
|
|
93
|
+
password?: string;
|
|
91
94
|
};
|
|
@@ -2,7 +2,7 @@ import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
|
2
2
|
export interface SerializableObject {
|
|
3
3
|
[key: string]: string | number | boolean | null | undefined | SerializableObject;
|
|
4
4
|
}
|
|
5
|
-
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
5
|
+
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'serverUnprocessableEntity' | 'serverEntityLocked' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
6
6
|
export type MediaClientErrorMetadata = SerializableObject & {
|
|
7
7
|
traceContext?: MediaTraceContext;
|
|
8
8
|
};
|
|
@@ -36,7 +36,7 @@ export type CreateUrlOptions = {
|
|
|
36
36
|
readonly params?: RequestParams;
|
|
37
37
|
readonly auth?: Auth;
|
|
38
38
|
};
|
|
39
|
-
export type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError';
|
|
39
|
+
export type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnprocessableEntity' | 'serverEntityLocked' | 'serverUnexpectedError';
|
|
40
40
|
export type RequestErrorMetadata = RequestMetadata & {
|
|
41
41
|
readonly attempts?: number;
|
|
42
42
|
readonly clientExhaustedRetries?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.0.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/chunkinator": "^7.0.0",
|
|
38
|
-
"@atlaskit/media-common": "^12.
|
|
38
|
+
"@atlaskit/media-common": "^12.3.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"dataloader": "^2.1.0",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@atlaskit/media-core": "^37.0.0",
|
|
54
|
-
"@atlaskit/media-state": "^1.
|
|
54
|
+
"@atlaskit/media-state": "^1.7.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@atlaskit/media-core": "^37.0.0",
|
|
58
|
-
"@atlaskit/media-state": "^1.
|
|
58
|
+
"@atlaskit/media-state": "^1.7.0",
|
|
59
59
|
"@atlaskit/ssr": "workspace:^",
|
|
60
60
|
"@atlaskit/tokens": "^5.4.0",
|
|
61
61
|
"@atlassian/feature-flags-test-utils": "^0.3.0",
|