@atlaskit/media-client 20.2.0 → 21.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cjs/client/file-fetcher/index.js +15 -13
  3. package/dist/cjs/client/media-client.js +27 -7
  4. package/dist/cjs/client/media-store/index.js +86 -112
  5. package/dist/cjs/client/media-store/resolveAuth.js +4 -3
  6. package/dist/cjs/client/stargate-client.js +4 -3
  7. package/dist/cjs/index.js +0 -13
  8. package/dist/cjs/models/media.js +4 -5
  9. package/dist/cjs/uploader/index.js +14 -11
  10. package/dist/cjs/utils/createFileDataLoader.js +8 -6
  11. package/dist/cjs/utils/getDimensionsFromBlob.js +4 -3
  12. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +4 -3
  13. package/dist/cjs/utils/hashing/hasherCreator.js +3 -3
  14. package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
  15. package/dist/cjs/utils/mobileUpload/helpers.js +4 -3
  16. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +4 -3
  17. package/dist/cjs/utils/polling/index.js +4 -3
  18. package/dist/cjs/utils/request/helpers.js +14 -13
  19. package/dist/cjs/utils/request/index.js +4 -3
  20. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +4 -3
  21. package/dist/cjs/version.json +1 -1
  22. package/dist/es2019/client/media-client.js +3 -2
  23. package/dist/es2019/client/media-store/index.js +0 -9
  24. package/dist/es2019/index.js +1 -2
  25. package/dist/es2019/models/media.js +3 -1
  26. package/dist/es2019/uploader/index.js +3 -0
  27. package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
  28. package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
  29. package/dist/es2019/version.json +1 -1
  30. package/dist/esm/client/file-fetcher/index.js +14 -13
  31. package/dist/esm/client/media-client.js +28 -7
  32. package/dist/esm/client/media-store/index.js +86 -112
  33. package/dist/esm/client/media-store/resolveAuth.js +4 -3
  34. package/dist/esm/client/stargate-client.js +4 -3
  35. package/dist/esm/index.js +1 -2
  36. package/dist/esm/models/media.js +3 -3
  37. package/dist/esm/uploader/index.js +15 -11
  38. package/dist/esm/utils/createFileDataLoader.js +6 -5
  39. package/dist/esm/utils/getDimensionsFromBlob.js +4 -3
  40. package/dist/esm/utils/getVideoDimensionsFromBlob.js +4 -3
  41. package/dist/esm/utils/hashing/hasherCreator.js +4 -3
  42. package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
  43. package/dist/esm/utils/mobileUpload/helpers.js +4 -3
  44. package/dist/esm/utils/mobileUpload/stateMachine/index.js +4 -3
  45. package/dist/esm/utils/polling/index.js +4 -3
  46. package/dist/esm/utils/request/helpers.js +14 -13
  47. package/dist/esm/utils/request/index.js +4 -3
  48. package/dist/esm/utils/shouldFetchRemoteFileStates.js +4 -3
  49. package/dist/esm/version.json +1 -1
  50. package/dist/types/client/__mocks__/media-client.d.ts +0 -2
  51. package/dist/types/client/file-fetcher/index.d.ts +4 -4
  52. package/dist/types/client/media-client.d.ts +1 -2
  53. package/dist/types/client/media-store/index.d.ts +2 -13
  54. package/dist/types/index.d.ts +3 -5
  55. package/dist/types/models/file-state.d.ts +2 -2
  56. package/dist/types/models/media.d.ts +1 -21
  57. package/dist/types/utils/createFileDataLoader.d.ts +2 -2
  58. package/dist/types/utils/createMediaSubject.d.ts +2 -2
  59. package/dist/types/utils/detectEmptyFile.d.ts +2 -2
  60. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
  61. package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
  62. package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
  63. package/package.json +4 -4
  64. package/report.api.md +46 -126
  65. package/dist/cjs/client/collection-fetcher.js +0 -98
  66. package/dist/cjs/models/media-subscribable.js +0 -5
  67. package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
  68. package/dist/es2019/client/collection-fetcher.js +0 -38
  69. package/dist/es2019/models/media-subscribable.js +0 -1
  70. package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
  71. package/dist/esm/client/collection-fetcher.js +0 -89
  72. package/dist/esm/models/media-subscribable.js +0 -1
  73. package/dist/esm/utils/deprecatedEndpointError.js +0 -34
  74. package/dist/types/client/collection-fetcher.d.ts +0 -42
  75. package/dist/types/models/media-subscribable.d.ts +0 -3
  76. package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
package/report.api.md CHANGED
@@ -80,34 +80,8 @@ export type ClientOptions = {
80
80
  };
81
81
 
82
82
  // @public (undocumented)
83
- export class CollectionFetcher {
84
- constructor(mediaStore: MediaStore);
85
- // @deprecated (undocumented)
86
- getItems(
87
- collectionName: string,
88
- params?: MediaStoreGetCollectionItemsParams,
89
- traceContext?: MediaTraceContext,
90
- ): MediaSubscribable<MediaCollectionItem[]>;
91
- // @deprecated (undocumented)
92
- loadNextPage(
93
- collectionName: string,
94
- params?: MediaStoreGetCollectionItemsParams,
95
- traceContext?: MediaTraceContext,
96
- ): Promise<void>;
97
- // (undocumented)
98
- readonly mediaStore: MediaStore;
99
- // (undocumented)
100
- removeFile(
101
- id: string,
102
- collectionName: string,
103
- occurrenceKey?: string,
104
- traceContext?: MediaTraceContext,
105
- ): Promise<void>;
106
- }
107
-
108
- // @public (undocumented)
109
- type CompletionObserver<T> = PartialObserver<T> &
110
- Required<Pick<PartialObserver<T>, 'complete'>>;
83
+ type CompletionObserver = PartialObserver &
84
+ Required<Pick<PartialObserver, 'complete'>>;
111
85
 
112
86
  // @public (undocumented)
113
87
  export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
@@ -144,14 +118,14 @@ export interface CreatedTouchedFile {
144
118
  }
145
119
 
146
120
  // @public (undocumented)
147
- export function createMediaSubject<T extends MediaSubscribableItem>(
121
+ export function createMediaSubject<T extends FileState>(
148
122
  initialState?: Error | T,
149
123
  ): ReplaySubject<T>;
150
124
 
151
125
  // @public (undocumented)
152
- export function createMediaSubscribable<T extends MediaSubscribableItem>(
153
- mediaSubscribableItem?: Error | T,
154
- ): MediaSubscribable<T>;
126
+ export function createMediaSubscribable(
127
+ item?: Error | FileState,
128
+ ): MediaSubscribable;
155
129
 
156
130
  // @public (undocumented)
157
131
  export function createUrl(
@@ -204,8 +178,7 @@ export interface ErrorFileState extends BaseFileState {
204
178
  }
205
179
 
206
180
  // @public (undocumented)
207
- type ErrorObserver<T> = PartialObserver<T> &
208
- Required<Pick<PartialObserver<T>, 'error'>>;
181
+ type ErrorObserver = PartialObserver & Required<Pick<PartialObserver, 'error'>>;
209
182
 
210
183
  // @public (undocumented)
211
184
  export type EventPayloadListener<
@@ -286,10 +259,7 @@ export interface FileFetcher {
286
259
  // (undocumented)
287
260
  getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
288
261
  // (undocumented)
289
- getFileState(
290
- id: string,
291
- options?: GetFileOptions,
292
- ): MediaSubscribable<FileState>;
262
+ getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
293
263
  // (undocumented)
294
264
  touchFiles(
295
265
  descriptors: TouchFileDescriptor[],
@@ -302,7 +272,8 @@ export interface FileFetcher {
302
272
  controller?: UploadController,
303
273
  uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
304
274
  traceContext?: MediaTraceContext,
305
- ): MediaSubscribable<FileState>;
275
+ featureFlags?: MediaFeatureFlags,
276
+ ): MediaSubscribable;
306
277
  // (undocumented)
307
278
  uploadExternal(
308
279
  url: string,
@@ -389,10 +360,7 @@ export class FileFetcherImpl implements FileFetcher {
389
360
  // (undocumented)
390
361
  getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
391
362
  // (undocumented)
392
- getFileState(
393
- id: string,
394
- options?: GetFileOptions,
395
- ): MediaSubscribable<FileState>;
363
+ getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
396
364
  // (undocumented)
397
365
  touchFiles(
398
366
  descriptors: TouchFileDescriptor[],
@@ -405,7 +373,8 @@ export class FileFetcherImpl implements FileFetcher {
405
373
  controller?: UploadController,
406
374
  uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
407
375
  traceContext?: MediaTraceContext,
408
- ): MediaSubscribable<FileState>;
376
+ featureFlags?: MediaFeatureFlags,
377
+ ): MediaSubscribable;
409
378
  // (undocumented)
410
379
  uploadExternal(
411
380
  url: string,
@@ -620,11 +589,6 @@ export function isMediaClientError(error: any): error is MediaClientError<{
620
589
  reason: MediaClientErrorReason;
621
590
  }>;
622
591
 
623
- // @public (undocumented)
624
- export const isMediaCollectionItemFullDetails: (
625
- mediaCollectionItem: MediaCollectionItemDetails,
626
- ) => mediaCollectionItem is MediaCollectionItemFullDetails;
627
-
628
592
  // @public (undocumented)
629
593
  export function isMediaStoreError(err: Error): err is MediaStoreError;
630
594
 
@@ -695,7 +659,7 @@ export const mapMediaFileToFileState: (
695
659
  // @public (undocumented)
696
660
  export const mapMediaItemToFileState: (
697
661
  id: string,
698
- item: MediaCollectionItemFullDetails,
662
+ item: MediaItemDetails,
699
663
  ) => FileState;
700
664
 
701
665
  // @public @deprecated (undocumented)
@@ -756,8 +720,6 @@ export class MediaClient {
756
720
  featureFlags?: MediaFeatureFlags | undefined,
757
721
  );
758
722
  // (undocumented)
759
- readonly collection: CollectionFetcher;
760
- // (undocumented)
761
723
  readonly config: MediaClientConfig;
762
724
  // (undocumented)
763
725
  emit<E extends keyof UploadEventPayloadMap>(
@@ -805,6 +767,13 @@ export class MediaClient {
805
767
  listener: EventPayloadListener<UploadEventPayloadMap, E>,
806
768
  ): void;
807
769
  // (undocumented)
770
+ removeFileFromCollection(
771
+ id: string,
772
+ collectionName: string,
773
+ occurrenceKey?: string,
774
+ traceContext?: MediaTraceContext,
775
+ ): Promise<void>;
776
+ // (undocumented)
808
777
  readonly stargate: StargateClient;
809
778
  }
810
779
 
@@ -847,50 +816,6 @@ export type MediaClientErrorReason =
847
816
  | 'tokenExpired'
848
817
  | 'zeroVersionFile';
849
818
 
850
- // @public (undocumented)
851
- export type MediaCollection = {
852
- readonly name: string;
853
- readonly createdAt: number;
854
- };
855
-
856
- // @public (undocumented)
857
- export type MediaCollectionItem = {
858
- readonly id: string;
859
- readonly insertedAt: number;
860
- readonly occurrenceKey: string;
861
- readonly details: MediaCollectionItemDetails;
862
- };
863
-
864
- // @public (undocumented)
865
- export type MediaCollectionItemDetails =
866
- | MediaCollectionItemFullDetails
867
- | MediaCollectionItemMinimalDetails;
868
-
869
- // @public (undocumented)
870
- export type MediaCollectionItemFullDetails = {
871
- readonly mediaType: MediaType;
872
- readonly mimeType: string;
873
- readonly name: string;
874
- readonly processingStatus: MediaFileProcessingStatus;
875
- readonly size: number;
876
- readonly artifacts: MediaFileArtifacts;
877
- readonly representations: MediaRepresentations;
878
- readonly createdAt?: number;
879
- readonly metadataTraceContext?: MediaTraceContext;
880
- };
881
-
882
- // @public (undocumented)
883
- export type MediaCollectionItemMinimalDetails = {
884
- readonly name: string;
885
- readonly size: number;
886
- };
887
-
888
- // @public (undocumented)
889
- export type MediaCollectionItems = {
890
- readonly contents: MediaCollectionItem[];
891
- readonly nextInclusiveStartKey?: string;
892
- };
893
-
894
819
  // @public (undocumented)
895
820
  export type MediaFile = {
896
821
  readonly id: string;
@@ -926,15 +851,28 @@ export interface MediaFileArtifacts {
926
851
  // @public (undocumented)
927
852
  export type MediaFileProcessingStatus = 'failed' | 'pending' | 'succeeded';
928
853
 
854
+ // @public (undocumented)
855
+ export type MediaItemDetails = {
856
+ readonly mediaType: MediaType;
857
+ readonly mimeType: string;
858
+ readonly name: string;
859
+ readonly processingStatus: MediaFileProcessingStatus;
860
+ readonly size: number;
861
+ readonly artifacts: MediaFileArtifacts;
862
+ readonly representations: MediaRepresentations;
863
+ readonly createdAt?: number;
864
+ readonly metadataTraceContext?: MediaTraceContext;
865
+ };
866
+
929
867
  // @public (undocumented)
930
868
  export type MediaItemType = 'external-image' | 'file';
931
869
 
932
870
  // @public (undocumented)
933
- export type MediaObserver<T> =
934
- | ((value: T) => void)
935
- | CompletionObserver<T>
936
- | ErrorObserver<T>
937
- | NextObserver<T>;
871
+ export type MediaObserver =
872
+ | ((value: FileState) => void)
873
+ | CompletionObserver
874
+ | ErrorObserver
875
+ | NextObserver;
938
876
 
939
877
  // @public (undocumented)
940
878
  export type MediaRepresentations = {
@@ -980,12 +918,6 @@ export class MediaStore {
980
918
  artifactName: keyof MediaFileArtifacts,
981
919
  collectionName?: string,
982
920
  ): Promise<string>;
983
- // @deprecated (undocumented)
984
- getCollectionItems(
985
- collectionName: string,
986
- params?: MediaStoreGetCollectionItemsParams,
987
- traceContext?: MediaTraceContext,
988
- ): Promise<MediaStoreResponse<MediaCollectionItems>>;
989
921
  // (undocumented)
990
922
  getFile(
991
923
  fileId: string,
@@ -1146,14 +1078,6 @@ export type MediaStoreErrorReason =
1146
1078
  | 'missingInitialAuth'
1147
1079
  | 'tokenExpired';
1148
1080
 
1149
- // @public (undocumented)
1150
- export type MediaStoreGetCollectionItemsParams = {
1151
- readonly limit?: number;
1152
- readonly inclusiveStartKey?: string;
1153
- readonly sortDirection?: 'asc' | 'desc';
1154
- readonly details?: 'full' | 'minimal';
1155
- };
1156
-
1157
1081
  // @public (undocumented)
1158
1082
  export type MediaStoreGetFileImageParams = {
1159
1083
  readonly allowAnimated?: boolean;
@@ -1202,13 +1126,10 @@ export interface MediaStoreTouchFileParams {
1202
1126
  }
1203
1127
 
1204
1128
  // @public (undocumented)
1205
- export type MediaSubscribable<T> = {
1206
- subscribe(observer?: MediaObserver<T>): MediaSubscription;
1129
+ export type MediaSubscribable = {
1130
+ subscribe(observer?: MediaObserver): MediaSubscription;
1207
1131
  };
1208
1132
 
1209
- // @public (undocumented)
1210
- export type MediaSubscribableItem = FileState | MediaCollectionItem[];
1211
-
1212
1133
  // @public (undocumented)
1213
1134
  export type MediaSubscription = {
1214
1135
  unsubscribe: () => void;
@@ -1275,8 +1196,7 @@ export type MobileUploadStartEvent = {
1275
1196
  };
1276
1197
 
1277
1198
  // @public (undocumented)
1278
- type NextObserver<T> = PartialObserver<T> &
1279
- Required<Pick<PartialObserver<T>, 'next'>>;
1199
+ type NextObserver = PartialObserver & Required<Pick<PartialObserver, 'next'>>;
1280
1200
 
1281
1201
  // @public (undocumented)
1282
1202
  export type NonErrorFileState = Exclude<FileState, ErrorFileState>;
@@ -1287,8 +1207,8 @@ export const objectToQueryString: (json: {
1287
1207
  }) => string;
1288
1208
 
1289
1209
  // @public (undocumented)
1290
- type PartialObserver<T> = {
1291
- next?: (value: T) => void;
1210
+ type PartialObserver = {
1211
+ next?: (value: FileState) => void;
1292
1212
  error?: (err: any) => void;
1293
1213
  complete?: () => void;
1294
1214
  };
@@ -1542,7 +1462,7 @@ export interface ResponseFileItem {
1542
1462
  // (undocumented)
1543
1463
  collection?: string;
1544
1464
  // (undocumented)
1545
- details: MediaCollectionItemFullDetails;
1465
+ details: MediaItemDetails;
1546
1466
  // (undocumented)
1547
1467
  id: string;
1548
1468
  // (undocumented)
@@ -1719,7 +1639,7 @@ export type WithMediaClientFunction = <P extends WithMediaClient>(
1719
1639
 
1720
1640
  ```json
1721
1641
  {
1722
- "@atlaskit/media-core": "^34.0.1",
1642
+ "@atlaskit/media-core": "^34.0.2",
1723
1643
  "@emotion/react": "^11.7.1",
1724
1644
  "react": "^16.8.0"
1725
1645
  }
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.collectionCache = exports.CollectionFetcher = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _fileStreamsCache = require("../file-streams-cache");
13
- var _deprecatedEndpointError = require("../utils/deprecatedEndpointError");
14
- var collectionCache = {};
15
- exports.collectionCache = collectionCache;
16
- var CollectionFetcher = /*#__PURE__*/function () {
17
- function CollectionFetcher(mediaStore) {
18
- (0, _classCallCheck2.default)(this, CollectionFetcher);
19
- this.mediaStore = mediaStore;
20
- }
21
- (0, _createClass2.default)(CollectionFetcher, [{
22
- key: "removeFromCache",
23
- value: function removeFromCache(id, collectionName) {
24
- var collectionCacheIndex = collectionCache[collectionName].items.findIndex(function (item) {
25
- return item.id === id;
26
- });
27
- if (collectionCacheIndex === -1) {
28
- return;
29
- }
30
- (0, _fileStreamsCache.getFileStreamsCache)().remove(id);
31
- collectionCache[collectionName].items.splice(collectionCacheIndex, 1);
32
- }
33
-
34
- /**
35
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
36
- * This method is no longer working. Will be removed in the next release
37
- */
38
- }, {
39
- key: "getItems",
40
- value: function getItems(collectionName, params, traceContext) {
41
- throw new _deprecatedEndpointError.DeprecatedError('collection/:name/items');
42
- }
43
- }, {
44
- key: "removeFile",
45
- value: function () {
46
- var _removeFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
47
- var collection;
48
- return _regenerator.default.wrap(function _callee$(_context) {
49
- while (1) {
50
- switch (_context.prev = _context.next) {
51
- case 0:
52
- _context.next = 2;
53
- return this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey, traceContext);
54
- case 2:
55
- this.removeFromCache(id, collectionName);
56
- collection = collectionCache[collectionName];
57
- collection.subject.next(collection.items);
58
- case 5:
59
- case "end":
60
- return _context.stop();
61
- }
62
- }
63
- }, _callee, this);
64
- }));
65
- function removeFile(_x, _x2, _x3, _x4) {
66
- return _removeFile.apply(this, arguments);
67
- }
68
- return removeFile;
69
- }()
70
- /**
71
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
72
- * This method is no longer working. Will be removed in the next release
73
- */
74
- }, {
75
- key: "loadNextPage",
76
- value: function () {
77
- var _loadNextPage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(collectionName, params, traceContext) {
78
- return _regenerator.default.wrap(function _callee2$(_context2) {
79
- while (1) {
80
- switch (_context2.prev = _context2.next) {
81
- case 0:
82
- throw new _deprecatedEndpointError.DeprecatedError('collection/:name/items');
83
- case 1:
84
- case "end":
85
- return _context2.stop();
86
- }
87
- }
88
- }, _callee2);
89
- }));
90
- function loadNextPage(_x5, _x6, _x7) {
91
- return _loadNextPage.apply(this, arguments);
92
- }
93
- return loadNextPage;
94
- }()
95
- }]);
96
- return CollectionFetcher;
97
- }();
98
- exports.CollectionFetcher = CollectionFetcher;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DeprecatedError = void 0;
8
- exports.isDeprecatedError = isDeprecatedError;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _errors = require("../models/errors");
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
17
- var reason = 'deprecatedEndpoint';
18
- var DeprecatedError = /*#__PURE__*/function (_BaseMediaClientError) {
19
- (0, _inherits2.default)(DeprecatedError, _BaseMediaClientError);
20
- var _super = _createSuper(DeprecatedError);
21
- function DeprecatedError(endpointName) {
22
- var _this;
23
- (0, _classCallCheck2.default)(this, DeprecatedError);
24
- _this = _super.call(this, reason);
25
- _this.endpointName = endpointName;
26
- return _this;
27
- }
28
- (0, _createClass2.default)(DeprecatedError, [{
29
- key: "attributes",
30
- get: function get() {
31
- var endpointName = this.endpointName;
32
- return {
33
- reason: reason,
34
- endpointName: endpointName
35
- };
36
- }
37
- }]);
38
- return DeprecatedError;
39
- }(_errors.BaseMediaClientError);
40
- exports.DeprecatedError = DeprecatedError;
41
- function isDeprecatedError(err) {
42
- return err instanceof DeprecatedError;
43
- }
@@ -1,38 +0,0 @@
1
- import { getFileStreamsCache } from '../file-streams-cache';
2
- import { DeprecatedError } from '../utils/deprecatedEndpointError';
3
- export const collectionCache = {};
4
- export class CollectionFetcher {
5
- constructor(mediaStore) {
6
- this.mediaStore = mediaStore;
7
- }
8
- removeFromCache(id, collectionName) {
9
- const collectionCacheIndex = collectionCache[collectionName].items.findIndex(item => item.id === id);
10
- if (collectionCacheIndex === -1) {
11
- return;
12
- }
13
- getFileStreamsCache().remove(id);
14
- collectionCache[collectionName].items.splice(collectionCacheIndex, 1);
15
- }
16
-
17
- /**
18
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
19
- * This method is no longer working. Will be removed in the next release
20
- */
21
- getItems(collectionName, params, traceContext) {
22
- throw new DeprecatedError('collection/:name/items');
23
- }
24
- async removeFile(id, collectionName, occurrenceKey, traceContext) {
25
- await this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey, traceContext);
26
- this.removeFromCache(id, collectionName);
27
- const collection = collectionCache[collectionName];
28
- collection.subject.next(collection.items);
29
- }
30
-
31
- /**
32
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
33
- * This method is no longer working. Will be removed in the next release
34
- */
35
- async loadNextPage(collectionName, params, traceContext) {
36
- throw new DeprecatedError('collection/:name/items');
37
- }
38
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- import { BaseMediaClientError } from '../models/errors';
2
- const reason = 'deprecatedEndpoint';
3
- export class DeprecatedError extends BaseMediaClientError {
4
- constructor(endpointName) {
5
- super(reason);
6
- this.endpointName = endpointName;
7
- }
8
- get attributes() {
9
- const {
10
- endpointName
11
- } = this;
12
- return {
13
- reason,
14
- endpointName
15
- };
16
- }
17
- }
18
- export function isDeprecatedError(err) {
19
- return err instanceof DeprecatedError;
20
- }
@@ -1,89 +0,0 @@
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 _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import { getFileStreamsCache } from '../file-streams-cache';
6
- import { DeprecatedError } from '../utils/deprecatedEndpointError';
7
- export var collectionCache = {};
8
- export var CollectionFetcher = /*#__PURE__*/function () {
9
- function CollectionFetcher(mediaStore) {
10
- _classCallCheck(this, CollectionFetcher);
11
- this.mediaStore = mediaStore;
12
- }
13
- _createClass(CollectionFetcher, [{
14
- key: "removeFromCache",
15
- value: function removeFromCache(id, collectionName) {
16
- var collectionCacheIndex = collectionCache[collectionName].items.findIndex(function (item) {
17
- return item.id === id;
18
- });
19
- if (collectionCacheIndex === -1) {
20
- return;
21
- }
22
- getFileStreamsCache().remove(id);
23
- collectionCache[collectionName].items.splice(collectionCacheIndex, 1);
24
- }
25
-
26
- /**
27
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
28
- * This method is no longer working. Will be removed in the next release
29
- */
30
- }, {
31
- key: "getItems",
32
- value: function getItems(collectionName, params, traceContext) {
33
- throw new DeprecatedError('collection/:name/items');
34
- }
35
- }, {
36
- key: "removeFile",
37
- value: function () {
38
- var _removeFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
39
- var collection;
40
- return _regeneratorRuntime.wrap(function _callee$(_context) {
41
- while (1) {
42
- switch (_context.prev = _context.next) {
43
- case 0:
44
- _context.next = 2;
45
- return this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey, traceContext);
46
- case 2:
47
- this.removeFromCache(id, collectionName);
48
- collection = collectionCache[collectionName];
49
- collection.subject.next(collection.items);
50
- case 5:
51
- case "end":
52
- return _context.stop();
53
- }
54
- }
55
- }, _callee, this);
56
- }));
57
- function removeFile(_x, _x2, _x3, _x4) {
58
- return _removeFile.apply(this, arguments);
59
- }
60
- return removeFile;
61
- }()
62
- /**
63
- * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
64
- * This method is no longer working. Will be removed in the next release
65
- */
66
- }, {
67
- key: "loadNextPage",
68
- value: function () {
69
- var _loadNextPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(collectionName, params, traceContext) {
70
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
71
- while (1) {
72
- switch (_context2.prev = _context2.next) {
73
- case 0:
74
- throw new DeprecatedError('collection/:name/items');
75
- case 1:
76
- case "end":
77
- return _context2.stop();
78
- }
79
- }
80
- }, _callee2);
81
- }));
82
- function loadNextPage(_x5, _x6, _x7) {
83
- return _loadNextPage.apply(this, arguments);
84
- }
85
- return loadNextPage;
86
- }()
87
- }]);
88
- return CollectionFetcher;
89
- }();
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
- import { BaseMediaClientError } from '../models/errors';
9
- var reason = 'deprecatedEndpoint';
10
- export var DeprecatedError = /*#__PURE__*/function (_BaseMediaClientError) {
11
- _inherits(DeprecatedError, _BaseMediaClientError);
12
- var _super = _createSuper(DeprecatedError);
13
- function DeprecatedError(endpointName) {
14
- var _this;
15
- _classCallCheck(this, DeprecatedError);
16
- _this = _super.call(this, reason);
17
- _this.endpointName = endpointName;
18
- return _this;
19
- }
20
- _createClass(DeprecatedError, [{
21
- key: "attributes",
22
- get: function get() {
23
- var endpointName = this.endpointName;
24
- return {
25
- reason: reason,
26
- endpointName: endpointName
27
- };
28
- }
29
- }]);
30
- return DeprecatedError;
31
- }(BaseMediaClientError);
32
- export function isDeprecatedError(err) {
33
- return err instanceof DeprecatedError;
34
- }