@atlaskit/media-test-helpers 32.0.0 → 32.1.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 (59) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/authProvider.js +28 -31
  3. package/dist/cjs/await-error.js +20 -23
  4. package/dist/cjs/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -15
  5. package/dist/cjs/fileStateFactory/factory/factory.js +146 -0
  6. package/dist/cjs/fileStateFactory/factory/index.js +38 -0
  7. package/dist/cjs/fileStateFactory/fileSimulation/fileSimulation.js +89 -0
  8. package/dist/cjs/fileStateFactory/fileSimulation/index.js +79 -0
  9. package/dist/cjs/fileStateFactory/fileSimulation/simulations.js +399 -0
  10. package/dist/cjs/fileStateFactory/index.js +76 -4
  11. package/dist/cjs/getAuthFromContextProvider.js +24 -27
  12. package/dist/cjs/index.js +72 -0
  13. package/dist/cjs/mediaPickerAuthProvider.js +25 -28
  14. package/dist/cjs/mocks/routers/api-router.js +97 -104
  15. package/dist/cjs/utils/logging.js +4 -4
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/cjs/waitUntil.js +22 -25
  18. package/dist/es2019/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -17
  19. package/dist/es2019/fileStateFactory/{factory.js → factory/factory.js} +12 -2
  20. package/dist/es2019/fileStateFactory/factory/index.js +3 -0
  21. package/dist/es2019/fileStateFactory/fileSimulation/fileSimulation.js +63 -0
  22. package/dist/es2019/fileStateFactory/fileSimulation/index.js +2 -0
  23. package/dist/es2019/fileStateFactory/fileSimulation/simulations.js +148 -0
  24. package/dist/es2019/fileStateFactory/index.js +4 -2
  25. package/dist/es2019/index.js +5 -1
  26. package/dist/es2019/utils/logging.js +3 -3
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/authProvider.js +28 -31
  29. package/dist/esm/await-error.js +20 -23
  30. package/dist/esm/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -15
  31. package/dist/esm/fileStateFactory/factory/factory.js +137 -0
  32. package/dist/esm/fileStateFactory/factory/index.js +3 -0
  33. package/dist/esm/fileStateFactory/fileSimulation/fileSimulation.js +81 -0
  34. package/dist/esm/fileStateFactory/fileSimulation/index.js +2 -0
  35. package/dist/esm/fileStateFactory/fileSimulation/simulations.js +382 -0
  36. package/dist/esm/fileStateFactory/index.js +4 -2
  37. package/dist/esm/getAuthFromContextProvider.js +24 -27
  38. package/dist/esm/index.js +5 -1
  39. package/dist/esm/mediaPickerAuthProvider.js +25 -28
  40. package/dist/esm/mocks/routers/api-router.js +97 -104
  41. package/dist/esm/utils/logging.js +3 -3
  42. package/dist/esm/version.json +1 -1
  43. package/dist/esm/waitUntil.js +22 -25
  44. package/dist/types/fileStateFactory/{factory.d.ts → factory/factory.d.ts} +3 -0
  45. package/dist/types/fileStateFactory/factory/index.d.ts +4 -0
  46. package/dist/types/fileStateFactory/fileSimulation/fileSimulation.d.ts +18 -0
  47. package/dist/types/fileStateFactory/fileSimulation/index.d.ts +4 -0
  48. package/dist/types/fileStateFactory/fileSimulation/simulations.d.ts +35 -0
  49. package/dist/types/fileStateFactory/index.d.ts +7 -3
  50. package/dist/types/index.d.ts +2 -2
  51. package/package.json +2 -2
  52. package/report.api.md +90 -1
  53. package/dist/cjs/fileStateFactory/factory.js +0 -138
  54. package/dist/esm/fileStateFactory/factory.js +0 -129
  55. /package/dist/cjs/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  56. /package/dist/es2019/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  57. /package/dist/esm/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  58. /package/dist/types/fileStateFactory/{createFileState.d.ts → factory/createFileState.d.ts} +0 -0
  59. /package/dist/types/fileStateFactory/{helpers.d.ts → factory/helpers.d.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ import { useEffect, useState } from 'react';
6
+ import { FileStateFactory, createIdentifier, createFileDetails } from '../factory';
7
+ var defaultDelay = 1500;
8
+ var useSimulationSettings = function useSimulationSettings() {
9
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
10
+ mediaType = _ref.mediaType,
11
+ _ref$mediaClientMockO = _ref.mediaClientMockOptions,
12
+ mediaClientMockOptions = _ref$mediaClientMockO === void 0 ? {} : _ref$mediaClientMockO;
13
+ var _useState = useState(createIdentifier()),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ identifier = _useState2[0],
16
+ setIdentifier = _useState2[1];
17
+ var _useState3 = useState(new FileStateFactory(identifier, {
18
+ fileDetails: createFileDetails(identifier.id, mediaType),
19
+ mediaClientMockOptions: _objectSpread({
20
+ // default options
21
+ getImageDelay: defaultDelay
22
+ }, mediaClientMockOptions)
23
+ })),
24
+ _useState4 = _slicedToArray(_useState3, 1),
25
+ fileStateFactory = _useState4[0];
26
+ var _useState5 = useState(function () {
27
+ return function (newMediaType) {
28
+ var newId = createIdentifier();
29
+ fileStateFactory.updateIdentifier(newId, createFileDetails(newId.id, newMediaType || mediaType));
30
+ setIdentifier(newId);
31
+ };
32
+ }),
33
+ _useState6 = _slicedToArray(_useState5, 1),
34
+ updateIdentifier = _useState6[0];
35
+ return {
36
+ fileStateFactory: fileStateFactory,
37
+ identifier: identifier,
38
+ updateIdentifier: updateIdentifier
39
+ };
40
+ };
41
+ export var useRunSimulation = function useRunSimulation(simulation) {
42
+ var simulationSettings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ var _useSimulationSetting = useSimulationSettings(simulationSettings),
44
+ identifier = _useSimulationSetting.identifier,
45
+ fileStateFactory = _useSimulationSetting.fileStateFactory,
46
+ updateIdentifier = _useSimulationSetting.updateIdentifier;
47
+ var fileState = useSubscribeToFileState(identifier, fileStateFactory);
48
+ useEffect(function () {
49
+ simulation(fileStateFactory, {
50
+ updateIdentifier: updateIdentifier
51
+ });
52
+ }, [fileStateFactory, updateIdentifier, simulation]);
53
+ return {
54
+ identifier: identifier,
55
+ fileStateFactory: fileStateFactory,
56
+ fileState: fileState,
57
+ updateIdentifier: updateIdentifier
58
+ };
59
+ };
60
+ var useSubscribeToFileState = function useSubscribeToFileState(identifier, fileStateFactory) {
61
+ var _useState7 = useState(),
62
+ _useState8 = _slicedToArray(_useState7, 2),
63
+ fileState = _useState8[0],
64
+ setFileState = _useState8[1];
65
+ useEffect(function () {
66
+ var subscription = fileStateFactory.mediaClient.file.getFileState(identifier.id, _objectSpread({}, identifier)).subscribe({
67
+ next: function next(filestate) {
68
+ return setFileState(filestate);
69
+ },
70
+ error: function error() {
71
+ return setFileState({
72
+ status: 'subscription error'
73
+ });
74
+ }
75
+ });
76
+ return function () {
77
+ subscription.unsubscribe();
78
+ };
79
+ }, [fileStateFactory, identifier]);
80
+ return fileState;
81
+ };
@@ -0,0 +1,2 @@
1
+ export { useRunSimulation } from './fileSimulation';
2
+ export { simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing } from './simulations';
@@ -0,0 +1,382 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { sleep } from '../../nextTick';
4
+ var speed = 1500;
5
+ /**
6
+ * Normal File Flow
7
+ */
8
+
9
+ export var simulateProcessed = function simulateProcessed() {
10
+ var withRemotePreview = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11
+ return {
12
+ simulation: function () {
13
+ var _simulation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(factory) {
14
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ _context.next = 2;
18
+ return sleep(speed);
19
+ case 2:
20
+ factory.next('processed', {
21
+ withRemotePreview: withRemotePreview
22
+ });
23
+ case 3:
24
+ case "end":
25
+ return _context.stop();
26
+ }
27
+ }, _callee);
28
+ }));
29
+ function simulation(_x) {
30
+ return _simulation.apply(this, arguments);
31
+ }
32
+ return simulation;
33
+ }(),
34
+ description: "File state is processed ".concat(withRemotePreview ? 'with' : 'without', " remote preview")
35
+ };
36
+ };
37
+ export var simulateProcessing = function simulateProcessing() {
38
+ var suceeded = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
39
+ var withRemotePreview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
40
+ return {
41
+ description: "File is processing, then ".concat(suceeded ? 'succeeds' : 'fails', " ").concat(withRemotePreview ? 'with' : 'without', " remote preview"),
42
+ simulation: function () {
43
+ var _simulation2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(factory) {
44
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
45
+ while (1) switch (_context2.prev = _context2.next) {
46
+ case 0:
47
+ _context2.next = 2;
48
+ return sleep(speed);
49
+ case 2:
50
+ factory.next('processing');
51
+ _context2.next = 5;
52
+ return sleep(speed);
53
+ case 5:
54
+ factory.next('processing');
55
+ _context2.next = 8;
56
+ return sleep(speed * 0.5);
57
+ case 8:
58
+ if (!suceeded) {
59
+ factory.next('failed-processing', {
60
+ withRemotePreview: withRemotePreview
61
+ });
62
+ } else {
63
+ factory.next('processed', {
64
+ withRemotePreview: withRemotePreview
65
+ });
66
+ }
67
+ case 9:
68
+ case "end":
69
+ return _context2.stop();
70
+ }
71
+ }, _callee2);
72
+ }));
73
+ function simulation(_x2) {
74
+ return _simulation2.apply(this, arguments);
75
+ }
76
+ return simulation;
77
+ }()
78
+ };
79
+ };
80
+ export var simulateImmediateFailProcessing = function simulateImmediateFailProcessing() {
81
+ return {
82
+ description: 'The first sate is failed-processing with no preview',
83
+ simulation: function () {
84
+ var _simulation3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(factory) {
85
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
86
+ while (1) switch (_context3.prev = _context3.next) {
87
+ case 0:
88
+ _context3.next = 2;
89
+ return sleep(speed);
90
+ case 2:
91
+ factory.next('failed-processing');
92
+ case 3:
93
+ case "end":
94
+ return _context3.stop();
95
+ }
96
+ }, _callee3);
97
+ }));
98
+ function simulation(_x3) {
99
+ return _simulation3.apply(this, arguments);
100
+ }
101
+ return simulation;
102
+ }()
103
+ };
104
+ };
105
+ export var simulateUpload = function simulateUpload(withLocalPreview) {
106
+ var suceeded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
107
+ return {
108
+ description: '',
109
+ simulation: function () {
110
+ var _simulation4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(factory) {
111
+ var chunks, chunkUploadDelay, processingTime, uploadUpTo, index;
112
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
113
+ while (1) switch (_context4.prev = _context4.next) {
114
+ case 0:
115
+ chunks = 3;
116
+ chunkUploadDelay = 500;
117
+ processingTime = speed;
118
+ _context4.next = 5;
119
+ return sleep(speed);
120
+ case 5:
121
+ factory.next('uploading', {
122
+ withLocalPreview: withLocalPreview
123
+ });
124
+ uploadUpTo = !suceeded ? chunks / 2 : chunks;
125
+ index = 0;
126
+ case 8:
127
+ if (!(index <= uploadUpTo)) {
128
+ _context4.next = 15;
129
+ break;
130
+ }
131
+ factory.next('uploading', {
132
+ uploadProgress: index / chunks,
133
+ withLocalPreview: withLocalPreview
134
+ });
135
+ _context4.next = 12;
136
+ return sleep(chunkUploadDelay);
137
+ case 12:
138
+ index++;
139
+ _context4.next = 8;
140
+ break;
141
+ case 15:
142
+ if (!suceeded) {
143
+ factory.error(new Error('some-error'));
144
+ }
145
+ factory.next('processing', {
146
+ withLocalPreview: withLocalPreview
147
+ });
148
+ _context4.next = 19;
149
+ return sleep(processingTime);
150
+ case 19:
151
+ factory.next('processed', {
152
+ withLocalPreview: withLocalPreview
153
+ });
154
+ case 20:
155
+ case "end":
156
+ return _context4.stop();
157
+ }
158
+ }, _callee4);
159
+ }));
160
+ function simulation(_x4) {
161
+ return _simulation4.apply(this, arguments);
162
+ }
163
+ return simulation;
164
+ }()
165
+ };
166
+ };
167
+ export var simulateErrorState = function simulateErrorState() {
168
+ return {
169
+ description: 'File state is error',
170
+ simulation: function () {
171
+ var _simulation5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(factory) {
172
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
173
+ while (1) switch (_context5.prev = _context5.next) {
174
+ case 0:
175
+ _context5.next = 2;
176
+ return sleep(speed);
177
+ case 2:
178
+ factory.next('error');
179
+ case 3:
180
+ case "end":
181
+ return _context5.stop();
182
+ }
183
+ }, _callee5);
184
+ }));
185
+ function simulation(_x5) {
186
+ return _simulation5.apply(this, arguments);
187
+ }
188
+ return simulation;
189
+ }()
190
+ };
191
+ };
192
+ export var simulateError = function simulateError() {
193
+ return {
194
+ description: 'Subscription throws an error through the observer',
195
+ simulation: function () {
196
+ var _simulation6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(factory) {
197
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
198
+ while (1) switch (_context6.prev = _context6.next) {
199
+ case 0:
200
+ _context6.next = 2;
201
+ return sleep(speed);
202
+ case 2:
203
+ factory.error(new Error('error thrown from client'));
204
+ case 3:
205
+ case "end":
206
+ return _context6.stop();
207
+ }
208
+ }, _callee6);
209
+ }));
210
+ function simulation(_x6) {
211
+ return _simulation6.apply(this, arguments);
212
+ }
213
+ return simulation;
214
+ }()
215
+ };
216
+ };
217
+
218
+ /**
219
+ * Rare Cases
220
+ */
221
+
222
+ export var simulateManyProcessed = function simulateManyProcessed() {
223
+ var withRemotePreview = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
224
+ return {
225
+ description: '',
226
+ simulation: function () {
227
+ var _simulation7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(factory) {
228
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
229
+ while (1) switch (_context7.prev = _context7.next) {
230
+ case 0:
231
+ _context7.next = 2;
232
+ return sleep(speed);
233
+ case 2:
234
+ factory.next('processed', {
235
+ withRemotePreview: withRemotePreview
236
+ });
237
+ _context7.next = 5;
238
+ return sleep(speed);
239
+ case 5:
240
+ factory.next('processed', {
241
+ withRemotePreview: withRemotePreview
242
+ });
243
+ _context7.next = 8;
244
+ return sleep(speed);
245
+ case 8:
246
+ factory.next('processed', {
247
+ withRemotePreview: withRemotePreview
248
+ });
249
+ case 9:
250
+ case "end":
251
+ return _context7.stop();
252
+ }
253
+ }, _callee7);
254
+ }));
255
+ function simulation(_x7) {
256
+ return _simulation7.apply(this, arguments);
257
+ }
258
+ return simulation;
259
+ }()
260
+ };
261
+ };
262
+ export var simulateEmptyDetails = function simulateEmptyDetails() {
263
+ return {
264
+ description: 'Incomplete uploads return empty file details and a processing status pending',
265
+ simulation: function () {
266
+ var _simulation8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(factory) {
267
+ var emptyDetails;
268
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
269
+ while (1) switch (_context8.prev = _context8.next) {
270
+ case 0:
271
+ emptyDetails = {
272
+ createdAt: 1630986510989
273
+ };
274
+ _context8.next = 3;
275
+ return sleep(speed);
276
+ case 3:
277
+ factory.next('processing', {
278
+ fileDetails: emptyDetails
279
+ });
280
+ case 4:
281
+ case "end":
282
+ return _context8.stop();
283
+ }
284
+ }, _callee8);
285
+ }));
286
+ function simulation(_x8) {
287
+ return _simulation8.apply(this, arguments);
288
+ }
289
+ return simulation;
290
+ }()
291
+ };
292
+ };
293
+ export var simulateUpdateFileId = function simulateUpdateFileId() {
294
+ return {
295
+ description: 'First File Id: video with processing issue. Next File Id: PDF sucessfully processed',
296
+ simulation: function () {
297
+ var _simulation9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(factory, _ref) {
298
+ var updateIdentifier;
299
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
300
+ while (1) switch (_context9.prev = _context9.next) {
301
+ case 0:
302
+ updateIdentifier = _ref.updateIdentifier;
303
+ _context9.next = 3;
304
+ return sleep(speed);
305
+ case 3:
306
+ factory.next('failed-processing');
307
+ _context9.next = 6;
308
+ return sleep(speed);
309
+ case 6:
310
+ updateIdentifier('doc');
311
+ _context9.next = 9;
312
+ return sleep(speed);
313
+ case 9:
314
+ factory.next('processing');
315
+ _context9.next = 12;
316
+ return sleep(speed);
317
+ case 12:
318
+ factory.next('processed');
319
+ case 13:
320
+ case "end":
321
+ return _context9.stop();
322
+ }
323
+ }, _callee9);
324
+ }));
325
+ function simulation(_x9, _x10) {
326
+ return _simulation9.apply(this, arguments);
327
+ }
328
+ return simulation;
329
+ }()
330
+ };
331
+ };
332
+ export var simulateAlwaysLoading = function simulateAlwaysLoading() {
333
+ return {
334
+ description: 'File state never fetched',
335
+ simulation: function () {
336
+ var _simulation10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
337
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
338
+ while (1) switch (_context10.prev = _context10.next) {
339
+ case 0:
340
+ case "end":
341
+ return _context10.stop();
342
+ }
343
+ }, _callee10);
344
+ }));
345
+ function simulation() {
346
+ return _simulation10.apply(this, arguments);
347
+ }
348
+ return simulation;
349
+ }()
350
+ };
351
+ };
352
+ export var simulateAlwaysProcessing = function simulateAlwaysProcessing() {
353
+ return {
354
+ description: 'File state is permanently processing',
355
+ simulation: function () {
356
+ var _simulation11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(factory) {
357
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
358
+ while (1) switch (_context11.prev = _context11.next) {
359
+ case 0:
360
+ _context11.next = 2;
361
+ return sleep(speed);
362
+ case 2:
363
+ factory.next('processing');
364
+ _context11.next = 5;
365
+ return sleep(speed);
366
+ case 5:
367
+ factory.next('processing');
368
+ _context11.next = 8;
369
+ return sleep(speed * 0.5);
370
+ case 8:
371
+ case "end":
372
+ return _context11.stop();
373
+ }
374
+ }, _callee11);
375
+ }));
376
+ function simulation(_x11) {
377
+ return _simulation11.apply(this, arguments);
378
+ }
379
+ return simulation;
380
+ }()
381
+ };
382
+ };
@@ -1,3 +1,5 @@
1
1
  export { FileStateFactory, MediaClientMock } from './factory';
2
- export { createIdentifier, createFileDetails } from './helpers';
3
- export { createFileState } from './createFileState';
2
+ export { createIdentifier, createFileDetails } from './factory';
3
+ export { createFileState } from './factory/createFileState';
4
+ export { useRunSimulation } from './fileSimulation';
5
+ export { simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing } from './fileSimulation';
@@ -1,6 +1,5 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  var access = {
5
4
  'urn:filestore:collection:MediaServicesSample': ['read', 'insert'],
6
5
  'urn:filestore:chunk:*': ['create', 'read'],
@@ -12,32 +11,30 @@ var access = {
12
11
  'urn:filestore:collection:mediapicker-test': ['read', 'insert']
13
12
  };
14
13
  export var getAuthFromContextProvider = /*#__PURE__*/function () {
15
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
15
  var url, body, headers, response;
17
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18
- while (1) {
19
- switch (_context.prev = _context.next) {
20
- case 0:
21
- url = 'https://media-playground.dev.atl-paas.net/token/tenant?environment=asap';
22
- body = JSON.stringify({
23
- access: access
24
- });
25
- headers = new Headers();
26
- headers.append('Content-Type', 'application/json; charset=utf-8');
27
- headers.append('Accept', 'text/plain, */*; q=0.01');
28
- _context.next = 7;
29
- return fetch(url, {
30
- method: 'POST',
31
- body: body,
32
- headers: headers
33
- });
34
- case 7:
35
- response = _context.sent;
36
- return _context.abrupt("return", response.json());
37
- case 9:
38
- case "end":
39
- return _context.stop();
40
- }
16
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17
+ while (1) switch (_context.prev = _context.next) {
18
+ case 0:
19
+ url = 'https://media-playground.dev.atl-paas.net/token/tenant?environment=asap';
20
+ body = JSON.stringify({
21
+ access: access
22
+ });
23
+ headers = new Headers();
24
+ headers.append('Content-Type', 'application/json; charset=utf-8');
25
+ headers.append('Accept', 'text/plain, */*; q=0.01');
26
+ _context.next = 7;
27
+ return fetch(url, {
28
+ method: 'POST',
29
+ body: body,
30
+ headers: headers
31
+ });
32
+ case 7:
33
+ response = _context.sent;
34
+ return _context.abrupt("return", response.json());
35
+ case 9:
36
+ case "end":
37
+ return _context.stop();
41
38
  }
42
39
  }, _callee);
43
40
  }));
package/dist/esm/index.js CHANGED
@@ -37,5 +37,9 @@ export { dataURItoBlob } from './mockData/utils';
37
37
  export { mapDataUriToBlob } from './utils/index';
38
38
  export { createPollingMaxAttemptsError, createRateLimitedError, createMediaStoreError } from './mediaClientErrors';
39
39
  export { default as FeatureFlagsWrapper } from './featureFlagsWrapper';
40
- export { FileStateFactory, MediaClientMock, createIdentifier, createFileDetails, createFileState } from './fileStateFactory';
40
+ export {
41
+ // Simulation tools
42
+ FileStateFactory, MediaClientMock, createIdentifier, createFileDetails, createFileState, useRunSimulation,
43
+ // Predefined simulations
44
+ simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing } from './fileStateFactory';
41
45
  export { DocsContentTabs } from './docs-content-tabs';