@@ -4,7 +4,7 @@ import { diff } from "@n1ru4l/json-patch-plus";
4
4
import { CombinedError } from "@urql/core" ;
5
5
import nock from "nock" ;
6
6
import { BackgroundActionHandle } from "../src/BackgroundActionHandle.js" ;
7
- import type { AnyModelManager , GadgetErrorGroup , LimitToKnownKeys } from "../src/index.js" ;
7
+ import type { AnyPublicModelManager , GadgetErrorGroup , LimitToKnownKeys } from "../src/index.js" ;
8
8
import {
9
9
GadgetConnection ,
10
10
actionRunner ,
@@ -30,7 +30,7 @@ describe("type checks", () => {
30
30
options ?: LimitToKnownKeys < Options , CreatePostOptions >
31
31
) : Promise < CreatePostResult < Options > > {
32
32
return await actionRunner < SelectedPostOrDefault < Options > > (
33
- this ,
33
+ this , // This is a problem...
34
34
"createPost" ,
35
35
DefaultPostSelection ,
36
36
"post" ,
@@ -48,6 +48,7 @@ describe("type checks", () => {
48
48
// eslint-disable-next-line jest/no-export
49
49
describe ( "operationRunners" , ( ) => {
50
50
let connection : GadgetConnection ;
51
+ let manager : AnyPublicModelManager ;
51
52
let query : string | undefined ;
52
53
let mockUrqlClient : MockUrqlClient ;
53
54
@@ -60,6 +61,7 @@ describe("operationRunners", () => {
60
61
} ,
61
62
} ) ;
62
63
jest . spyOn ( connection , "currentClient" as any , "get" ) . mockReturnValue ( mockUrqlClient as any ) ;
64
+ manager = { connection } as AnyPublicModelManager ;
63
65
} ) ;
64
66
65
67
describe ( "findOneRunner" , ( ) => {
@@ -74,7 +76,7 @@ describe("operationRunners", () => {
74
76
__typename
75
77
}
76
78
gadgetMeta {
77
- hydrations(modelName:
79
+ hydrations(modelName:
78
80
"widget")
79
81
}
80
82
}"
@@ -114,7 +116,7 @@ describe("operationRunners", () => {
114
116
}
115
117
}
116
118
gadgetMeta {
117
- hydrations(modelName:
119
+ hydrations(modelName:
118
120
"outer.inner.widget")
119
121
}
120
122
}"
@@ -170,7 +172,7 @@ describe("operationRunners", () => {
170
172
}
171
173
}
172
174
gadgetMeta {
173
- hydrations(modelName:
175
+ hydrations(modelName:
174
176
"widget")
175
177
}
176
178
}"
@@ -240,7 +242,7 @@ describe("operationRunners", () => {
240
242
}
241
243
}
242
244
gadgetMeta {
243
- hydrations(modelName:
245
+ hydrations(modelName:
244
246
"outer.inner.widget")
245
247
}
246
248
}"
@@ -316,7 +318,7 @@ describe("operationRunners", () => {
316
318
317
319
describe ( "findManyRunner" , ( ) => {
318
320
test ( "can execute a findMany operation against a model" , async ( ) => {
319
- const promise = findManyRunner ( { connection } as AnyModelManager , "widgets" , { id : true , name : true } , "widget" ) ;
321
+ const promise = findManyRunner ( { connection } as AnyPublicModelManager , "widgets" , { id : true , name : true } , "widget" ) ;
320
322
321
323
expect ( query ) . toMatchInlineSnapshot ( `
322
324
"query widgets($after: String, $first: Int, $before: String, $last: Int) {
@@ -337,7 +339,7 @@ describe("operationRunners", () => {
337
339
}
338
340
}
339
341
gadgetMeta {
340
- hydrations(modelName:
342
+ hydrations(modelName:
341
343
"widget")
342
344
}
343
345
}"
@@ -369,7 +371,7 @@ describe("operationRunners", () => {
369
371
370
372
test ( "can execute a findMany operation against a namespaced model" , async ( ) => {
371
373
const promise = findManyRunner (
372
- { connection } as AnyModelManager ,
374
+ { connection } as AnyPublicModelManager ,
373
375
"widgets" ,
374
376
{ id : true , name : true } ,
375
377
"widget" ,
@@ -400,7 +402,7 @@ describe("operationRunners", () => {
400
402
}
401
403
}
402
404
gadgetMeta {
403
- hydrations(modelName:
405
+ hydrations(modelName:
404
406
"outer.inner.widget")
405
407
}
406
408
}"
@@ -436,7 +438,7 @@ describe("operationRunners", () => {
436
438
437
439
test ( "can execute a findMany operation against a namespaced model when the namespace is a string" , async ( ) => {
438
440
const promise = findManyRunner (
439
- { connection } as AnyModelManager ,
441
+ { connection } as AnyPublicModelManager ,
440
442
"widgets" ,
441
443
{ id : true , name : true } ,
442
444
"widget" ,
@@ -466,7 +468,7 @@ describe("operationRunners", () => {
466
468
}
467
469
}
468
470
gadgetMeta {
469
- hydrations(modelName:
471
+ hydrations(modelName:
470
472
"outer.widget")
471
473
}
472
474
}"
@@ -502,9 +504,7 @@ describe("operationRunners", () => {
502
504
describe ( "actionRunner" , ( ) => {
503
505
test ( "can run a single create action" , async ( ) => {
504
506
const promise = actionRunner < { id : string ; name : string } > (
505
- {
506
- connection,
507
- } ,
507
+ manager ,
508
508
"createWidget" ,
509
509
{ id : true , name : true } ,
510
510
"widget" ,
@@ -544,9 +544,7 @@ describe("operationRunners", () => {
544
544
545
545
test ( "can run a single update action" , async ( ) => {
546
546
const promise = actionRunner < { id : string ; name : string } > (
547
- {
548
- connection,
549
- } ,
547
+ manager ,
550
548
"updateWidget" ,
551
549
{ id : true , name : true } ,
552
550
"widget" ,
@@ -591,9 +589,7 @@ describe("operationRunners", () => {
591
589
592
590
test ( "can run a single action with an object result type" , async ( ) => {
593
591
const promise = actionRunner (
594
- {
595
- connection,
596
- } ,
592
+ manager ,
597
593
"upsertWidget" ,
598
594
{ id : true , name : true , eventAt : true } ,
599
595
"widget" ,
@@ -646,9 +642,7 @@ describe("operationRunners", () => {
646
642
647
643
test ( "can run a single action with an object result type that has an inner return type" , async ( ) => {
648
644
const promise = actionRunner (
649
- {
650
- connection,
651
- } ,
645
+ manager ,
652
646
"upsertWidget" ,
653
647
{ id : true , name : true , eventAt : true } ,
654
648
"widget" ,
@@ -693,9 +687,7 @@ describe("operationRunners", () => {
693
687
694
688
test ( "can run an action with hasReturnType" , async ( ) => {
695
689
const promise = actionRunner (
696
- {
697
- connection,
698
- } ,
690
+ manager ,
699
691
"createWidget" ,
700
692
{ id : true , name : true } ,
701
693
"widget" ,
@@ -733,9 +725,7 @@ describe("operationRunners", () => {
733
725
734
726
test ( "can throw the error returned by the server for a single action" , async ( ) => {
735
727
const promise = actionRunner < { id : string ; name : string } > (
736
- {
737
- connection,
738
- } ,
728
+ manager ,
739
729
"updateWidget" ,
740
730
{ id : true , name : true } ,
741
731
"widget" ,
@@ -780,9 +770,7 @@ describe("operationRunners", () => {
780
770
781
771
test ( "can run a bulk action by ids" , async ( ) => {
782
772
const promise = actionRunner < { id : string ; name : string } > (
783
- {
784
- connection,
785
- } ,
773
+ manager ,
786
774
"bulkFlipWidgets" ,
787
775
{ id : true , name : true } ,
788
776
"widget" ,
@@ -830,9 +818,7 @@ describe("operationRunners", () => {
830
818
831
819
test ( "can run a bulk action with params" , async ( ) => {
832
820
const promise = actionRunner < { id : string ; name : string } > (
833
- {
834
- connection,
835
- } ,
821
+ manager ,
836
822
"bulkCreateWidgets" ,
837
823
{ id : true , name : true } ,
838
824
"widget" ,
@@ -880,9 +866,7 @@ describe("operationRunners", () => {
880
866
881
867
test ( "can run a bulk action with a returnType" , async ( ) => {
882
868
const promise = actionRunner (
883
- {
884
- connection,
885
- } ,
869
+ manager ,
886
870
"bulkCreateWidgets" ,
887
871
{ id : true , name : true } ,
888
872
"widget" ,
@@ -921,9 +905,7 @@ describe("operationRunners", () => {
921
905
922
906
test ( "can run a bulk action with an object returnType" , async ( ) => {
923
907
const promise = actionRunner (
924
- {
925
- connection,
926
- } ,
908
+ manager ,
927
909
"bulkUpsertWidgets" ,
928
910
{ id : true , name : true } ,
929
911
"widget" ,
@@ -970,9 +952,7 @@ describe("operationRunners", () => {
970
952
971
953
test ( "throws a nice error when a bulk action returns errors" , async ( ) => {
972
954
const promise = actionRunner < { id : string ; name : string } > (
973
- {
974
- connection,
975
- } ,
955
+ manager ,
976
956
"bulkCreateWidgets" ,
977
957
{ id : true , name : true } ,
978
958
"widget" ,
@@ -1010,9 +990,7 @@ describe("operationRunners", () => {
1010
990
1011
991
test ( "throws a nice error when a bulk action returns errors and data" , async ( ) => {
1012
992
const promise = actionRunner < { id : string ; name : string } > (
1013
- {
1014
- connection,
1015
- } ,
993
+ manager ,
1016
994
"bulkCreateWidgets" ,
1017
995
{ id : true , name : true } ,
1018
996
"widget" ,
@@ -1057,9 +1035,7 @@ describe("operationRunners", () => {
1057
1035
1058
1036
test ( "returns undefined when bulk action does not have a result" , async ( ) => {
1059
1037
const promise = actionRunner < { id : string ; name : string } > (
1060
- {
1061
- connection,
1062
- } ,
1038
+ manager ,
1063
1039
"bulkDeleteWidgets" ,
1064
1040
null ,
1065
1041
"widget" ,
@@ -1958,7 +1934,7 @@ describe("operationRunners", () => {
1958
1934
test ( "can run a live findMany" , async ( ) => {
1959
1935
const iterator = asyncIterableToIterator (
1960
1936
findManyRunner < { id : string ; name : string } , { live : true } > (
1961
- { connection } as AnyModelManager ,
1937
+ { connection } as AnyPublicModelManager ,
1962
1938
"widgets" ,
1963
1939
{ id : true , name : true } ,
1964
1940
"widget" ,
0 commit comments