@dhis2/app-service-data 3.16.0 → 3.17.0-beta.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.
Files changed (180) hide show
  1. package/build/cjs/__tests__/integration.test.js +10 -16
  2. package/build/cjs/__tests__/mutations.test.js +5 -8
  3. package/build/cjs/index.js +16 -44
  4. package/build/cjs/react/components/CustomDataProvider.js +9 -11
  5. package/build/cjs/react/components/DataMutation.js +7 -8
  6. package/build/cjs/react/components/DataProvider.js +3 -4
  7. package/build/cjs/react/components/DataProvider.test.js +3 -4
  8. package/build/cjs/react/components/DataQuery.js +8 -9
  9. package/build/cjs/react/components/index.js +33 -0
  10. package/build/cjs/react/context/DataContext.js +2 -2
  11. package/build/cjs/react/context/defaultDataContext.js +13 -0
  12. package/build/cjs/react/context/{defaultContext.test.js → defaultDataContext.test.js} +3 -3
  13. package/build/cjs/react/hooks/index.js +26 -0
  14. package/build/cjs/react/hooks/useDataMutation.js +6 -7
  15. package/build/cjs/react/hooks/useDataMutation.test.js +44 -71
  16. package/build/cjs/react/hooks/useDataQuery.js +10 -14
  17. package/build/cjs/react/hooks/useDataQuery.test.js +172 -265
  18. package/build/cjs/react/hooks/useQueryExecutor.js +11 -13
  19. package/build/cjs/react/hooks/useQueryExecutor.test.js +12 -16
  20. package/build/cjs/react/hooks/useStaticInput.js +4 -5
  21. package/build/cjs/react/hooks/useStaticInput.test.js +24 -39
  22. package/build/cjs/react/index.js +22 -77
  23. package/build/es/__tests__/integration.test.js +10 -16
  24. package/build/es/__tests__/mutations.test.js +5 -8
  25. package/build/es/index.js +2 -3
  26. package/build/es/react/components/CustomDataProvider.js +7 -9
  27. package/build/es/react/components/DataMutation.js +7 -8
  28. package/build/es/react/components/DataProvider.js +1 -2
  29. package/build/es/react/components/DataProvider.test.js +1 -2
  30. package/build/es/react/components/DataQuery.js +8 -9
  31. package/build/es/react/components/index.js +4 -0
  32. package/build/es/react/context/DataContext.js +2 -2
  33. package/build/es/react/context/{defaultContext.js → defaultDataContext.js} +2 -3
  34. package/build/es/react/context/{defaultContext.test.js → defaultDataContext.test.js} +3 -3
  35. package/build/es/react/hooks/index.js +3 -0
  36. package/build/es/react/hooks/useDataMutation.js +6 -7
  37. package/build/es/react/hooks/useDataMutation.test.js +44 -71
  38. package/build/es/react/hooks/useDataQuery.js +10 -14
  39. package/build/es/react/hooks/useDataQuery.test.js +172 -265
  40. package/build/es/react/hooks/useQueryExecutor.js +10 -12
  41. package/build/es/react/hooks/useQueryExecutor.test.js +12 -16
  42. package/build/es/react/hooks/useStaticInput.js +4 -5
  43. package/build/es/react/hooks/useStaticInput.test.js +24 -39
  44. package/build/es/react/index.js +3 -11
  45. package/build/types/index.d.ts +2 -3
  46. package/build/types/react/components/CustomDataProvider.d.ts +1 -1
  47. package/build/types/react/components/DataMutation.d.ts +1 -1
  48. package/build/types/react/components/DataQuery.d.ts +1 -1
  49. package/build/types/react/components/index.d.ts +4 -0
  50. package/build/types/react/context/defaultDataContext.d.ts +4 -0
  51. package/build/types/react/hooks/index.d.ts +3 -0
  52. package/build/types/react/hooks/mergeAndCompareVariables.d.ts +1 -1
  53. package/build/types/react/hooks/useDataEngine.d.ts +1 -1
  54. package/build/types/react/hooks/useDataMutation.d.ts +1 -1
  55. package/build/types/react/hooks/useDataQuery.d.ts +1 -1
  56. package/build/types/react/index.d.ts +2 -11
  57. package/build/types/types.d.ts +2 -7
  58. package/package.json +4 -3
  59. package/build/cjs/engine/DataEngine.js +0 -73
  60. package/build/cjs/engine/DataEngine.test.js +0 -156
  61. package/build/cjs/engine/helpers/getMutationFetchType.js +0 -8
  62. package/build/cjs/engine/helpers/getMutationFetchType.test.js +0 -39
  63. package/build/cjs/engine/helpers/resolveDynamicQuery.js +0 -21
  64. package/build/cjs/engine/helpers/resolveDynamicQuery.test.js +0 -63
  65. package/build/cjs/engine/helpers/validate.js +0 -62
  66. package/build/cjs/engine/helpers/validate.test.js +0 -206
  67. package/build/cjs/engine/index.js +0 -104
  68. package/build/cjs/engine/types/DataEngineLink.js +0 -1
  69. package/build/cjs/engine/types/ExecuteOptions.js +0 -1
  70. package/build/cjs/engine/types/FetchError.js +0 -24
  71. package/build/cjs/engine/types/FetchError.test.js +0 -14
  72. package/build/cjs/engine/types/InvalidQueryError.js +0 -18
  73. package/build/cjs/engine/types/JsonValue.js +0 -1
  74. package/build/cjs/engine/types/Mutation.js +0 -1
  75. package/build/cjs/engine/types/PossiblyDynamic.js +0 -1
  76. package/build/cjs/engine/types/Query.js +0 -1
  77. package/build/cjs/engine/types/QueryParameters.js +0 -1
  78. package/build/cjs/links/CustomDataLink.js +0 -51
  79. package/build/cjs/links/CustomDataLink.test.js +0 -73
  80. package/build/cjs/links/ErrorLink.js +0 -20
  81. package/build/cjs/links/RestAPILink/fetchData.js +0 -80
  82. package/build/cjs/links/RestAPILink/fetchData.test.js +0 -132
  83. package/build/cjs/links/RestAPILink/metadataResources.js +0 -22
  84. package/build/cjs/links/RestAPILink/path.js +0 -14
  85. package/build/cjs/links/RestAPILink/path.test.js +0 -16
  86. package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +0 -58
  87. package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.test.js +0 -73
  88. package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.js +0 -80
  89. package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +0 -120
  90. package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +0 -170
  91. package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +0 -246
  92. package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +0 -14
  93. package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.test.js +0 -20
  94. package/build/cjs/links/RestAPILink/queryToRequestOptions.js +0 -34
  95. package/build/cjs/links/RestAPILink/queryToRequestOptions.test.js +0 -107
  96. package/build/cjs/links/RestAPILink/queryToResourcePath.js +0 -82
  97. package/build/cjs/links/RestAPILink/queryToResourcePath.test.js +0 -173
  98. package/build/cjs/links/RestAPILink/validateQuery.js +0 -59
  99. package/build/cjs/links/RestAPILink/validateQuery.test.js +0 -209
  100. package/build/cjs/links/RestAPILink.js +0 -33
  101. package/build/cjs/links/RestAPILink.test.js +0 -21
  102. package/build/cjs/links/index.js +0 -38
  103. package/build/cjs/locales/en/translations.json +0 -3
  104. package/build/cjs/locales/index.js +0 -21
  105. package/build/cjs/react/context/defaultContext.js +0 -14
  106. package/build/es/engine/DataEngine.js +0 -66
  107. package/build/es/engine/DataEngine.test.js +0 -154
  108. package/build/es/engine/helpers/getMutationFetchType.js +0 -1
  109. package/build/es/engine/helpers/getMutationFetchType.test.js +0 -37
  110. package/build/es/engine/helpers/resolveDynamicQuery.js +0 -14
  111. package/build/es/engine/helpers/resolveDynamicQuery.test.js +0 -61
  112. package/build/es/engine/helpers/validate.js +0 -53
  113. package/build/es/engine/helpers/validate.test.js +0 -204
  114. package/build/es/engine/index.js +0 -10
  115. package/build/es/engine/types/DataEngineLink.js +0 -1
  116. package/build/es/engine/types/ExecuteOptions.js +0 -1
  117. package/build/es/engine/types/FetchError.js +0 -17
  118. package/build/es/engine/types/FetchError.test.js +0 -12
  119. package/build/es/engine/types/InvalidQueryError.js +0 -11
  120. package/build/es/engine/types/JsonValue.js +0 -1
  121. package/build/es/engine/types/Mutation.js +0 -1
  122. package/build/es/engine/types/PossiblyDynamic.js +0 -1
  123. package/build/es/engine/types/Query.js +0 -1
  124. package/build/es/engine/types/QueryParameters.js +0 -1
  125. package/build/es/links/CustomDataLink.js +0 -44
  126. package/build/es/links/CustomDataLink.test.js +0 -71
  127. package/build/es/links/ErrorLink.js +0 -13
  128. package/build/es/links/RestAPILink/fetchData.js +0 -71
  129. package/build/es/links/RestAPILink/fetchData.test.js +0 -130
  130. package/build/es/links/RestAPILink/metadataResources.js +0 -16
  131. package/build/es/links/RestAPILink/path.js +0 -7
  132. package/build/es/links/RestAPILink/path.test.js +0 -14
  133. package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +0 -47
  134. package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.test.js +0 -71
  135. package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.js +0 -70
  136. package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +0 -118
  137. package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +0 -151
  138. package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +0 -244
  139. package/build/es/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +0 -7
  140. package/build/es/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.test.js +0 -18
  141. package/build/es/links/RestAPILink/queryToRequestOptions.js +0 -27
  142. package/build/es/links/RestAPILink/queryToRequestOptions.test.js +0 -105
  143. package/build/es/links/RestAPILink/queryToResourcePath.js +0 -75
  144. package/build/es/links/RestAPILink/queryToResourcePath.test.js +0 -171
  145. package/build/es/links/RestAPILink/validateQuery.js +0 -52
  146. package/build/es/links/RestAPILink/validateQuery.test.js +0 -207
  147. package/build/es/links/RestAPILink.js +0 -26
  148. package/build/es/links/RestAPILink.test.js +0 -19
  149. package/build/es/links/index.js +0 -4
  150. package/build/es/locales/en/translations.json +0 -3
  151. package/build/es/locales/index.js +0 -13
  152. package/build/types/engine/DataEngine.d.ts +0 -13
  153. package/build/types/engine/helpers/getMutationFetchType.d.ts +0 -3
  154. package/build/types/engine/helpers/resolveDynamicQuery.d.ts +0 -2
  155. package/build/types/engine/helpers/validate.d.ts +0 -4
  156. package/build/types/engine/index.d.ts +0 -9
  157. package/build/types/engine/types/DataEngineLink.d.ts +0 -9
  158. package/build/types/engine/types/ExecuteOptions.d.ts +0 -9
  159. package/build/types/engine/types/FetchError.d.ts +0 -19
  160. package/build/types/engine/types/InvalidQueryError.d.ts +0 -5
  161. package/build/types/engine/types/JsonValue.d.ts +0 -6
  162. package/build/types/engine/types/Mutation.d.ts +0 -29
  163. package/build/types/engine/types/PossiblyDynamic.d.ts +0 -1
  164. package/build/types/engine/types/Query.d.ts +0 -24
  165. package/build/types/engine/types/QueryParameters.d.ts +0 -12
  166. package/build/types/links/CustomDataLink.d.ts +0 -17
  167. package/build/types/links/ErrorLink.d.ts +0 -6
  168. package/build/types/links/RestAPILink/fetchData.d.ts +0 -4
  169. package/build/types/links/RestAPILink/metadataResources.d.ts +0 -2
  170. package/build/types/links/RestAPILink/path.d.ts +0 -1
  171. package/build/types/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.d.ts +0 -6
  172. package/build/types/links/RestAPILink/queryToRequestOptions/requestContentType.d.ts +0 -6
  173. package/build/types/links/RestAPILink/queryToRequestOptions/textPlainMatchers.d.ts +0 -14
  174. package/build/types/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.d.ts +0 -2
  175. package/build/types/links/RestAPILink/queryToRequestOptions.d.ts +0 -2
  176. package/build/types/links/RestAPILink/queryToResourcePath.d.ts +0 -3
  177. package/build/types/links/RestAPILink/validateQuery.d.ts +0 -2
  178. package/build/types/links/RestAPILink.d.ts +0 -10
  179. package/build/types/links/index.d.ts +0 -3
  180. package/build/types/react/context/defaultContext.d.ts +0 -4
@@ -13,14 +13,11 @@ describe('useDataQuery', () => {
13
13
  const data = {
14
14
  answer: 42
15
15
  };
16
- const wrapper = _ref => {
17
- let {
18
- children
19
- } = _ref;
20
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
21
- data: data
22
- }, children);
23
- };
16
+ const wrapper = ({
17
+ children
18
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
19
+ data: data
20
+ }, children);
24
21
  const onComplete = jest.fn();
25
22
  const onError = jest.fn();
26
23
  const {
@@ -62,14 +59,11 @@ describe('useDataQuery', () => {
62
59
  throw expectedError;
63
60
  }
64
61
  };
65
- const wrapper = _ref2 => {
66
- let {
67
- children
68
- } = _ref2;
69
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
70
- data: data
71
- }, children);
72
- };
62
+ const wrapper = ({
63
+ children
64
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
65
+ data: data
66
+ }, children);
73
67
  const onComplete = jest.fn();
74
68
  const onError = jest.fn();
75
69
  const {
@@ -102,36 +96,30 @@ describe('useDataQuery', () => {
102
96
  const query = {
103
97
  x: {
104
98
  resource: 'answer',
105
- id: _ref3 => {
106
- let {
107
- id
108
- } = _ref3;
109
- return id;
110
- }
99
+ id: ({
100
+ id
101
+ }) => id
111
102
  }
112
103
  };
113
- const mockSpy = jest.fn((_, _ref4) => {
114
- let {
115
- id
116
- } = _ref4;
104
+ const mockSpy = jest.fn((_, {
105
+ id
106
+ }) => {
117
107
  switch (id) {
118
108
  case one:
119
109
  return Promise.resolve(resultOne);
120
110
  case two:
121
111
  return Promise.resolve(resultTwo);
122
112
  }
113
+ return Promise.resolve(undefined);
123
114
  });
124
115
  const data = {
125
116
  answer: mockSpy
126
117
  };
127
- const wrapper = _ref5 => {
128
- let {
129
- children
130
- } = _ref5;
131
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
132
- data: data
133
- }, children);
134
- };
118
+ const wrapper = ({
119
+ children
120
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
121
+ data: data
122
+ }, children);
135
123
  const initialProps = {
136
124
  query,
137
125
  options: {
@@ -189,14 +177,11 @@ describe('useDataQuery', () => {
189
177
  const data = {
190
178
  answer: mockSpy
191
179
  };
192
- const wrapper = _ref6 => {
193
- let {
194
- children
195
- } = _ref6;
196
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
197
- data: data
198
- }, children);
199
- };
180
+ const wrapper = ({
181
+ children
182
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
183
+ data: data
184
+ }, children);
200
185
  const {
201
186
  result
202
187
  } = renderHook(() => useDataQuery(query), {
@@ -238,15 +223,12 @@ describe('useDataQuery', () => {
238
223
  resource: 'answer'
239
224
  }
240
225
  };
241
- const wrapper = _ref7 => {
242
- let {
243
- children
244
- } = _ref7;
245
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
246
- data: data,
247
- queryClientOptions: queryClientOptions
248
- }, children);
249
- };
226
+ const wrapper = ({
227
+ children
228
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
229
+ data: data,
230
+ queryClientOptions: queryClientOptions
231
+ }, children);
250
232
  const {
251
233
  result
252
234
  } = renderHook(() => useDataQuery(query), {
@@ -306,7 +288,7 @@ describe('useDataQuery', () => {
306
288
  });
307
289
  describe('internal: deduplication', () => {
308
290
  it('Should deduplicate identical requests', async () => {
309
- const mockSpy = jest.fn(() => 42);
291
+ const mockSpy = jest.fn(() => Promise.resolve(42));
310
292
  const data = {
311
293
  answer: mockSpy
312
294
  };
@@ -315,14 +297,11 @@ describe('useDataQuery', () => {
315
297
  resource: 'answer'
316
298
  }
317
299
  };
318
- const wrapper = _ref8 => {
319
- let {
320
- children
321
- } = _ref8;
322
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
323
- data: data
324
- }, children);
325
- };
300
+ const wrapper = ({
301
+ children
302
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
303
+ data: data
304
+ }, children);
326
305
  const {
327
306
  result
328
307
  } = renderHook(() => {
@@ -362,14 +341,11 @@ describe('useDataQuery', () => {
362
341
  const data = {
363
342
  answer: 42
364
343
  };
365
- const wrapper = _ref9 => {
366
- let {
367
- children
368
- } = _ref9;
369
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
370
- data: data
371
- }, children);
372
- };
344
+ const wrapper = ({
345
+ children
346
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
347
+ data: data
348
+ }, children);
373
349
  const {
374
350
  result
375
351
  } = renderHook(() => useDataQuery(query), {
@@ -402,14 +378,11 @@ describe('useDataQuery', () => {
402
378
  answer: 42,
403
379
  opposite: 24
404
380
  };
405
- const wrapper = _ref0 => {
406
- let {
407
- children
408
- } = _ref0;
409
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
410
- data: data
411
- }, children);
412
- };
381
+ const wrapper = ({
382
+ children
383
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
384
+ data: data
385
+ }, children);
413
386
  const {
414
387
  result
415
388
  } = renderHook(() => useDataQuery(query), {
@@ -444,14 +417,11 @@ describe('useDataQuery', () => {
444
417
  throw expectedError;
445
418
  }
446
419
  };
447
- const wrapper = _ref1 => {
448
- let {
449
- children
450
- } = _ref1;
451
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
452
- data: data
453
- }, children);
454
- };
420
+ const wrapper = ({
421
+ children
422
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
423
+ data: data
424
+ }, children);
455
425
  const {
456
426
  result
457
427
  } = renderHook(() => useDataQuery(query), {
@@ -485,14 +455,11 @@ describe('useDataQuery', () => {
485
455
  },
486
456
  opposite: 24
487
457
  };
488
- const wrapper = _ref10 => {
489
- let {
490
- children
491
- } = _ref10;
492
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
493
- data: data
494
- }, children);
495
- };
458
+ const wrapper = ({
459
+ children
460
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
461
+ data: data
462
+ }, children);
496
463
  const {
497
464
  result
498
465
  } = renderHook(() => useDataQuery(query), {
@@ -516,7 +483,7 @@ describe('useDataQuery', () => {
516
483
  let count = 0;
517
484
  const spy = jest.fn(() => {
518
485
  count++;
519
- return count;
486
+ return Promise.resolve(count);
520
487
  });
521
488
  const data = {
522
489
  answer: spy
@@ -526,14 +493,11 @@ describe('useDataQuery', () => {
526
493
  resource: 'answer'
527
494
  }
528
495
  };
529
- const wrapper = _ref11 => {
530
- let {
531
- children
532
- } = _ref11;
533
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
534
- data: data
535
- }, children);
536
- };
496
+ const wrapper = ({
497
+ children
498
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
499
+ data: data
500
+ }, children);
537
501
  const {
538
502
  result
539
503
  } = renderHook(() => useDataQuery(query, {
@@ -574,9 +538,9 @@ describe('useDataQuery', () => {
574
538
  it('Should only trigger a single request when refetch is called on a lazy query with new variables', async () => {
575
539
  const spy = jest.fn((type, query) => {
576
540
  if (query.id === '1') {
577
- return 42;
541
+ return Promise.resolve(42);
578
542
  }
579
- return 0;
543
+ return Promise.resolve(0);
580
544
  });
581
545
  const data = {
582
546
  answer: spy
@@ -584,22 +548,16 @@ describe('useDataQuery', () => {
584
548
  const query = {
585
549
  x: {
586
550
  resource: 'answer',
587
- id: _ref12 => {
588
- let {
589
- id
590
- } = _ref12;
591
- return id;
592
- }
551
+ id: ({
552
+ id
553
+ }) => id
593
554
  }
594
555
  };
595
- const wrapper = _ref13 => {
596
- let {
597
- children
598
- } = _ref13;
599
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
600
- data: data
601
- }, children);
602
- };
556
+ const wrapper = ({
557
+ children
558
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
559
+ data: data
560
+ }, children);
603
561
  const {
604
562
  result
605
563
  } = renderHook(() => useDataQuery(query, {
@@ -627,9 +585,9 @@ describe('useDataQuery', () => {
627
585
  it('Should only trigger a single request when refetch is called on a lazy query with identical variables', async () => {
628
586
  const spy = jest.fn((type, query) => {
629
587
  if (query.id === '1') {
630
- return 42;
588
+ return Promise.resolve(42);
631
589
  }
632
- return 0;
590
+ return Promise.resolve(0);
633
591
  });
634
592
  const data = {
635
593
  answer: spy
@@ -637,22 +595,16 @@ describe('useDataQuery', () => {
637
595
  const query = {
638
596
  x: {
639
597
  resource: 'answer',
640
- id: _ref14 => {
641
- let {
642
- id
643
- } = _ref14;
644
- return id;
645
- }
598
+ id: ({
599
+ id
600
+ }) => id
646
601
  }
647
602
  };
648
- const wrapper = _ref15 => {
649
- let {
650
- children
651
- } = _ref15;
652
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
653
- data: data
654
- }, children);
655
- };
603
+ const wrapper = ({
604
+ children
605
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
606
+ data: data
607
+ }, children);
656
608
  const {
657
609
  result
658
610
  } = renderHook(() => useDataQuery(query, {
@@ -682,21 +634,18 @@ describe('useDataQuery', () => {
682
634
  });
683
635
  it('Should have a stable identity if the variables have not changed', async () => {
684
636
  const data = {
685
- answer: () => 42
637
+ answer: () => Promise.resolve(42)
686
638
  };
687
639
  const query = {
688
640
  x: {
689
641
  resource: 'answer'
690
642
  }
691
643
  };
692
- const wrapper = _ref16 => {
693
- let {
694
- children
695
- } = _ref16;
696
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
697
- data: data
698
- }, children);
699
- };
644
+ const wrapper = ({
645
+ children
646
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
647
+ data: data
648
+ }, children);
700
649
  const {
701
650
  result,
702
651
  rerender
@@ -732,14 +681,11 @@ describe('useDataQuery', () => {
732
681
  resource: 'answer'
733
682
  }
734
683
  };
735
- const wrapper = _ref17 => {
736
- let {
737
- children
738
- } = _ref17;
739
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
740
- data: data
741
- }, children);
742
- };
684
+ const wrapper = ({
685
+ children
686
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
687
+ data: data
688
+ }, children);
743
689
  const {
744
690
  result,
745
691
  rerender
@@ -801,14 +747,11 @@ describe('useDataQuery', () => {
801
747
  const data = {
802
748
  answer: mockSpy
803
749
  };
804
- const wrapper = _ref18 => {
805
- let {
806
- children
807
- } = _ref18;
808
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
809
- data: data
810
- }, children);
811
- };
750
+ const wrapper = ({
751
+ children
752
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
753
+ data: data
754
+ }, children);
812
755
  const {
813
756
  result
814
757
  } = renderHook(() => useDataQuery(query, {
@@ -848,14 +791,11 @@ describe('useDataQuery', () => {
848
791
  const data = {
849
792
  answer: 42
850
793
  };
851
- const wrapper = _ref19 => {
852
- let {
853
- children
854
- } = _ref19;
855
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
856
- data: data
857
- }, children);
858
- };
794
+ const wrapper = ({
795
+ children
796
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
797
+ data: data
798
+ }, children);
859
799
  const onComplete = jest.fn();
860
800
  const onError = jest.fn();
861
801
  const {
@@ -896,14 +836,11 @@ describe('useDataQuery', () => {
896
836
  throw expectedError;
897
837
  }
898
838
  };
899
- const wrapper = _ref20 => {
900
- let {
901
- children
902
- } = _ref20;
903
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
904
- data: data
905
- }, children);
906
- };
839
+ const wrapper = ({
840
+ children
841
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
842
+ data: data
843
+ }, children);
907
844
  const onComplete = jest.fn();
908
845
  const onError = jest.fn();
909
846
  const {
@@ -935,32 +872,26 @@ describe('useDataQuery', () => {
935
872
  const query = {
936
873
  x: {
937
874
  resource: 'answer',
938
- params: _ref21 => {
939
- let {
940
- one,
941
- two,
942
- three
943
- } = _ref21;
944
- return {
945
- one,
946
- two,
947
- three
948
- };
949
- }
875
+ params: ({
876
+ one,
877
+ two,
878
+ three
879
+ }) => ({
880
+ one,
881
+ two,
882
+ three
883
+ })
950
884
  }
951
885
  };
952
- const spy = jest.fn(() => 42);
886
+ const spy = jest.fn(() => Promise.resolve(42));
953
887
  const data = {
954
888
  answer: spy
955
889
  };
956
- const wrapper = _ref22 => {
957
- let {
958
- children
959
- } = _ref22;
960
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
961
- data: data
962
- }, children);
963
- };
890
+ const wrapper = ({
891
+ children
892
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
893
+ data: data
894
+ }, children);
964
895
  const {
965
896
  result
966
897
  } = renderHook(() => useDataQuery(query, {
@@ -1001,14 +932,11 @@ describe('useDataQuery', () => {
1001
932
  const data = {
1002
933
  answer: 42
1003
934
  };
1004
- const wrapper = _ref23 => {
1005
- let {
1006
- children
1007
- } = _ref23;
1008
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1009
- data: data
1010
- }, children);
1011
- };
935
+ const wrapper = ({
936
+ children
937
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
938
+ data: data
939
+ }, children);
1012
940
  const {
1013
941
  result
1014
942
  } = renderHook(() => useDataQuery(query, {
@@ -1043,14 +971,11 @@ describe('useDataQuery', () => {
1043
971
  const data = {
1044
972
  answer: 42
1045
973
  };
1046
- const wrapper = _ref24 => {
1047
- let {
1048
- children
1049
- } = _ref24;
1050
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1051
- data: data
1052
- }, children);
1053
- };
974
+ const wrapper = ({
975
+ children
976
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
977
+ data: data
978
+ }, children);
1054
979
  const {
1055
980
  result
1056
981
  } = renderHook(() => useDataQuery(query, {
@@ -1088,14 +1013,11 @@ describe('useDataQuery', () => {
1088
1013
  throw expectedError;
1089
1014
  }
1090
1015
  };
1091
- const wrapper = _ref25 => {
1092
- let {
1093
- children
1094
- } = _ref25;
1095
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1096
- data: data
1097
- }, children);
1098
- };
1016
+ const wrapper = ({
1017
+ children
1018
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
1019
+ data: data
1020
+ }, children);
1099
1021
  const {
1100
1022
  result
1101
1023
  } = renderHook(() => useDataQuery(query, {
@@ -1127,14 +1049,11 @@ describe('useDataQuery', () => {
1127
1049
  throw expectedError;
1128
1050
  }
1129
1051
  };
1130
- const wrapper = _ref26 => {
1131
- let {
1132
- children
1133
- } = _ref26;
1134
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1135
- data: data
1136
- }, children);
1137
- };
1052
+ const wrapper = ({
1053
+ children
1054
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
1055
+ data: data
1056
+ }, children);
1138
1057
  const {
1139
1058
  result
1140
1059
  } = renderHook(() => useDataQuery(query, {
@@ -1162,36 +1081,30 @@ describe('useDataQuery', () => {
1162
1081
  const query = {
1163
1082
  x: {
1164
1083
  resource: 'answer',
1165
- id: _ref27 => {
1166
- let {
1167
- id
1168
- } = _ref27;
1169
- return id;
1170
- }
1084
+ id: ({
1085
+ id
1086
+ }) => id
1171
1087
  }
1172
1088
  };
1173
- const mockSpy = jest.fn((_, _ref28) => {
1174
- let {
1175
- id
1176
- } = _ref28;
1089
+ const mockSpy = jest.fn((_, {
1090
+ id
1091
+ }) => {
1177
1092
  switch (id) {
1178
1093
  case one:
1179
1094
  return Promise.resolve(resultOne);
1180
1095
  case two:
1181
1096
  return Promise.resolve(resultTwo);
1182
1097
  }
1098
+ return Promise.resolve(undefined);
1183
1099
  });
1184
1100
  const data = {
1185
1101
  answer: mockSpy
1186
1102
  };
1187
- const wrapper = _ref29 => {
1188
- let {
1189
- children
1190
- } = _ref29;
1191
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1192
- data: data
1193
- }, children);
1194
- };
1103
+ const wrapper = ({
1104
+ children
1105
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
1106
+ data: data
1107
+ }, children);
1195
1108
  const initialProps = {
1196
1109
  query,
1197
1110
  options: {
@@ -1240,32 +1153,26 @@ describe('useDataQuery', () => {
1240
1153
  const query = {
1241
1154
  x: {
1242
1155
  resource: 'answer',
1243
- params: _ref30 => {
1244
- let {
1245
- one,
1246
- two,
1247
- three
1248
- } = _ref30;
1249
- return {
1250
- one,
1251
- two,
1252
- three
1253
- };
1254
- }
1156
+ params: ({
1157
+ one,
1158
+ two,
1159
+ three
1160
+ }) => ({
1161
+ one,
1162
+ two,
1163
+ three
1164
+ })
1255
1165
  }
1256
1166
  };
1257
1167
  const mockSpy = jest.fn(() => Promise.resolve(42));
1258
1168
  const data = {
1259
1169
  answer: mockSpy
1260
1170
  };
1261
- const wrapper = _ref31 => {
1262
- let {
1263
- children
1264
- } = _ref31;
1265
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
1266
- data: data
1267
- }, children);
1268
- };
1171
+ const wrapper = ({
1172
+ children
1173
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
1174
+ data: data
1175
+ }, children);
1269
1176
  const {
1270
1177
  result
1271
1178
  } = renderHook(() => useDataQuery(query, {