@selkirk-systems/fetch 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,175 @@
1
+ /* eslint-disable */
2
+
3
+ //download.js v4.21, by dandavis; 2008-2018. [MIT] see http://danml.com/download.html for tests/usage
4
+ // v1 landed a FF+Chrome compatible way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
5
+ // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
6
+ // v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
7
+ // v4 adds AMD/UMD, commonJS, and plain browser support
8
+ // v4.1 adds url download capability via solo URL argument (same domain/CORS only)
9
+ // v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
10
+ // https://github.com/rndme/download
11
+
12
+ ( function ( root, factory ) {
13
+ if ( typeof define === 'function' && define.amd ) {
14
+ // AMD. Register as an anonymous module.
15
+ define( [], factory );
16
+ } else if ( typeof exports === 'object' ) {
17
+ // Node. Does not work with strict CommonJS, but
18
+ // only CommonJS-like environments that support module.exports,
19
+ // like Node.
20
+ module.exports = factory();
21
+ } else {
22
+ // Browser globals (root is window)
23
+ root.download = factory();
24
+ }
25
+ }( this, function () {
26
+
27
+
28
+ return function download( data, strFileName, strMimeType ) {
29
+
30
+ var self = window, // this script is only for browsers anyway...
31
+ defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
32
+ mimeType = strMimeType || defaultMime,
33
+ payload = data,
34
+ url = !strFileName && !strMimeType && payload,
35
+ anchor = document.createElement( "a" ),
36
+ toString = function ( a ) { return String( a ); },
37
+ myBlob = ( self.Blob || self.MozBlob || self.WebKitBlob || toString ),
38
+ fileName = strFileName || "download",
39
+ blob,
40
+ reader;
41
+ myBlob = myBlob.call ? myBlob.bind( self ) : Blob;
42
+
43
+ if ( String( this ) === "true" ) { //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
44
+ payload = [payload, mimeType];
45
+ mimeType = payload[0];
46
+ payload = payload[1];
47
+ }
48
+
49
+
50
+ if ( url && url.length < 2048 ) { // if no filename and no mime, assume a url was passed as the only argument
51
+ fileName = url.split( "/" ).pop().split( "?" )[0];
52
+ anchor.href = url; // assign href prop to temp anchor
53
+ if ( anchor.href.indexOf( url ) !== -1 ) { // if the browser determines that it's a potentially valid url path:
54
+ var ajax = new XMLHttpRequest();
55
+ ajax.open( "GET", url, true );
56
+ ajax.responseType = 'blob';
57
+ ajax.onload = function ( e ) {
58
+ download( e.target.response, fileName, defaultMime );
59
+ };
60
+ setTimeout( function () { ajax.send(); }, 0 ); // allows setting custom ajax headers using the return:
61
+ return ajax;
62
+ } // end if valid url?
63
+ } // end if url?
64
+
65
+
66
+ //go ahead and download dataURLs right away
67
+ if ( /^data:([\w+-]+\/[\w+.-]+)?[,;]/.test( payload ) ) {
68
+
69
+ if ( payload.length > ( 1024 * 1024 * 1.999 ) && myBlob !== toString ) {
70
+ payload = dataUrlToBlob( payload );
71
+ mimeType = payload.type || defaultMime;
72
+ } else {
73
+ return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
74
+ navigator.msSaveBlob( dataUrlToBlob( payload ), fileName ) :
75
+ saver( payload ); // everyone else can save dataURLs un-processed
76
+ }
77
+
78
+ } else {//not data url, is it a string with special needs?
79
+ if ( /([\x80-\xff])/.test( payload ) ) {
80
+ var i = 0, tempUiArr = new Uint8Array( payload.length ), mx = tempUiArr.length;
81
+ for ( i; i < mx; ++i ) tempUiArr[i] = payload.charCodeAt( i );
82
+ payload = new myBlob( [tempUiArr], { type: mimeType } );
83
+ }
84
+ }
85
+ blob = payload instanceof myBlob ?
86
+ payload :
87
+ new myBlob( [payload], { type: mimeType } );
88
+
89
+
90
+ function dataUrlToBlob( strUrl ) {
91
+ var parts = strUrl.split( /[:;,]/ ),
92
+ type = parts[1],
93
+ indexDecoder = strUrl.indexOf( "charset" ) > 0 ? 3 : 2,
94
+ decoder = parts[indexDecoder] == "base64" ? atob : decodeURIComponent,
95
+ binData = decoder( parts.pop() ),
96
+ mx = binData.length,
97
+ i = 0,
98
+ uiArr = new Uint8Array( mx );
99
+
100
+ for ( i; i < mx; ++i ) uiArr[i] = binData.charCodeAt( i );
101
+
102
+ return new myBlob( [uiArr], { type: type } );
103
+ }
104
+
105
+ function saver( url, winMode ) {
106
+
107
+ if ( 'download' in anchor ) { //html5 A[download]
108
+ anchor.href = url;
109
+ anchor.setAttribute( "download", fileName );
110
+ anchor.className = "download-js-link";
111
+ anchor.innerHTML = "downloading...";
112
+ anchor.style.display = "none";
113
+ anchor.addEventListener( 'click', function ( e ) {
114
+ e.stopPropagation();
115
+ this.removeEventListener( 'click', arguments.callee );
116
+ } );
117
+ document.body.appendChild( anchor );
118
+ setTimeout( function () {
119
+ anchor.click();
120
+ document.body.removeChild( anchor );
121
+ if ( winMode === true ) { setTimeout( function () { self.URL.revokeObjectURL( anchor.href ); }, 250 ); }
122
+ }, 66 );
123
+ return true;
124
+ }
125
+
126
+ // handle non-a[download] safari as best we can:
127
+ if ( /(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test( navigator.userAgent ) ) {
128
+ if ( /^data:/.test( url ) ) url = "data:" + url.replace( /^data:([\w\/\-\+]+)/, defaultMime );
129
+ if ( !window.open( url ) ) { // popup blocked, offer direct download:
130
+ if ( confirm( "Displaying New Document\n\nUse Save As... to download, then click back to return to this page." ) ) { location.href = url; }
131
+ }
132
+ return true;
133
+ }
134
+
135
+ //do iframe dataURL download (old ch+FF):
136
+ var f = document.createElement( "iframe" );
137
+ document.body.appendChild( f );
138
+
139
+ if ( !winMode && /^data:/.test( url ) ) { // force a mime that will download:
140
+ url = "data:" + url.replace( /^data:([\w\/\-\+]+)/, defaultMime );
141
+ }
142
+ f.src = url;
143
+ setTimeout( function () { document.body.removeChild( f ); }, 333 );
144
+
145
+ }//end saver
146
+
147
+
148
+
149
+
150
+ if ( navigator.msSaveBlob ) { // IE10+ : (has Blob, but not a[download] or URL)
151
+ return navigator.msSaveBlob( blob, fileName );
152
+ }
153
+
154
+ if ( self.URL ) { // simple fast and modern way using Blob and URL:
155
+ saver( self.URL.createObjectURL( blob ), true );
156
+ } else {
157
+ // handle non-Blob()+non-URL browsers:
158
+ if ( typeof blob === "string" || blob.constructor === toString ) {
159
+ try {
160
+ return saver( "data:" + mimeType + ";base64," + self.btoa( blob ) );
161
+ } catch ( y ) {
162
+ return saver( "data:" + mimeType + "," + encodeURIComponent( blob ) );
163
+ }
164
+ }
165
+
166
+ // Blob but not URL support:
167
+ reader = new FileReader();
168
+ reader.onload = function ( e ) {
169
+ saver( this.result );
170
+ };
171
+ reader.readAsDataURL( blob );
172
+ }
173
+ return true;
174
+ }; /* end download() */
175
+ } ) );
@@ -0,0 +1,515 @@
1
+ //Inspired by https://www.bennadel.com/blog/4180-canceling-api-requests-using-fetch-and-abortcontroller-in-javascript.htm
2
+
3
+ import Download from './Download';
4
+ import FetchErrorHandler from './middleware/FetchErrorHandler';
5
+
6
+ // Regular expression patterns for testing content-type response headers.
7
+ const RE_CONTENT_TYPE_JSON = /^application\/(x-)?json/i;
8
+ const RE_CONTENT_TYPE_TEXT = /"^text\/"/i;
9
+ const RE_QUERY_STRING = /\/.+\?/;
10
+
11
+ const UNEXPECTED_ERROR_MESSAGE = "An unexpected error occurred while processing your request.";
12
+
13
+ const CONTENT_TYPE_DOWNLOADS = {
14
+ 'application/pdf': true,
15
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': true
16
+ }
17
+ //We store the original promise.catch so we can override it in some
18
+ //scenarios when we want to swallow errors vs bubble them up.
19
+ const ORIGINAL_CATCH_FN = Promise.prototype.catch;
20
+
21
+ //Auto applied middleware that dispatches all errors so any UI's can respond.
22
+ let _middlewares = [FetchErrorHandler];
23
+
24
+
25
+ //Cache of request AbortController signals for auto request aborting.
26
+ let _requests = {};
27
+
28
+ /**
29
+ * PUBLIC: Apply custom middleware to act on any fetch responses and errors.
30
+ *
31
+ * NOTE: Middleware can handle errors and swallow them by passing back a new error object.
32
+ *
33
+ * @param {array} middleware
34
+ */
35
+ export function applyMiddleware( middleware = [] ) {
36
+ _middlewares = middleware;
37
+
38
+ _middlewares.push( FetchErrorHandler );
39
+ }
40
+
41
+ /**
42
+ * Make the fetch request with the given configuration options.
43
+ *
44
+ * GUARANTEE: All errors produced by this method will have consistent structure, even
45
+ * if they are low-level networking errors. At a minimum, every Promise rejection will
46
+ * have the following properties:
47
+ *
48
+ * TODO: Add support for multi-form uploads (images, files etc)
49
+ *
50
+ * - data.type
51
+ * - data.message
52
+ * - status.code
53
+ * - status.text
54
+ * - status.isAbort
55
+ */
56
+ export default function Fetch( url, options = {} ) {
57
+
58
+ const config = {
59
+ downloadFileName: null,
60
+ contentType: "application/json",
61
+ headers: {
62
+ accept: "*/*"
63
+ },
64
+ credentials: "same-origin",
65
+ url: url || "",
66
+ urlTemplateData: {},
67
+ method: "GET",
68
+ params: {},
69
+ form: null,
70
+ json: null,
71
+ body: null,
72
+ signal: new AbortController(),
73
+ ...options,
74
+ _hasCatch: false,
75
+ _promiseChain: null,
76
+ _userSignal: Boolean( options.signal )
77
+ }
78
+
79
+ let finalHeaders, finalMethod, finalUrl, finalBody, finalSignal, request;
80
+
81
+
82
+ try {
83
+
84
+ finalHeaders = buildHeaders( config.headers );
85
+ finalMethod = config.method;
86
+ finalUrl = buildURL( config.url, config.urlTemplateData, config.params );
87
+ finalBody = config.body;
88
+ finalSignal = config.signal;
89
+
90
+ // Bail out early if url contains url params,
91
+ //these should be set via the options.params object.
92
+ if ( !config.url.href && RE_QUERY_STRING.test( config.url ) ) {
93
+ return ( Promise.reject( normalizeError( {
94
+ type: "INVALID_URL",
95
+ message: `${config.url} contains query parameters: please use options.params object for this purpose.`
96
+ }, {}, {}, config ) ) );
97
+ }
98
+
99
+
100
+ if ( CONTENT_TYPE_DOWNLOADS[config.contentType] && finalMethod === "GET" ) {
101
+ finalHeaders.credentials = "same-origin";
102
+
103
+ finalHeaders.accept = "*/*";
104
+ }
105
+
106
+ if ( config.form ) {
107
+
108
+ // For form data posts, we want the browser to build the Content-
109
+ // Type for us so that it puts in both the "multipart/form-data" plus the
110
+ // correct, auto-generated field delimiter.
111
+ delete ( finalHeaders["content-type"] );
112
+
113
+ finalMethod = "POST";
114
+ finalBody = buildFormData( config.form );
115
+
116
+ } else if ( config.json ) {
117
+
118
+ finalHeaders["content-type"] = ( config.contentType || "application/x-json" );
119
+ finalBody = JSON.stringify( config.json );
120
+
121
+ } else if ( config.body ) {
122
+
123
+ finalHeaders["content-type"] = ( config.contentType || "application/octet-stream" );
124
+
125
+ }
126
+ else {
127
+ finalHeaders["content-type"] = config.contentType;
128
+ }
129
+
130
+ request = new window.Request(
131
+ finalUrl,
132
+ {
133
+ headers: finalHeaders,
134
+ method: finalMethod,
135
+ body: finalBody,
136
+ signal: finalSignal.signal
137
+ }
138
+ );
139
+
140
+ //Check if a pending request is in-flight, if so and it is the exact same url abort it.
141
+ if ( _requests[finalUrl] ) {
142
+ _requests[finalUrl].abort();
143
+ }
144
+
145
+ //Cache requests abort signal by url
146
+ cacheRequestSignal( finalUrl, finalSignal );
147
+
148
+ config._promiseChain = Promise.resolve( window.fetch( request ) )
149
+ .then( async ( response ) => {
150
+
151
+ deleteCachedRequestSignal( finalUrl );
152
+
153
+ const data = await unwrapResponseData( response );
154
+
155
+ if ( response.ok ) {
156
+
157
+ //Run response through middleware
158
+ const nextResp = _applyMiddleware( null, response, config );
159
+
160
+ if ( config.downloadFileName ) {
161
+ presetBrowserDownloadDialog( data, config );
162
+ }
163
+
164
+
165
+ return [
166
+ {
167
+ request: request,
168
+ response: nextResp || response,
169
+ data: data
170
+ },
171
+ false
172
+ ]
173
+
174
+ }
175
+
176
+ return handleError(
177
+ normalizeError( data, request, response, config ),
178
+ config
179
+ );
180
+
181
+ } ).catch( ( err ) => {
182
+
183
+ deleteCachedRequestSignal( finalUrl );
184
+
185
+ const error = isNormalizedError( err ) ?
186
+ err :
187
+ normalizeTransportError( err );
188
+
189
+ return handleError(
190
+ error,
191
+ config
192
+ );
193
+ } )
194
+
195
+ }
196
+ catch ( err ) {
197
+
198
+ deleteCachedRequestSignal( finalUrl );
199
+
200
+ return handleError(
201
+ normalizeTransportError( err ),
202
+ config
203
+ );
204
+ }
205
+
206
+
207
+ if ( config._promiseChain ) {
208
+
209
+ //If catch is added outside, then assume they want to handle errors and
210
+ //not have them swallowed
211
+
212
+ config._promiseChain.catch = function ( ...args ) {
213
+ config._hasCatch = true;
214
+ return ORIGINAL_CATCH_FN.apply( this, args );
215
+ };
216
+ }
217
+
218
+ return config._promiseChain;
219
+ }
220
+
221
+ /**
222
+ * Shows the browser download dialog
223
+ * @param {response.blob} blob
224
+ * @param {object} config
225
+ * @returns
226
+ */
227
+ function presetBrowserDownloadDialog( blob, config ) {
228
+ return Download( blob, config.downloadFileName, config.contentType );
229
+ }
230
+
231
+ /**
232
+ * Stores a ref to the abort signal
233
+ * @param {string} url
234
+ * @param {AbortController.signal} signal
235
+ */
236
+ function cacheRequestSignal( url, signal ) {
237
+ _requests[url] = signal;
238
+ }
239
+
240
+
241
+ /**
242
+ * Deletes a req from the cached requests
243
+ * @param {string} url
244
+ */
245
+ function deleteCachedRequestSignal( url ) {
246
+ delete _requests[url];
247
+ }
248
+
249
+
250
+ /**
251
+ * Checks if the error structure mimics ours and has already been normalized.
252
+ * @param {Object} err
253
+ * @returns
254
+ */
255
+ function isNormalizedError( err ) {
256
+ return err.hasOwnProperty( "status" ) && err.hasOwnProperty( "data" )
257
+ }
258
+
259
+
260
+ /**
261
+ * Handles errors by passing them through any middleware and finally throwing them or swallowing them.
262
+ * @param {object} normalizedError
263
+ * @param {object} config
264
+ * @returns
265
+ */
266
+ function handleError( normalizedError, config ) {
267
+ const hasCatch = config._hasCatch;
268
+ const promiseChain = config._promiseChain;
269
+
270
+ const nextErr = _applyMiddleware( normalizedError, null, config );
271
+
272
+ //Only swallow errors if they have been handled by middleware AND they have not
273
+ //Added a catch outside
274
+ if ( !hasCatch && !nextErr ) {
275
+ if ( promiseChain && promiseChain.cancel ) promiseChain.cancel();
276
+ //In the case of aborted requests etc, we treat them as success and let the initial fetch chain
277
+ //handle them.
278
+ return Promise.resolve( [normalizedError, true] );
279
+ }
280
+
281
+ // The request failed in a critical way; the content of this error will be
282
+ // entirely unpredictable.
283
+ return ( Promise.reject( nextErr || normalizedError ) );
284
+ }
285
+
286
+
287
+ /**
288
+ * Passes any errors, responses through configured middleware
289
+ *
290
+ * @param {ErrorEvent} err the error.
291
+ * @param {Object} response the network response.
292
+ * @param {Object} options the request options.
293
+ * @returns null
294
+ */
295
+ function _applyMiddleware( err, response, options ) {
296
+ let i = -1;
297
+
298
+ const next = function ( nextErr, nextState ) {
299
+ i++;
300
+ const middleware = _middlewares[i];
301
+
302
+ if ( !middleware ) return nextErr || nextState;
303
+
304
+ return middleware( nextErr )( nextState )( options )( next );
305
+ };
306
+
307
+ return next( err, response );
308
+ }
309
+
310
+
311
+ /**
312
+ * Unwrap the response payload from the given response based on the reported
313
+ * content-type.
314
+ */
315
+ async function unwrapResponseData( response ) {
316
+
317
+ var contentType = response.headers.has( "content-type" )
318
+ ? response.headers.get( "content-type" )
319
+ : ""
320
+ ;
321
+
322
+ if ( RE_CONTENT_TYPE_JSON.test( contentType ) ) {
323
+
324
+ return ( response.json() );
325
+
326
+ } else if ( RE_CONTENT_TYPE_TEXT.test( contentType ) ) {
327
+
328
+ return ( response.text() );
329
+
330
+ } else {
331
+
332
+ return ( response.blob() );
333
+
334
+ }
335
+
336
+ }
337
+
338
+
339
+ /**
340
+ * FormData instance from the given object.
341
+ *
342
+ * NOTE: At this time, only simple values (ie, no files) are supported.
343
+ */
344
+ function buildFormData( form ) {
345
+ var formData = new FormData();
346
+
347
+ Object.entries( form ).forEach(
348
+ ( [key, value] ) => {
349
+
350
+ formData.append( key, value );
351
+
352
+ }
353
+ );
354
+
355
+ return ( formData );
356
+ }
357
+
358
+
359
+ /**
360
+ * Supports url or url with template identifiers,creates a url with optional query parameters.
361
+ * @param {string} url
362
+ * @param {object} templateData
363
+ * @param {object} params
364
+ * @returns
365
+ */
366
+ function buildURL( url, templateData, params ) {
367
+
368
+ if ( url.href ) return url;
369
+
370
+ const formattedUrl = buildURLTemplate( url, templateData );
371
+
372
+ const finalUrl = new URL( formattedUrl, `${window.location.origin}${window.baseUrl || ""}` );
373
+
374
+ const searchParams = new URLSearchParams();
375
+
376
+ Object.entries( params ).forEach(
377
+ ( [key, value] ) => {
378
+ if ( Array.isArray( value ) ) {
379
+ for ( let i = 0; i < value.length; i++ ) {
380
+ const e = value[i];
381
+ searchParams.append( key, e );
382
+ }
383
+ return;
384
+ }
385
+
386
+ searchParams.append( key, value );
387
+ }
388
+ )
389
+
390
+ finalUrl.search = searchParams;
391
+
392
+ return finalUrl;
393
+ }
394
+
395
+
396
+ /**
397
+ * Builds a urls tring using template identifiers.
398
+ * @param {string} url
399
+ * @param {object} templateData
400
+ */
401
+ function buildURLTemplate( url, templateData ) {
402
+ Object.entries( templateData ).forEach(
403
+ ( [key, value] ) => {
404
+ url = url.replace( new RegExp( `{${key}}`, "ig" ), value.toString() )
405
+ }
406
+ )
407
+
408
+ return url;
409
+ }
410
+
411
+
412
+ /**
413
+ * Transform the collection of HTTP headers into a like collection wherein the names
414
+ * of the headers have been lower-cased. This way, if we need to manipulate the
415
+ * collection prior to transport, we'll know what key-casing to use.
416
+ */
417
+ function buildHeaders( headers ) {
418
+
419
+ var lowercaseHeaders = {};
420
+
421
+ Object.entries( headers ).forEach(
422
+ ( [key, value] ) => {
423
+
424
+ lowercaseHeaders[key.toLowerCase()] = value;
425
+
426
+ }
427
+ );
428
+
429
+ return ( lowercaseHeaders );
430
+
431
+ }
432
+
433
+
434
+ /**
435
+ * At a minimum, we want every error to have the following properties:
436
+ *
437
+ * - data.type
438
+ * - data.message
439
+ * - status.code
440
+ * - status.text
441
+ * - status.isAbort
442
+ *
443
+ * These are the keys that the calling context will depend on; and, are the minimum
444
+ * keys that the server is expected to return when it throws domain errors.
445
+ */
446
+ function normalizeError( data, request, response, config ) {
447
+ var error = {
448
+ data: {
449
+ type: "ServerError",
450
+ message: UNEXPECTED_ERROR_MESSAGE
451
+ },
452
+ status: {
453
+ code: response.status,
454
+ text: response.statusText,
455
+ isAbort: false
456
+ },
457
+ // The following data is being provided to make debugging AJAX errors easier.
458
+ request: request,
459
+ response: response,
460
+ config: config || {}
461
+ };
462
+
463
+ // If the error data is an Object (which it should be if the server responded
464
+ // with a domain-based error), then it should have "type" and "message"
465
+ // properties within it. That said, just because this isn't a transport error, it
466
+ // doesn't mean that this error is actually being returned by our application.
467
+ if (
468
+ ( typeof ( data?.type ) === "string" ) &&
469
+ ( typeof ( data?.message ) === "string" )
470
+ ) {
471
+
472
+ Object.assign( error.data, data );
473
+
474
+ // If the error data has any other shape, it means that an unexpected error
475
+ // occurred on the server (or somewhere in transit). Let's pass that raw error
476
+ // through as the rootCause, using the default error structure.
477
+ } else {
478
+
479
+ error.data.rootCause = data;
480
+
481
+ }
482
+
483
+ return ( error );
484
+ }
485
+
486
+
487
+ /**
488
+ * If our request never makes it to the server (or the round-trip is interrupted
489
+ * somehow), we still want the error response to have a consistent structure with the
490
+ * application errors returned by the server. At a minimum, we want every error to
491
+ * have the following properties:
492
+ *
493
+ * - data.type
494
+ * - data.message
495
+ * - status.code
496
+ * - status.text
497
+ * - status.isAbort
498
+ */
499
+ function normalizeTransportError( transportError ) {
500
+
501
+ const isAbort = ( transportError.name === "AbortError" )
502
+ return ( {
503
+ data: {
504
+ type: "TransportError",
505
+ message: isAbort ? "Network Request Aborted" : UNEXPECTED_ERROR_MESSAGE,
506
+ rootCause: transportError
507
+ },
508
+ status: {
509
+ code: 0,
510
+ text: "Unknown",
511
+ isAbort: isAbort
512
+ }
513
+ } );
514
+
515
+ }
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { default as Download } from './Download';
2
+ export { default as fetch, applyMiddleware } from './FetchWrapper';
3
+ export { ADD_ERROR } from "./constants/ErrorConstants";
@@ -1,4 +1,4 @@
1
- import { dispatch } from "@@/packages/StateManagment";
1
+ import { dispatch } from "@selkirk-systems/state-management";
2
2
  import { ADD_ERROR } from "../constants/ErrorConstants";
3
3
 
4
4
  const handler = ( err ) => ( response ) => ( options ) => ( next ) => {