@dhis2/app-service-data 3.7.0 → 3.9.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.
- package/build/cjs/__tests__/integration.test.js +16 -10
- package/build/cjs/__tests__/mutations.test.js +8 -5
- package/build/cjs/engine/DataEngine.js +14 -12
- package/build/cjs/engine/helpers/resolveDynamicQuery.js +14 -11
- package/build/cjs/engine/helpers/resolveDynamicQuery.test.js +23 -14
- package/build/cjs/engine/helpers/validate.js +6 -4
- package/build/cjs/engine/helpers/validate.test.js +74 -15
- package/build/cjs/engine/types/FetchError.js +6 -5
- package/build/cjs/engine/types/InvalidQueryError.js +1 -1
- package/build/cjs/index.js +10 -10
- package/build/cjs/links/CustomDataLink.js +8 -6
- package/build/cjs/links/CustomDataLink.test.js +2 -2
- package/build/cjs/links/RestAPILink/fetchData.js +3 -2
- package/build/cjs/links/RestAPILink/fetchData.test.js +1 -1
- package/build/cjs/links/RestAPILink/metadataResources.js +1 -1
- package/build/cjs/links/RestAPILink/path.js +5 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +29 -16
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.js +9 -6
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +2 -2
- package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +51 -33
- package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +6 -3
- package/build/cjs/links/RestAPILink/queryToRequestOptions.js +1 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions.test.js +56 -6
- package/build/cjs/links/RestAPILink/queryToResourcePath.js +14 -6
- package/build/cjs/links/RestAPILink/queryToResourcePath.test.js +16 -16
- package/build/cjs/links/RestAPILink/validateQuery.test.js +12 -12
- package/build/cjs/links/RestAPILink.js +4 -3
- package/build/cjs/react/components/CustomDataProvider.js +7 -6
- package/build/cjs/react/components/DataMutation.js +8 -7
- package/build/cjs/react/components/DataProvider.js +1 -1
- package/build/cjs/react/components/DataQuery.js +9 -8
- package/build/cjs/react/context/defaultContext.test.js +10 -2
- package/build/cjs/react/hooks/stableVariablesHash.js +1 -2
- package/build/cjs/react/hooks/stableVariablesHash.test.js +6 -6
- package/build/cjs/react/hooks/useDataMutation.js +7 -6
- package/build/cjs/react/hooks/useDataMutation.test.js +70 -43
- package/build/cjs/react/hooks/useDataQuery.js +13 -9
- package/build/cjs/react/hooks/useDataQuery.test.js +259 -162
- package/build/cjs/react/hooks/useQueryExecutor.js +11 -9
- package/build/cjs/react/hooks/useQueryExecutor.test.js +16 -12
- package/build/cjs/react/hooks/useStaticInput.js +7 -6
- package/build/cjs/react/hooks/useStaticInput.test.js +44 -25
- package/build/cjs/react/index.js +6 -6
- package/build/es/__tests__/integration.test.js +16 -10
- package/build/es/__tests__/mutations.test.js +8 -5
- package/build/es/engine/DataEngine.js +14 -12
- package/build/es/engine/helpers/resolveDynamicQuery.js +14 -11
- package/build/es/engine/helpers/resolveDynamicQuery.test.js +23 -14
- package/build/es/engine/helpers/validate.js +6 -4
- package/build/es/engine/helpers/validate.test.js +74 -15
- package/build/es/engine/types/FetchError.js +6 -5
- package/build/es/engine/types/InvalidQueryError.js +1 -1
- package/build/es/links/CustomDataLink.js +8 -6
- package/build/es/links/CustomDataLink.test.js +2 -2
- package/build/es/links/RestAPILink/fetchData.js +3 -2
- package/build/es/links/RestAPILink/fetchData.test.js +1 -1
- package/build/es/links/RestAPILink/path.js +5 -1
- package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +28 -15
- package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.js +8 -5
- package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +2 -2
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +50 -32
- package/build/es/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +6 -3
- package/build/es/links/RestAPILink/queryToRequestOptions.js +1 -1
- package/build/es/links/RestAPILink/queryToRequestOptions.test.js +56 -6
- package/build/es/links/RestAPILink/queryToResourcePath.js +14 -6
- package/build/es/links/RestAPILink/queryToResourcePath.test.js +16 -16
- package/build/es/links/RestAPILink/validateQuery.test.js +12 -12
- package/build/es/links/RestAPILink.js +4 -3
- package/build/es/react/components/CustomDataProvider.js +7 -6
- package/build/es/react/components/DataMutation.js +8 -7
- package/build/es/react/components/DataQuery.js +9 -8
- package/build/es/react/context/defaultContext.test.js +10 -2
- package/build/es/react/hooks/stableVariablesHash.js +1 -2
- package/build/es/react/hooks/stableVariablesHash.test.js +6 -6
- package/build/es/react/hooks/useDataMutation.js +7 -6
- package/build/es/react/hooks/useDataMutation.test.js +70 -43
- package/build/es/react/hooks/useDataQuery.js +13 -9
- package/build/es/react/hooks/useDataQuery.test.js +259 -162
- package/build/es/react/hooks/useQueryExecutor.js +11 -9
- package/build/es/react/hooks/useQueryExecutor.test.js +16 -12
- package/build/es/react/hooks/useStaticInput.js +7 -6
- package/build/es/react/hooks/useStaticInput.test.js +44 -25
- package/package.json +2 -2
|
@@ -24,11 +24,14 @@ describe('useDataQuery', () => {
|
|
|
24
24
|
answer: 42
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const wrapper = ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const wrapper = (_ref) => {
|
|
28
|
+
let {
|
|
29
|
+
children
|
|
30
|
+
} = _ref;
|
|
31
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
32
|
+
data: data
|
|
33
|
+
}, children);
|
|
34
|
+
};
|
|
32
35
|
|
|
33
36
|
const onComplete = jest.fn();
|
|
34
37
|
const onError = jest.fn();
|
|
@@ -72,11 +75,14 @@ describe('useDataQuery', () => {
|
|
|
72
75
|
}
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
const wrapper = ({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
const wrapper = (_ref2) => {
|
|
79
|
+
let {
|
|
80
|
+
children
|
|
81
|
+
} = _ref2;
|
|
82
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
83
|
+
data: data
|
|
84
|
+
}, children);
|
|
85
|
+
};
|
|
80
86
|
|
|
81
87
|
const onComplete = jest.fn();
|
|
82
88
|
const onError = jest.fn();
|
|
@@ -110,14 +116,19 @@ describe('useDataQuery', () => {
|
|
|
110
116
|
const query = {
|
|
111
117
|
x: {
|
|
112
118
|
resource: 'answer',
|
|
113
|
-
id: ({
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
id: (_ref3) => {
|
|
120
|
+
let {
|
|
121
|
+
id
|
|
122
|
+
} = _ref3;
|
|
123
|
+
return id;
|
|
124
|
+
}
|
|
116
125
|
}
|
|
117
126
|
};
|
|
118
|
-
const mockSpy = jest.fn((_, {
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
const mockSpy = jest.fn((_, _ref4) => {
|
|
128
|
+
let {
|
|
129
|
+
id
|
|
130
|
+
} = _ref4;
|
|
131
|
+
|
|
121
132
|
switch (id) {
|
|
122
133
|
case one:
|
|
123
134
|
return Promise.resolve(resultOne);
|
|
@@ -130,11 +141,14 @@ describe('useDataQuery', () => {
|
|
|
130
141
|
answer: mockSpy
|
|
131
142
|
};
|
|
132
143
|
|
|
133
|
-
const wrapper = ({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
const wrapper = (_ref5) => {
|
|
145
|
+
let {
|
|
146
|
+
children
|
|
147
|
+
} = _ref5;
|
|
148
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
149
|
+
data: data
|
|
150
|
+
}, children);
|
|
151
|
+
};
|
|
138
152
|
|
|
139
153
|
const initialProps = {
|
|
140
154
|
query,
|
|
@@ -194,11 +208,14 @@ describe('useDataQuery', () => {
|
|
|
194
208
|
answer: mockSpy
|
|
195
209
|
};
|
|
196
210
|
|
|
197
|
-
const wrapper = ({
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
const wrapper = (_ref6) => {
|
|
212
|
+
let {
|
|
213
|
+
children
|
|
214
|
+
} = _ref6;
|
|
215
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
216
|
+
data: data
|
|
217
|
+
}, children);
|
|
218
|
+
};
|
|
202
219
|
|
|
203
220
|
const {
|
|
204
221
|
result,
|
|
@@ -242,12 +259,15 @@ describe('useDataQuery', () => {
|
|
|
242
259
|
}
|
|
243
260
|
};
|
|
244
261
|
|
|
245
|
-
const wrapper = ({
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
262
|
+
const wrapper = (_ref7) => {
|
|
263
|
+
let {
|
|
264
|
+
children
|
|
265
|
+
} = _ref7;
|
|
266
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
267
|
+
data: data,
|
|
268
|
+
queryClientOptions: queryClientOptions
|
|
269
|
+
}, children);
|
|
270
|
+
};
|
|
251
271
|
|
|
252
272
|
const {
|
|
253
273
|
result,
|
|
@@ -316,11 +336,14 @@ describe('useDataQuery', () => {
|
|
|
316
336
|
}
|
|
317
337
|
};
|
|
318
338
|
|
|
319
|
-
const wrapper = ({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
339
|
+
const wrapper = (_ref8) => {
|
|
340
|
+
let {
|
|
341
|
+
children
|
|
342
|
+
} = _ref8;
|
|
343
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
344
|
+
data: data
|
|
345
|
+
}, children);
|
|
346
|
+
};
|
|
324
347
|
|
|
325
348
|
const {
|
|
326
349
|
result,
|
|
@@ -362,11 +385,14 @@ describe('useDataQuery', () => {
|
|
|
362
385
|
answer: 42
|
|
363
386
|
};
|
|
364
387
|
|
|
365
|
-
const wrapper = ({
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
388
|
+
const wrapper = (_ref9) => {
|
|
389
|
+
let {
|
|
390
|
+
children
|
|
391
|
+
} = _ref9;
|
|
392
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
393
|
+
data: data
|
|
394
|
+
}, children);
|
|
395
|
+
};
|
|
370
396
|
|
|
371
397
|
const {
|
|
372
398
|
result,
|
|
@@ -401,11 +427,14 @@ describe('useDataQuery', () => {
|
|
|
401
427
|
opposite: 24
|
|
402
428
|
};
|
|
403
429
|
|
|
404
|
-
const wrapper = ({
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
430
|
+
const wrapper = (_ref10) => {
|
|
431
|
+
let {
|
|
432
|
+
children
|
|
433
|
+
} = _ref10;
|
|
434
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
435
|
+
data: data
|
|
436
|
+
}, children);
|
|
437
|
+
};
|
|
409
438
|
|
|
410
439
|
const {
|
|
411
440
|
result,
|
|
@@ -442,11 +471,14 @@ describe('useDataQuery', () => {
|
|
|
442
471
|
}
|
|
443
472
|
};
|
|
444
473
|
|
|
445
|
-
const wrapper = ({
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
474
|
+
const wrapper = (_ref11) => {
|
|
475
|
+
let {
|
|
476
|
+
children
|
|
477
|
+
} = _ref11;
|
|
478
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
479
|
+
data: data
|
|
480
|
+
}, children);
|
|
481
|
+
};
|
|
450
482
|
|
|
451
483
|
const {
|
|
452
484
|
result,
|
|
@@ -482,11 +514,14 @@ describe('useDataQuery', () => {
|
|
|
482
514
|
opposite: 24
|
|
483
515
|
};
|
|
484
516
|
|
|
485
|
-
const wrapper = ({
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
517
|
+
const wrapper = (_ref12) => {
|
|
518
|
+
let {
|
|
519
|
+
children
|
|
520
|
+
} = _ref12;
|
|
521
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
522
|
+
data: data
|
|
523
|
+
}, children);
|
|
524
|
+
};
|
|
490
525
|
|
|
491
526
|
const {
|
|
492
527
|
result,
|
|
@@ -522,11 +557,14 @@ describe('useDataQuery', () => {
|
|
|
522
557
|
}
|
|
523
558
|
};
|
|
524
559
|
|
|
525
|
-
const wrapper = ({
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
560
|
+
const wrapper = (_ref13) => {
|
|
561
|
+
let {
|
|
562
|
+
children
|
|
563
|
+
} = _ref13;
|
|
564
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
565
|
+
data: data
|
|
566
|
+
}, children);
|
|
567
|
+
};
|
|
530
568
|
|
|
531
569
|
const {
|
|
532
570
|
result,
|
|
@@ -580,17 +618,23 @@ describe('useDataQuery', () => {
|
|
|
580
618
|
const query = {
|
|
581
619
|
x: {
|
|
582
620
|
resource: 'answer',
|
|
583
|
-
id: ({
|
|
584
|
-
|
|
585
|
-
|
|
621
|
+
id: (_ref14) => {
|
|
622
|
+
let {
|
|
623
|
+
id
|
|
624
|
+
} = _ref14;
|
|
625
|
+
return id;
|
|
626
|
+
}
|
|
586
627
|
}
|
|
587
628
|
};
|
|
588
629
|
|
|
589
|
-
const wrapper = ({
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
630
|
+
const wrapper = (_ref15) => {
|
|
631
|
+
let {
|
|
632
|
+
children
|
|
633
|
+
} = _ref15;
|
|
634
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
635
|
+
data: data
|
|
636
|
+
}, children);
|
|
637
|
+
};
|
|
594
638
|
|
|
595
639
|
const {
|
|
596
640
|
result,
|
|
@@ -631,17 +675,23 @@ describe('useDataQuery', () => {
|
|
|
631
675
|
const query = {
|
|
632
676
|
x: {
|
|
633
677
|
resource: 'answer',
|
|
634
|
-
id: ({
|
|
635
|
-
|
|
636
|
-
|
|
678
|
+
id: (_ref16) => {
|
|
679
|
+
let {
|
|
680
|
+
id
|
|
681
|
+
} = _ref16;
|
|
682
|
+
return id;
|
|
683
|
+
}
|
|
637
684
|
}
|
|
638
685
|
};
|
|
639
686
|
|
|
640
|
-
const wrapper = ({
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
687
|
+
const wrapper = (_ref17) => {
|
|
688
|
+
let {
|
|
689
|
+
children
|
|
690
|
+
} = _ref17;
|
|
691
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
692
|
+
data: data
|
|
693
|
+
}, children);
|
|
694
|
+
};
|
|
645
695
|
|
|
646
696
|
const {
|
|
647
697
|
result,
|
|
@@ -681,11 +731,14 @@ describe('useDataQuery', () => {
|
|
|
681
731
|
}
|
|
682
732
|
};
|
|
683
733
|
|
|
684
|
-
const wrapper = ({
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
734
|
+
const wrapper = (_ref18) => {
|
|
735
|
+
let {
|
|
736
|
+
children
|
|
737
|
+
} = _ref18;
|
|
738
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
739
|
+
data: data
|
|
740
|
+
}, children);
|
|
741
|
+
};
|
|
689
742
|
|
|
690
743
|
const {
|
|
691
744
|
result,
|
|
@@ -721,11 +774,14 @@ describe('useDataQuery', () => {
|
|
|
721
774
|
}
|
|
722
775
|
};
|
|
723
776
|
|
|
724
|
-
const wrapper = ({
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
777
|
+
const wrapper = (_ref19) => {
|
|
778
|
+
let {
|
|
779
|
+
children
|
|
780
|
+
} = _ref19;
|
|
781
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
782
|
+
data: data
|
|
783
|
+
}, children);
|
|
784
|
+
};
|
|
729
785
|
|
|
730
786
|
const {
|
|
731
787
|
result,
|
|
@@ -788,11 +844,14 @@ describe('useDataQuery', () => {
|
|
|
788
844
|
answer: mockSpy
|
|
789
845
|
};
|
|
790
846
|
|
|
791
|
-
const wrapper = ({
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
847
|
+
const wrapper = (_ref20) => {
|
|
848
|
+
let {
|
|
849
|
+
children
|
|
850
|
+
} = _ref20;
|
|
851
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
852
|
+
data: data
|
|
853
|
+
}, children);
|
|
854
|
+
};
|
|
796
855
|
|
|
797
856
|
const {
|
|
798
857
|
result,
|
|
@@ -834,11 +893,14 @@ describe('useDataQuery', () => {
|
|
|
834
893
|
answer: 42
|
|
835
894
|
};
|
|
836
895
|
|
|
837
|
-
const wrapper = ({
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
896
|
+
const wrapper = (_ref21) => {
|
|
897
|
+
let {
|
|
898
|
+
children
|
|
899
|
+
} = _ref21;
|
|
900
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
901
|
+
data: data
|
|
902
|
+
}, children);
|
|
903
|
+
};
|
|
842
904
|
|
|
843
905
|
const onComplete = jest.fn();
|
|
844
906
|
const onError = jest.fn();
|
|
@@ -881,11 +943,14 @@ describe('useDataQuery', () => {
|
|
|
881
943
|
}
|
|
882
944
|
};
|
|
883
945
|
|
|
884
|
-
const wrapper = ({
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
946
|
+
const wrapper = (_ref22) => {
|
|
947
|
+
let {
|
|
948
|
+
children
|
|
949
|
+
} = _ref22;
|
|
950
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
951
|
+
data: data
|
|
952
|
+
}, children);
|
|
953
|
+
};
|
|
889
954
|
|
|
890
955
|
const onComplete = jest.fn();
|
|
891
956
|
const onError = jest.fn();
|
|
@@ -918,15 +983,18 @@ describe('useDataQuery', () => {
|
|
|
918
983
|
const query = {
|
|
919
984
|
x: {
|
|
920
985
|
resource: 'answer',
|
|
921
|
-
params: ({
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
986
|
+
params: (_ref23) => {
|
|
987
|
+
let {
|
|
988
|
+
one,
|
|
989
|
+
two,
|
|
990
|
+
three
|
|
991
|
+
} = _ref23;
|
|
992
|
+
return {
|
|
993
|
+
one,
|
|
994
|
+
two,
|
|
995
|
+
three
|
|
996
|
+
};
|
|
997
|
+
}
|
|
930
998
|
}
|
|
931
999
|
};
|
|
932
1000
|
const spy = jest.fn(() => 42);
|
|
@@ -934,11 +1002,14 @@ describe('useDataQuery', () => {
|
|
|
934
1002
|
answer: spy
|
|
935
1003
|
};
|
|
936
1004
|
|
|
937
|
-
const wrapper = ({
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1005
|
+
const wrapper = (_ref24) => {
|
|
1006
|
+
let {
|
|
1007
|
+
children
|
|
1008
|
+
} = _ref24;
|
|
1009
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1010
|
+
data: data
|
|
1011
|
+
}, children);
|
|
1012
|
+
};
|
|
942
1013
|
|
|
943
1014
|
const {
|
|
944
1015
|
result,
|
|
@@ -980,11 +1051,14 @@ describe('useDataQuery', () => {
|
|
|
980
1051
|
answer: 42
|
|
981
1052
|
};
|
|
982
1053
|
|
|
983
|
-
const wrapper = ({
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1054
|
+
const wrapper = (_ref25) => {
|
|
1055
|
+
let {
|
|
1056
|
+
children
|
|
1057
|
+
} = _ref25;
|
|
1058
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1059
|
+
data: data
|
|
1060
|
+
}, children);
|
|
1061
|
+
};
|
|
988
1062
|
|
|
989
1063
|
const {
|
|
990
1064
|
result,
|
|
@@ -1021,11 +1095,14 @@ describe('useDataQuery', () => {
|
|
|
1021
1095
|
answer: 42
|
|
1022
1096
|
};
|
|
1023
1097
|
|
|
1024
|
-
const wrapper = ({
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1098
|
+
const wrapper = (_ref26) => {
|
|
1099
|
+
let {
|
|
1100
|
+
children
|
|
1101
|
+
} = _ref26;
|
|
1102
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1103
|
+
data: data
|
|
1104
|
+
}, children);
|
|
1105
|
+
};
|
|
1029
1106
|
|
|
1030
1107
|
const {
|
|
1031
1108
|
result,
|
|
@@ -1065,11 +1142,14 @@ describe('useDataQuery', () => {
|
|
|
1065
1142
|
}
|
|
1066
1143
|
};
|
|
1067
1144
|
|
|
1068
|
-
const wrapper = ({
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1145
|
+
const wrapper = (_ref27) => {
|
|
1146
|
+
let {
|
|
1147
|
+
children
|
|
1148
|
+
} = _ref27;
|
|
1149
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1150
|
+
data: data
|
|
1151
|
+
}, children);
|
|
1152
|
+
};
|
|
1073
1153
|
|
|
1074
1154
|
const {
|
|
1075
1155
|
result,
|
|
@@ -1103,11 +1183,14 @@ describe('useDataQuery', () => {
|
|
|
1103
1183
|
}
|
|
1104
1184
|
};
|
|
1105
1185
|
|
|
1106
|
-
const wrapper = ({
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1186
|
+
const wrapper = (_ref28) => {
|
|
1187
|
+
let {
|
|
1188
|
+
children
|
|
1189
|
+
} = _ref28;
|
|
1190
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1191
|
+
data: data
|
|
1192
|
+
}, children);
|
|
1193
|
+
};
|
|
1111
1194
|
|
|
1112
1195
|
const {
|
|
1113
1196
|
result,
|
|
@@ -1136,14 +1219,19 @@ describe('useDataQuery', () => {
|
|
|
1136
1219
|
const query = {
|
|
1137
1220
|
x: {
|
|
1138
1221
|
resource: 'answer',
|
|
1139
|
-
id: ({
|
|
1140
|
-
|
|
1141
|
-
|
|
1222
|
+
id: (_ref29) => {
|
|
1223
|
+
let {
|
|
1224
|
+
id
|
|
1225
|
+
} = _ref29;
|
|
1226
|
+
return id;
|
|
1227
|
+
}
|
|
1142
1228
|
}
|
|
1143
1229
|
};
|
|
1144
|
-
const mockSpy = jest.fn((_, {
|
|
1145
|
-
|
|
1146
|
-
|
|
1230
|
+
const mockSpy = jest.fn((_, _ref30) => {
|
|
1231
|
+
let {
|
|
1232
|
+
id
|
|
1233
|
+
} = _ref30;
|
|
1234
|
+
|
|
1147
1235
|
switch (id) {
|
|
1148
1236
|
case one:
|
|
1149
1237
|
return Promise.resolve(resultOne);
|
|
@@ -1156,11 +1244,14 @@ describe('useDataQuery', () => {
|
|
|
1156
1244
|
answer: mockSpy
|
|
1157
1245
|
};
|
|
1158
1246
|
|
|
1159
|
-
const wrapper = ({
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1247
|
+
const wrapper = (_ref31) => {
|
|
1248
|
+
let {
|
|
1249
|
+
children
|
|
1250
|
+
} = _ref31;
|
|
1251
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1252
|
+
data: data
|
|
1253
|
+
}, children);
|
|
1254
|
+
};
|
|
1164
1255
|
|
|
1165
1256
|
const initialProps = {
|
|
1166
1257
|
query,
|
|
@@ -1209,15 +1300,18 @@ describe('useDataQuery', () => {
|
|
|
1209
1300
|
const query = {
|
|
1210
1301
|
x: {
|
|
1211
1302
|
resource: 'answer',
|
|
1212
|
-
params: ({
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1303
|
+
params: (_ref32) => {
|
|
1304
|
+
let {
|
|
1305
|
+
one,
|
|
1306
|
+
two,
|
|
1307
|
+
three
|
|
1308
|
+
} = _ref32;
|
|
1309
|
+
return {
|
|
1310
|
+
one,
|
|
1311
|
+
two,
|
|
1312
|
+
three
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1221
1315
|
}
|
|
1222
1316
|
};
|
|
1223
1317
|
const mockSpy = jest.fn(() => Promise.resolve(42));
|
|
@@ -1225,11 +1319,14 @@ describe('useDataQuery', () => {
|
|
|
1225
1319
|
answer: mockSpy
|
|
1226
1320
|
};
|
|
1227
1321
|
|
|
1228
|
-
const wrapper = ({
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1322
|
+
const wrapper = (_ref33) => {
|
|
1323
|
+
let {
|
|
1324
|
+
children
|
|
1325
|
+
} = _ref33;
|
|
1326
|
+
return /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
|
|
1327
|
+
data: data
|
|
1328
|
+
}, children);
|
|
1329
|
+
};
|
|
1233
1330
|
|
|
1234
1331
|
const {
|
|
1235
1332
|
result,
|
|
@@ -11,14 +11,15 @@ var _engine = require("../../engine");
|
|
|
11
11
|
|
|
12
12
|
var _useStaticInput = require("./useStaticInput");
|
|
13
13
|
|
|
14
|
-
const useQueryExecutor = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const useQueryExecutor = (_ref) => {
|
|
15
|
+
let {
|
|
16
|
+
execute,
|
|
17
|
+
variables: initialVariables,
|
|
18
|
+
singular,
|
|
19
|
+
immediate,
|
|
20
|
+
onComplete,
|
|
21
|
+
onError
|
|
22
|
+
} = _ref;
|
|
22
23
|
const [theExecute] = (0, _useStaticInput.useStaticInput)(execute);
|
|
23
24
|
const [state, setState] = (0, _react.useState)({
|
|
24
25
|
called: !!immediate,
|
|
@@ -41,7 +42,8 @@ const useQueryExecutor = ({
|
|
|
41
42
|
})
|
|
42
43
|
}));
|
|
43
44
|
}, [abort]);
|
|
44
|
-
const refetch = (0, _react.useCallback)((
|
|
45
|
+
const refetch = (0, _react.useCallback)(function () {
|
|
46
|
+
let newVariables = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
45
47
|
setState(state => !state.called || !state.loading ? {
|
|
46
48
|
called: true,
|
|
47
49
|
loading: true
|