@atlaskit/media-client 34.2.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 CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## 34.2.0
4
12
 
5
13
  ### 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, params, collectionName, traceContext) {
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, params, collectionName, traceContext);
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[params.artifactName];
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, params, collectionName, traceContext) {
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(params.artifactName), options);
153
+ return _this.request("/file/".concat(id, "/artifact/").concat(artifactName), options);
151
154
  case 5:
152
155
  case "end":
153
156
  return _context3.stop();
@@ -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, params, collectionName, traceContext) => {
159
- await this.mediaApi.deleteArtifact(id, params, collectionName, traceContext);
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[params.artifactName];
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, params, collectionName, traceContext) => {
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/${params.artifactName}`, options);
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));
@@ -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, params, collectionName, traceContext) {
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, params, collectionName, traceContext);
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[params.artifactName];
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, params, collectionName, traceContext) {
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(params.artifactName), options);
147
+ return _this.request("/file/".concat(id, "/artifact/").concat(artifactName), options);
145
148
  case 5:
146
149
  case "end":
147
150
  return _context3.stop();
@@ -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, type DeleteArtifactParams } from '../media-store/types';
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, params: DeleteArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
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;
@@ -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, params: DeleteArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
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<{
@@ -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, type DeleteArtifactParams } from '../media-store/types';
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, params: DeleteArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
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;
@@ -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, params: DeleteArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
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<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "34.2.0",
3
+ "version": "35.0.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -51,11 +51,11 @@
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@atlaskit/media-core": "^37.0.0",
54
- "@atlaskit/media-state": "^1.6.0"
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.6.0",
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",