@data-client/rest 0.7.6 → 0.8.1

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 (77) hide show
  1. package/dist/index.js +18 -76
  2. package/dist/index.umd.min.js +1 -1
  3. package/dist/next.js +0 -566
  4. package/legacy/NetworkError.js +2 -2
  5. package/legacy/RestEndpoint.js +16 -17
  6. package/legacy/RestEndpointTypes.js +1 -1
  7. package/legacy/createResource.js +2 -2
  8. package/legacy/hookifyResource.js +2 -2
  9. package/legacy/index.js +1 -2
  10. package/legacy/next/index.js +2 -4
  11. package/legacy/resourceTypes.js +1 -1
  12. package/lib/NetworkError.d.ts +1 -1
  13. package/lib/NetworkError.js +2 -2
  14. package/lib/RestEndpoint.d.ts +1 -1
  15. package/lib/RestEndpoint.js +16 -17
  16. package/lib/RestEndpointTypes.d.ts +15 -15
  17. package/lib/RestEndpointTypes.d.ts.map +1 -1
  18. package/lib/RestEndpointTypes.js +1 -1
  19. package/lib/createResource.d.ts +1 -1
  20. package/lib/createResource.js +2 -2
  21. package/lib/hookifyResource.d.ts +1 -1
  22. package/lib/hookifyResource.js +2 -2
  23. package/lib/index.d.ts +0 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +1 -2
  26. package/lib/next/index.d.ts +0 -5
  27. package/lib/next/index.d.ts.map +1 -1
  28. package/lib/next/index.js +2 -4
  29. package/lib/resourceTypes.d.ts +13 -13
  30. package/lib/resourceTypes.d.ts.map +1 -1
  31. package/lib/resourceTypes.js +1 -1
  32. package/package.json +2 -2
  33. package/src/NetworkError.ts +1 -1
  34. package/src/RestEndpoint.d.ts +1 -1
  35. package/src/RestEndpoint.js +14 -13
  36. package/src/RestEndpointTypes.ts +15 -15
  37. package/src/__tests__/Resource.test.ts +10 -8
  38. package/src/__tests__/RestEndpoint.ts +55 -13
  39. package/src/__tests__/__snapshots__/RestEndpoint.ts.snap +9 -1
  40. package/src/__tests__/createResource.test.ts +16 -16
  41. package/src/__tests__/hookifyResource.ts +9 -9
  42. package/src/createResource.ts +1 -1
  43. package/src/hookifyResource.ts +1 -1
  44. package/src/index.ts +0 -1
  45. package/src/next/index.ts +0 -5
  46. package/src/resourceTypes.ts +13 -13
  47. package/ts4.0/NetworkError.d.ts +1 -1
  48. package/ts4.0/RestEndpoint.d.ts +1 -1
  49. package/ts4.0/RestEndpointTypes.d.ts +15 -15
  50. package/ts4.0/createResource.d.ts +1 -1
  51. package/ts4.0/hookifyResource.d.ts +1 -1
  52. package/ts4.0/index.d.ts +0 -1
  53. package/ts4.0/next/index.d.ts +0 -5
  54. package/ts4.0/resourceTypes.d.ts +13 -13
  55. package/ts4.1/NetworkError.d.ts +1 -1
  56. package/ts4.1/RestEndpoint.d.ts +1 -1
  57. package/ts4.1/RestEndpointTypes.d.ts +15 -15
  58. package/ts4.1/createResource.d.ts +1 -1
  59. package/ts4.1/hookifyResource.d.ts +1 -1
  60. package/ts4.1/index.d.ts +0 -1
  61. package/ts4.1/next/index.d.ts +0 -5
  62. package/ts4.1/resourceTypes.d.ts +13 -13
  63. package/legacy/getArrayPath.js +0 -19
  64. package/legacy/paginationUpdate.js +0 -36
  65. package/lib/getArrayPath.d.ts +0 -3
  66. package/lib/getArrayPath.d.ts.map +0 -1
  67. package/lib/getArrayPath.js +0 -19
  68. package/lib/paginationUpdate.d.ts +0 -8
  69. package/lib/paginationUpdate.d.ts.map +0 -1
  70. package/lib/paginationUpdate.js +0 -40
  71. package/src/__tests__/getArrayPath.test.ts +0 -30
  72. package/src/getArrayPath.ts +0 -20
  73. package/src/paginationUpdate.ts +0 -49
  74. package/ts4.0/getArrayPath.d.ts +0 -3
  75. package/ts4.0/paginationUpdate.d.ts +0 -10
  76. package/ts4.1/getArrayPath.d.ts +0 -3
  77. package/ts4.1/paginationUpdate.d.ts +0 -10
package/dist/next.js CHANGED
@@ -1,568 +1,2 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var endpoint = require('@data-client/endpoint');
6
- var pathToRegexp = require('path-to-regexp');
7
-
8
- function unwrapExports (x) {
9
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
- }
11
-
12
- function createCommonjsModule(fn, module) {
13
- return module = { exports: {} }, fn(module, module.exports), module.exports;
14
- }
15
-
16
- var classPrivateFieldLooseBase = createCommonjsModule(function (module) {
17
- function _classPrivateFieldBase(receiver, privateKey) {
18
- if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
19
- throw new TypeError("attempted to use private field on non-instance");
20
- }
21
- return receiver;
22
- }
23
- module.exports = _classPrivateFieldBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
24
- });
25
-
26
- var _classPrivateFieldLooseBase = unwrapExports(classPrivateFieldLooseBase);
27
-
28
- var classPrivateFieldLooseKey = createCommonjsModule(function (module) {
29
- var id = 0;
30
- function _classPrivateFieldKey(name) {
31
- return "__private_" + id++ + "_" + name;
32
- }
33
- module.exports = _classPrivateFieldKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
34
- });
35
-
36
- var _classPrivateFieldLooseKey = unwrapExports(classPrivateFieldLooseKey);
37
-
38
- function extractCollection(s, mapper) {
39
- if (typeof s !== 'object' || s === undefined || Array.isArray(s)) return;
40
- if (s instanceof endpoint.schema.Collection) {
41
- return mapper(s);
42
- }
43
- const objCopy = {
44
- ...(s instanceof endpoint.schema.Object ? s.schema : s)
45
- };
46
- for (const k in objCopy) {
47
- if (!objCopy[k]) continue;
48
- const collection = extractCollection(objCopy[k], mapper);
49
- if (collection) return collection;
50
- }
51
- }
52
-
53
- function mapCollection(s, mapper) {
54
- if (typeof s !== 'object' || s === undefined) return s;
55
- if (s instanceof endpoint.schema.Collection) {
56
- return mapper(s);
57
- }
58
- const objCopy = {
59
- ...(s instanceof endpoint.schema.Object ? s.schema : s)
60
- };
61
- for (const k in objCopy) {
62
- if (!objCopy[k]) continue;
63
- objCopy[k] = mapCollection(objCopy[k], mapper);
64
- }
65
- return objCopy;
66
- }
67
-
68
- /** An error with a Rest Endpoint fetch
69
- *
70
- * @see https://resthooks.io/rest/api/NetworkError
71
- */
72
- class NetworkError extends Error {
73
- constructor(response) {
74
- super(response.statusText || `Network response not 'ok': ${response.status}`);
75
- this.name = 'NetworkError';
76
- this.status = response.status;
77
- this.response = response;
78
- }
79
- }
80
-
81
- function paginatedMerge(existing, incoming) {
82
- const existingSet = new Set(existing);
83
- const mergedList = [...existing];
84
- for (const pk of incoming) {
85
- if (!existingSet.has(pk)) mergedList.push(pk);
86
- }
87
- return mergedList;
88
- }
89
- function createPaginationSchema(removeCursor, collection) {
90
- return Object.create(collection, {
91
- name: {
92
- value: `Pagination(${collection.schema})`
93
- },
94
- merge: {
95
- value: paginatedMerge
96
- },
97
- pk: {
98
- value: function (value, parent, key, args) {
99
- return collection.pk.call(this, value, parent, key, removeCursor(...args));
100
- }
101
- }
102
- });
103
- }
104
-
105
- function getArrayPath(s) {
106
- if (typeof s !== 'object') return false;
107
- if (s === undefined || s instanceof endpoint.schema.Array || Array.isArray(s)) {
108
- return [];
109
- }
110
- const o = s instanceof endpoint.schema.Object ? s.schema : s;
111
- for (const k in o) {
112
- if (!o[k]) continue;
113
- const path = getArrayPath(o[k]);
114
- if (path !== false) {
115
- // mutation is ok because there is only one path
116
- path.unshift(k);
117
- return path;
118
- }
119
- }
120
- return false;
121
- }
122
-
123
- function paginationUpdate(endpoint, removeCursor) {
124
- // infer path from schema. if schema is undefined assume array is top level
125
- const path = getArrayPath(endpoint.schema);
126
- if (path === false) throw new Error('schema has no array');
127
- return (newPage, ...args) => ({
128
- [endpoint.key(...removeCursor(...args))]: existing => {
129
- const existingList = getIn(existing, path);
130
- // using set so our lookups are O(1) in case this is large
131
- const existingSet = new Set(existingList);
132
- const addedList = getIn(newPage, path).filter(pk => !existingSet.has(pk));
133
- const mergedResults = [...existingList, ...addedList];
134
- return setIn(newPage, path, mergedResults);
135
- }
136
- });
137
- }
138
- const getIn = (results, path) => {
139
- let cur = results;
140
- for (const p of path) {
141
- if (!cur) return [];
142
- cur = cur[p];
143
- }
144
- return cur || [];
145
- };
146
- const setIn = (results, path, values) => {
147
- if (path.length === 0) return values;
148
- const newResults = {
149
- ...results
150
- };
151
- let cur = newResults;
152
- for (let i = 0; i < path.length - 1; i++) {
153
- const p = path[i];
154
- cur = cur[p] = {
155
- ...cur[p]
156
- };
157
- }
158
- cur[path[path.length - 1]] = values;
159
- return newResults;
160
- };
161
-
162
- function paramsToString(searchParams) {
163
- const params = new URLSearchParams(searchParams);
164
- params.sort();
165
- return params.toString();
166
- }
167
-
168
- const urlBaseCache = Object.create(null);
169
- function getUrlBase(path) {
170
- if (!(path in urlBaseCache)) {
171
- urlBaseCache[path] = pathToRegexp.compile(path, {
172
- encode: encodeURIComponent,
173
- validate: false
174
- });
175
- }
176
- return urlBaseCache[path];
177
- }
178
- const urlTokensCache = Object.create(null);
179
- function getUrlTokens(path) {
180
- if (!(path in urlTokensCache)) {
181
- urlTokensCache[path] = new Set(pathToRegexp.parse(path).map(t => typeof t === 'string' ? t : `${t['name']}`));
182
- }
183
- return urlTokensCache[path];
184
- }
185
- const proto = Object.prototype;
186
- const gpo = Object.getPrototypeOf;
187
- function isPojo(obj) {
188
- if (obj === null || typeof obj !== 'object') {
189
- return false;
190
- }
191
- return gpo(obj) === proto;
192
- }
193
- function shortenPath(path) {
194
- const lastColonIndex = path.lastIndexOf(':');
195
- if (lastColonIndex === -1) throw new Error('Resource path requires at least one :parameter');
196
- // this is for when not specifying a specific item like create/list
197
- let shortUrlRoot = path.substring(0, lastColonIndex);
198
- if (shortUrlRoot[shortUrlRoot.length - 1] === '/') shortUrlRoot = shortUrlRoot.substring(0, shortUrlRoot.length - 1);
199
- return shortUrlRoot;
200
- }
201
-
202
- /** Simplifies endpoint definitions that follow REST patterns
203
- *
204
- * @see https://resthooks.io/rest/api/RestEndpoint
205
- */
206
- var _hasBody = /*#__PURE__*/_classPrivateFieldLooseKey("hasBody");
207
- class RestEndpoint extends endpoint.Endpoint {
208
- constructor(options) {
209
- var _options$fetch;
210
- super((_options$fetch = options.fetch) != null ? _options$fetch : async function (...args) {
211
- const urlParams = _classPrivateFieldLooseBase(this, _hasBody)[_hasBody] && args.length < 2 ? {} : args[0] || {};
212
- const body = _classPrivateFieldLooseBase(this, _hasBody)[_hasBody] ? args[args.length - 1] : undefined;
213
- return this.fetchResponse(this.url(urlParams), await this.getRequestInit(body)).then(response => this.parseResponse(response)).then(res => this.process(res, ...args));
214
- }, options);
215
- // we want to use the prototype chain here
216
- Object.defineProperty(this, _hasBody, {
217
- writable: true,
218
- value: void 0
219
- });
220
- if (!('sideEffect' in this) || 'method' in options && !('sideEffect' in options)) {
221
- this.sideEffect = options.method === 'GET' || options.method === undefined ? undefined : true;
222
- }
223
- if (this.method === undefined) {
224
- this.method = this.sideEffect ? 'POST' : 'GET';
225
- }
226
- if (this.urlPrefix === undefined) {
227
- this.urlPrefix = '';
228
- }
229
- _classPrivateFieldLooseBase(this, _hasBody)[_hasBody] = (!('body' in this) || this.body !== undefined) && !['GET', 'DELETE'].includes(this.method);
230
- Object.defineProperty(this, 'name', {
231
- get() {
232
- // using 'in' to ensure inheritance lookup
233
- if ('__name' in this) return this.__name;
234
- return this.urlPrefix + this.path;
235
- }
236
- });
237
- }
238
- key(...args) {
239
- return `${this.method} ${this.url(_classPrivateFieldLooseBase(this, _hasBody)[_hasBody] && args.length < 2 ? {} : args[0] || {})}`;
240
- }
241
-
242
- /** Get the url */
243
- url(urlParams = {}) {
244
- const urlBase = getUrlBase(this.path)(urlParams);
245
- const tokens = getUrlTokens(this.path);
246
- const searchParams = {};
247
- Object.keys(urlParams).forEach(k => {
248
- if (!tokens.has(k)) {
249
- searchParams[k] = urlParams[k];
250
- }
251
- });
252
- if (Object.keys(searchParams).length) {
253
- return `${this.urlPrefix}${urlBase}?${paramsToString(searchParams)}`;
254
- }
255
- return `${this.urlPrefix}${urlBase}`;
256
- }
257
- getHeaders(headers) {
258
- return headers;
259
- }
260
-
261
- /** Init options for fetch - run at fetch */
262
- async getRequestInit(body) {
263
- const bodyIsPojo = isPojo(body);
264
- if (bodyIsPojo) {
265
- body = JSON.stringify(body);
266
- }
267
- const init = {
268
- ...this.requestInit,
269
- method: this.method,
270
- signal: this.signal,
271
- body
272
- };
273
- if (!body || bodyIsPojo) {
274
- init.headers = {
275
- // default to application/json but allow user explicit overrides
276
- 'Content-Type': 'application/json',
277
- ...init.headers
278
- };
279
- }
280
- init.headers = await this.getHeaders(init.headers);
281
- return init;
282
- }
283
-
284
- /** Perform network request and resolve with HTTP Response */
285
- fetchResponse(input, init) {
286
- return fetch(input, init).then(response => {
287
- if (!response.ok) {
288
- throw new NetworkError(response);
289
- }
290
- return response;
291
- }).catch(error => {
292
- // ensure CORS, network down, and parse errors are still caught by NetworkErrorBoundary
293
- if (error instanceof TypeError) {
294
- error.status = 500;
295
- }
296
- throw error;
297
- });
298
- }
299
- parseResponse(response) {
300
- var _response$headers$get;
301
- // this should not have any content to read
302
- if (response.status === 204) return Promise.resolve(null);
303
- if (!((_response$headers$get = response.headers.get('content-type')) != null && _response$headers$get.includes('json'))) {
304
- return response.text().then(text => {
305
- // string or 'not set' schema, are valid
306
- // when overriding process they might handle other cases, so we don't want to block on our logic
307
- if (['string', 'undefined'].includes(typeof this.schema) || this.schema === null || this.process !== RestEndpoint.prototype.process) return text;
308
- const error = new NetworkError(response);
309
- error.status = 404;
310
- error.message = `Unexpected text response for schema ${this.schema}`;
311
- // custom dev-only messages for more detailed cause
312
- /* istanbul ignore else */
313
- if (process.env.NODE_ENV !== 'production') {
314
- var _response$headers$get2;
315
- if (!((_response$headers$get2 = response.headers.get('content-type')) != null && _response$headers$get2.includes('html') || text.startsWith('<!doctype html>'))) {
316
- if (tryParse(text) !== undefined) {
317
- error.message = `"content-type" header does not include "json", but JSON response found.
318
- See https://www.rfc-editor.org/rfc/rfc4627 for information on JSON responses
319
-
320
- Using parsed JSON.
321
- If text content was expected see https://resthooks.io/rest/api/RestEndpoint#parseResponse`;
322
- }
323
- } else {
324
- error.message = `Unexpected html response for schema ${this.schema}
325
- This likely means no API endpoint was configured for this request, resulting in an HTML fallback.
326
-
327
- Response (first 300 characters): ${text.substring(0, 300)}`;
328
- }
329
- }
330
- throw error;
331
- });
332
- }
333
- return response.json().catch(error => {
334
- error.status = 400;
335
- throw error;
336
- });
337
- }
338
- process(value) {
339
- return value;
340
- }
341
- errorPolicy(error) {
342
- return error.status >= 500 ? 'soft' : undefined;
343
- }
344
- get pathRegex() {
345
- return pathToRegexp.pathToRegexp(this.path);
346
- }
347
- testKey(key) {
348
- const prefix = this.method + ' ' + this.urlPrefix;
349
- if (!key.startsWith(prefix)) return false;
350
- let lastQuestion = key.lastIndexOf('?');
351
- if (lastQuestion === -1) lastQuestion = undefined;
352
- return this.pathRegex.test(key.substring(prefix.length, lastQuestion));
353
- }
354
- extend(options) {
355
- // make a constructor/prototype based off this
356
- // extend from it and init with options sent
357
- class E extends this.constructor {}
358
- Object.assign(E.prototype, this);
359
- return new E(
360
- // fetch get overridden by function prototype, so we must set it explicitly every time
361
- {
362
- fetch: this.fetch,
363
- ...options
364
- });
365
- }
366
- paginated(removeCursor) {
367
- if (typeof removeCursor === 'string') {
368
- const fieldName = removeCursor;
369
- removeCursor = ({
370
- ...params
371
- }) => {
372
- delete params[fieldName];
373
- return [params];
374
- };
375
- }
376
- let found = false;
377
- const createPaginatedSchema = collection => {
378
- found = true;
379
- return createPaginationSchema(removeCursor, collection);
380
- };
381
- const newSchema = mapCollection(this.schema, createPaginatedSchema);
382
- if (found) {
383
- const sup = this;
384
- return this.extend({
385
- schema: newSchema,
386
- key(...args) {
387
- return sup.key.call(this, ...removeCursor(...args));
388
- }
389
- });
390
- }
391
- return this.extend({
392
- update: paginationUpdate(this, removeCursor)
393
- });
394
- }
395
- get getPage() {
396
- return this.paginated(this.paginationField);
397
- }
398
- get push() {
399
- return this.extend({
400
- method: 'POST',
401
- schema: extractCollection(this.schema, s => s.push)
402
- });
403
- }
404
- get unshift() {
405
- return this.extend({
406
- method: 'POST',
407
- schema: extractCollection(this.schema, s => s.unshift)
408
- });
409
- }
410
- get assign() {
411
- return this.extend({
412
- method: 'POST',
413
- schema: extractCollection(this.schema, s => s.assign)
414
- });
415
- }
416
- }
417
- const tryParse = input => {
418
- try {
419
- return JSON.parse(input);
420
- } catch (e) {
421
- return undefined;
422
- }
423
- };
424
-
425
- const {
426
- Invalidate,
427
- Collection: BaseCollection
428
- } = endpoint.schema;
429
-
430
- /** Creates collection of Endpoints for common operations on a given data/schema.
431
- *
432
- * @see https://resthooks.io/rest/api/createResource
433
- */
434
- function createResource({
435
- path,
436
- schema,
437
- Endpoint = RestEndpoint,
438
- Collection = BaseCollection,
439
- optimistic,
440
- paginationField,
441
- ...extraOptions
442
- }) {
443
- const shortenedPath = shortenPath(path);
444
- const getName = name => `${schema == null ? void 0 : schema.name}.${name}`;
445
- // this accounts for derivative endpoints
446
- function extendMember(extended, key, options) {
447
- extended[key] = extended[key].extend(options);
448
- }
449
- const extraMutateOptions = {
450
- ...extraOptions
451
- };
452
- const extraPartialOptions = {
453
- ...extraOptions
454
- };
455
- const get = new Endpoint({
456
- ...extraOptions,
457
- path,
458
- schema,
459
- name: getName('get')
460
- });
461
- if (optimistic) {
462
- extraMutateOptions.getOptimisticResponse = optimisticUpdate;
463
- extraPartialOptions.getOptimisticResponse = optimisticPartial(get);
464
- }
465
- const getList = new Endpoint({
466
- ...extraMutateOptions,
467
- paginationField: paginationField,
468
- path: shortenedPath,
469
- schema: new Collection([schema]),
470
- name: getName('getList')
471
- });
472
- const ret = {
473
- get,
474
- getList,
475
- // TODO(deprecated): remove this once we remove creates
476
- create: getList.push.extend({
477
- name: getName('create')
478
- }),
479
- update: new Endpoint({
480
- ...extraMutateOptions,
481
- path,
482
- schema,
483
- method: 'PUT',
484
- name: getName('update')
485
- }),
486
- partialUpdate: new Endpoint({
487
- ...extraPartialOptions,
488
- path,
489
- schema,
490
- method: 'PATCH',
491
- name: getName('partialUpdate')
492
- }),
493
- delete: new Endpoint({
494
- ...extraMutateOptions,
495
- path,
496
- schema: schema.process ? new Invalidate(schema) : schema,
497
- method: 'DELETE',
498
- name: getName('delete'),
499
- process(res, params) {
500
- return res && Object.keys(res).length ? res : params;
501
- },
502
- getOptimisticResponse: optimistic ? optimisticDelete : undefined
503
- }),
504
- extend(...args) {
505
- if (typeof args[0] === 'string') {
506
- const [key, options] = args;
507
- if (key in this) {
508
- const extended = {
509
- ...this
510
- };
511
- extendMember(extended, key, options);
512
- return extended;
513
- } else {
514
- return {
515
- ...this,
516
- [key]: this.get.extend(options)
517
- };
518
- }
519
- } else if (typeof args[0] === 'function') {
520
- const extended = args[0](this);
521
- return {
522
- ...this,
523
- ...extended
524
- };
525
- }
526
- const overrides = args[0];
527
- const extended = {
528
- ...this
529
- };
530
- for (const key in overrides) {
531
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
532
- // @ts-ignore
533
- extendMember(extended, key, overrides[key]);
534
- }
535
- return extended;
536
- }
537
- };
538
- return ret;
539
- }
540
- function optimisticUpdate(snap, params, body) {
541
- return {
542
- ...params,
543
- ...ensurePojo(body)
544
- };
545
- }
546
- function optimisticPartial(getEndpoint) {
547
- return function (snap, params, body) {
548
- const {
549
- data
550
- } = snap.getResponse(getEndpoint, params);
551
- if (!data) throw new endpoint.AbortOptimistic();
552
- return {
553
- ...params,
554
- ...data,
555
- // even tho we don't always have two arguments, the extra one will simply be undefined which spreads fine
556
- ...ensurePojo(body)
557
- };
558
- };
559
- }
560
- function optimisticDelete(snap, params) {
561
- return params;
562
- }
563
- function ensurePojo(body) {
564
- return body instanceof FormData ? Object.fromEntries(body.entries()) : body;
565
- }
566
-
567
- exports.RestEndpoint = RestEndpoint;
568
- exports.createResource = createResource;
@@ -1,6 +1,6 @@
1
1
  /** An error with a Rest Endpoint fetch
2
2
  *
3
- * @see https://resthooks.io/rest/api/NetworkError
3
+ * @see https://dataclient.io/rest/api/NetworkError
4
4
  */
5
5
  export default class NetworkError extends Error {
6
6
  constructor(response) {
@@ -10,4 +10,4 @@ export default class NetworkError extends Error {
10
10
  this.response = response;
11
11
  }
12
12
  }
13
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJOZXR3b3JrRXJyb3IiLCJFcnJvciIsImNvbnN0cnVjdG9yIiwicmVzcG9uc2UiLCJzdGF0dXNUZXh0Iiwic3RhdHVzIiwibmFtZSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9OZXR3b3JrRXJyb3IudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqIEFuIGVycm9yIHdpdGggYSBSZXN0IEVuZHBvaW50IGZldGNoXG4gKlxuICogQHNlZSBodHRwczovL3Jlc3Rob29rcy5pby9yZXN0L2FwaS9OZXR3b3JrRXJyb3JcbiAqL1xuZXhwb3J0IGRlZmF1bHQgY2xhc3MgTmV0d29ya0Vycm9yIGV4dGVuZHMgRXJyb3Ige1xuICBkZWNsYXJlIHN0YXR1czogbnVtYmVyO1xuICBkZWNsYXJlIHJlc3BvbnNlOiBSZXNwb25zZTtcbiAgbmFtZSA9ICdOZXR3b3JrRXJyb3InO1xuXG4gIGNvbnN0cnVjdG9yKHJlc3BvbnNlOiBSZXNwb25zZSkge1xuICAgIHN1cGVyKFxuICAgICAgcmVzcG9uc2Uuc3RhdHVzVGV4dCB8fCBgTmV0d29yayByZXNwb25zZSBub3QgJ29rJzogJHtyZXNwb25zZS5zdGF0dXN9YCxcbiAgICApO1xuICAgIHRoaXMuc3RhdHVzID0gcmVzcG9uc2Uuc3RhdHVzO1xuICAgIHRoaXMucmVzcG9uc2UgPSByZXNwb25zZTtcbiAgfVxufVxuIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGVBQWUsTUFBTUEsWUFBWSxTQUFTQyxLQUFLLENBQUM7RUFLOUNDLFdBQVdBLENBQUNDLFFBQWtCLEVBQUU7SUFDOUI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