@@ -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 { AnyPublicModelManager , GadgetErrorGroup , LimitToKnownKeys } from "../src/index.js" ;
7
+ import type { AnyModelManager , GadgetErrorGroup , LimitToKnownKeys } from "../src/index.js" ;
8
8
import {
9
9
GadgetConnection ,
10
10
actionRunner ,
@@ -48,7 +48,6 @@ 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 ;
52
51
let query : string | undefined ;
53
52
let mockUrqlClient : MockUrqlClient ;
54
53
@@ -61,26 +60,25 @@ describe("operationRunners", () => {
61
60
} ,
62
61
} ) ;
63
62
jest . spyOn ( connection , "currentClient" as any , "get" ) . mockReturnValue ( mockUrqlClient as any ) ;
64
- manager = { connection } as AnyPublicModelManager ;
65
63
} ) ;
66
64
67
65
describe ( "findOneRunner" , ( ) => {
68
66
test ( "can execute a findOne operation against a model" , async ( ) => {
69
67
const promise = findOneRunner ( { connection } , "widget" , "123" , { id : true , name : true } , "widget" ) ;
70
68
71
69
expect ( query ) . toMatchInlineSnapshot ( `
72
- "query widget($id: GadgetID!) {
73
- widget(id: $id) {
74
- id
75
- name
76
- __typename
77
- }
78
- gadgetMeta {
79
- hydrations(modelName:
80
- "widget")
81
- }
82
- }"
83
- ` ) ;
70
+ "query widget($id: GadgetID!) {
71
+ widget(id: $id) {
72
+ id
73
+ name
74
+ __typename
75
+ }
76
+ gadgetMeta {
77
+ hydrations(modelName:
78
+ "widget")
79
+ }
80
+ }"
81
+ ` ) ;
84
82
85
83
mockUrqlClient . executeQuery . pushResponse ( "widget" , {
86
84
data : {
@@ -318,32 +316,32 @@ describe("operationRunners", () => {
318
316
319
317
describe ( "findManyRunner" , ( ) => {
320
318
test ( "can execute a findMany operation against a model" , async ( ) => {
321
- const promise = findManyRunner ( { connection } as AnyPublicModelManager , "widgets" , { id : true , name : true } , "widget" ) ;
319
+ const promise = findManyRunner ( { connection } as AnyModelManager , "widgets" , { id : true , name : true } , "widget" ) ;
322
320
323
321
expect ( query ) . toMatchInlineSnapshot ( `
324
- "query widgets($after: String, $first: Int, $before: String, $last: Int) {
325
- widgets(after: $after, first: $first, before: $before, last: $last) {
326
- pageInfo {
327
- hasNextPage
328
- hasPreviousPage
329
- startCursor
330
- endCursor
331
- }
332
- edges {
333
- cursor
334
- node {
335
- id
336
- name
337
- __typename
338
- }
339
- }
340
- }
341
- gadgetMeta {
342
- hydrations(modelName:
343
- "widget")
344
- }
345
- }"
346
- ` ) ;
322
+ "query widgets($after: String, $first: Int, $before: String, $last: Int) {
323
+ widgets(after: $after, first: $first, before: $before, last: $last) {
324
+ pageInfo {
325
+ hasNextPage
326
+ hasPreviousPage
327
+ startCursor
328
+ endCursor
329
+ }
330
+ edges {
331
+ cursor
332
+ node {
333
+ id
334
+ name
335
+ __typename
336
+ }
337
+ }
338
+ }
339
+ gadgetMeta {
340
+ hydrations(modelName:
341
+ "widget")
342
+ }
343
+ }"
344
+ ` ) ;
347
345
348
346
mockUrqlClient . executeQuery . pushResponse ( "widgets" , {
349
347
data : {
@@ -371,7 +369,7 @@ describe("operationRunners", () => {
371
369
372
370
test ( "can execute a findMany operation against a namespaced model" , async ( ) => {
373
371
const promise = findManyRunner (
374
- { connection } as AnyPublicModelManager ,
372
+ { connection } as AnyModelManager ,
375
373
"widgets" ,
376
374
{ id : true , name : true } ,
377
375
"widget" ,
@@ -438,7 +436,7 @@ describe("operationRunners", () => {
438
436
439
437
test ( "can execute a findMany operation against a namespaced model when the namespace is a string" , async ( ) => {
440
438
const promise = findManyRunner (
441
- { connection } as AnyPublicModelManager ,
439
+ { connection } as AnyModelManager ,
442
440
"widgets" ,
443
441
{ id : true , name : true } ,
444
442
"widget" ,
@@ -504,7 +502,9 @@ describe("operationRunners", () => {
504
502
describe ( "actionRunner" , ( ) => {
505
503
test ( "can run a single create action" , async ( ) => {
506
504
const promise = actionRunner < { id : string ; name : string } > (
507
- manager ,
505
+ {
506
+ connection,
507
+ } ,
508
508
"createWidget" ,
509
509
{ id : true , name : true } ,
510
510
"widget" ,
@@ -544,7 +544,9 @@ describe("operationRunners", () => {
544
544
545
545
test ( "can run a single update action" , async ( ) => {
546
546
const promise = actionRunner < { id : string ; name : string } > (
547
- manager ,
547
+ {
548
+ connection,
549
+ } ,
548
550
"updateWidget" ,
549
551
{ id : true , name : true } ,
550
552
"widget" ,
@@ -589,7 +591,9 @@ describe("operationRunners", () => {
589
591
590
592
test ( "can run a single action with an object result type" , async ( ) => {
591
593
const promise = actionRunner (
592
- manager ,
594
+ {
595
+ connection,
596
+ } ,
593
597
"upsertWidget" ,
594
598
{ id : true , name : true , eventAt : true } ,
595
599
"widget" ,
@@ -642,7 +646,9 @@ describe("operationRunners", () => {
642
646
643
647
test ( "can run a single action with an object result type that has an inner return type" , async ( ) => {
644
648
const promise = actionRunner (
645
- manager ,
649
+ {
650
+ connection,
651
+ } ,
646
652
"upsertWidget" ,
647
653
{ id : true , name : true , eventAt : true } ,
648
654
"widget" ,
@@ -687,7 +693,9 @@ describe("operationRunners", () => {
687
693
688
694
test ( "can run an action with hasReturnType" , async ( ) => {
689
695
const promise = actionRunner (
690
- manager ,
696
+ {
697
+ connection,
698
+ } ,
691
699
"createWidget" ,
692
700
{ id : true , name : true } ,
693
701
"widget" ,
@@ -725,7 +733,9 @@ describe("operationRunners", () => {
725
733
726
734
test ( "can throw the error returned by the server for a single action" , async ( ) => {
727
735
const promise = actionRunner < { id : string ; name : string } > (
728
- manager ,
736
+ {
737
+ connection,
738
+ } ,
729
739
"updateWidget" ,
730
740
{ id : true , name : true } ,
731
741
"widget" ,
@@ -770,7 +780,9 @@ describe("operationRunners", () => {
770
780
771
781
test ( "can run a bulk action by ids" , async ( ) => {
772
782
const promise = actionRunner < { id : string ; name : string } > (
773
- manager ,
783
+ {
784
+ connection,
785
+ } ,
774
786
"bulkFlipWidgets" ,
775
787
{ id : true , name : true } ,
776
788
"widget" ,
@@ -818,7 +830,9 @@ describe("operationRunners", () => {
818
830
819
831
test ( "can run a bulk action with params" , async ( ) => {
820
832
const promise = actionRunner < { id : string ; name : string } > (
821
- manager ,
833
+ {
834
+ connection,
835
+ } ,
822
836
"bulkCreateWidgets" ,
823
837
{ id : true , name : true } ,
824
838
"widget" ,
@@ -866,7 +880,9 @@ describe("operationRunners", () => {
866
880
867
881
test ( "can run a bulk action with a returnType" , async ( ) => {
868
882
const promise = actionRunner (
869
- manager ,
883
+ {
884
+ connection,
885
+ } ,
870
886
"bulkCreateWidgets" ,
871
887
{ id : true , name : true } ,
872
888
"widget" ,
@@ -905,7 +921,9 @@ describe("operationRunners", () => {
905
921
906
922
test ( "can run a bulk action with an object returnType" , async ( ) => {
907
923
const promise = actionRunner (
908
- manager ,
924
+ {
925
+ connection,
926
+ } ,
909
927
"bulkUpsertWidgets" ,
910
928
{ id : true , name : true } ,
911
929
"widget" ,
@@ -952,7 +970,9 @@ describe("operationRunners", () => {
952
970
953
971
test ( "throws a nice error when a bulk action returns errors" , async ( ) => {
954
972
const promise = actionRunner < { id : string ; name : string } > (
955
- manager ,
973
+ {
974
+ connection,
975
+ } ,
956
976
"bulkCreateWidgets" ,
957
977
{ id : true , name : true } ,
958
978
"widget" ,
@@ -990,7 +1010,9 @@ describe("operationRunners", () => {
990
1010
991
1011
test ( "throws a nice error when a bulk action returns errors and data" , async ( ) => {
992
1012
const promise = actionRunner < { id : string ; name : string } > (
993
- manager ,
1013
+ {
1014
+ connection,
1015
+ } ,
994
1016
"bulkCreateWidgets" ,
995
1017
{ id : true , name : true } ,
996
1018
"widget" ,
@@ -1035,7 +1057,9 @@ describe("operationRunners", () => {
1035
1057
1036
1058
test ( "returns undefined when bulk action does not have a result" , async ( ) => {
1037
1059
const promise = actionRunner < { id : string ; name : string } > (
1038
- manager ,
1060
+ {
1061
+ connection,
1062
+ } ,
1039
1063
"bulkDeleteWidgets" ,
1040
1064
null ,
1041
1065
"widget" ,
@@ -1934,7 +1958,7 @@ describe("operationRunners", () => {
1934
1958
test ( "can run a live findMany" , async ( ) => {
1935
1959
const iterator = asyncIterableToIterator (
1936
1960
findManyRunner < { id : string ; name : string } , { live : true } > (
1937
- { connection } as AnyPublicModelManager ,
1961
+ { connection } as AnyModelManager ,
1938
1962
"widgets" ,
1939
1963
{ id : true , name : true } ,
1940
1964
"widget" ,
0 commit comments