@@ -56,23 +56,20 @@ export type MutationFactorySchema = Record<string, MutationFactoryProperty | Mut
5656
5757type InvalidSchema < Schema extends MutationFactorySchema > = Omit < Schema , InternalKey > ;
5858
59- export type ValidateFactory < Schema extends MutationFactorySchema > = Schema extends {
60- [ P in ExtractInternalKeys < Schema > ] : Schema [ P ] ;
61- }
62- ? InvalidSchema < Schema >
59+ export type ValidateFactory < Schema extends MutationFactorySchema > =
60+ Schema extends {
61+ [ P in ExtractInternalKeys < Schema > ] : Schema [ P ] ;
62+ } ?
63+ InvalidSchema < Schema >
6364 : Schema ;
6465
65- type ExtractNullableKey < Key extends KeyTuple | null | undefined > = Key extends
66- | [ ...infer Value ]
67- | readonly [ ...infer Value ]
68- ? Value
69- : Key extends null | undefined | unknown
70- ? null
66+ type ExtractNullableKey < Key extends KeyTuple | null | undefined > =
67+ Key extends [ ...infer Value ] | readonly [ ...infer Value ] ? Value
68+ : Key extends null | undefined | unknown ? null
7169 : never ;
7270
73- type ComposeQueryKey < BaseKey extends AnyMutableOrReadonlyArray , Key > = Key extends KeyTuple
74- ? readonly [ ...BaseKey , ...Key ]
75- : readonly [ ...BaseKey ] ;
71+ type ComposeQueryKey < BaseKey extends AnyMutableOrReadonlyArray , Key > =
72+ Key extends KeyTuple ? readonly [ ...BaseKey , ...Key ] : readonly [ ...BaseKey ] ;
7673
7774export type MutationOptionsStruct <
7875 Keys extends AnyMutableOrReadonlyArray ,
@@ -90,24 +87,25 @@ type MutationFactoryWithContextualQueriesOutput<
9087 SchemaMutationKey extends Schema [ 'mutationKey' ] = Schema [ 'mutationKey' ] ,
9188 ContextMutations extends Schema [ 'contextMutations' ] = Schema [ 'contextMutations' ] ,
9289 ComposedKey extends AnyMutableOrReadonlyArray = ComposeQueryKey < BaseKey , ExtractNullableKey < SchemaMutationKey > > ,
93- > = SchemaMutationKey extends null
94- ? Omit < MutationOptionsStruct < ComposedKey , MutateFunction > , 'mutationFn' > & {
90+ > =
91+ SchemaMutationKey extends null ?
92+ Omit < MutationOptionsStruct < ComposedKey , MutateFunction > , 'mutationFn' > & {
9593 _ctx : {
96- [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey
97- ? DynamicMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
98- : ContextMutations [ P ] extends MutationFactoryProperty
99- ? StaticMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
100- : never ;
94+ [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey ?
95+ DynamicMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
96+ : ContextMutations [ P ] extends MutationFactoryProperty ?
97+ StaticMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
98+ : never ;
10199 } ;
102100 }
103101 : Omit < MutationOptionsStruct < ComposedKey , MutateFunction > , 'mutationFn' > &
104102 DefinitionKey < BaseKey > & {
105103 _ctx : {
106- [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey
107- ? DynamicMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
108- : ContextMutations [ P ] extends MutationFactoryProperty
109- ? StaticMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
110- : never ;
104+ [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey ?
105+ DynamicMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
106+ : ContextMutations [ P ] extends MutationFactoryProperty ?
107+ StaticMutationFactoryOutput < [ ...ComposedKey , P ] , ContextMutations [ P ] >
108+ : never ;
111109 } ;
112110 } ;
113111
@@ -116,8 +114,8 @@ type FactoryMutationKeyRecordOutput<
116114 Schema extends NullableMutationKeyRecord | MutationKeyRecord ,
117115 SchemaMutationKey extends Schema [ 'mutationKey' ] = Schema [ 'mutationKey' ] ,
118116 ComposedKey extends AnyMutableOrReadonlyArray = ComposeQueryKey < BaseKey , ExtractNullableKey < SchemaMutationKey > > ,
119- > = SchemaMutationKey extends null
120- ? Omit < MutationOptionsStruct < BaseKey , MutateFunction > , 'mutationFn' >
117+ > =
118+ SchemaMutationKey extends null ? Omit < MutationOptionsStruct < BaseKey , MutateFunction > , 'mutationFn' >
121119 : Omit < MutationOptionsStruct < ComposedKey , MutateFunction > , 'mutationFn' > & DefinitionKey < BaseKey > ;
122120
123121type FactoryMutationOptionsOutput <
@@ -126,8 +124,8 @@ type FactoryMutationOptionsOutput<
126124 SchemaQueryKey extends Schema [ 'mutationKey' ] = Schema [ 'mutationKey' ] ,
127125 MutationFn extends Schema [ 'mutationFn' ] = Schema [ 'mutationFn' ] ,
128126 ComposedKey extends AnyMutableOrReadonlyArray = ComposeQueryKey < BaseKey , ExtractNullableKey < SchemaQueryKey > > ,
129- > = SchemaQueryKey extends null
130- ? MutationOptionsStruct < BaseKey , MutationFn >
127+ > =
128+ SchemaQueryKey extends null ? MutationOptionsStruct < BaseKey , MutationFn >
131129 : MutationOptionsStruct < ComposedKey , MutationFn > & DefinitionKey < BaseKey > ;
132130
133131type FactoryMutationOptionsWithContextualQueriesOutput <
@@ -137,71 +135,64 @@ type FactoryMutationOptionsWithContextualQueriesOutput<
137135 MutationFn extends Schema [ 'mutationFn' ] = Schema [ 'mutationFn' ] ,
138136 ContextMutations extends Schema [ 'contextMutations' ] = Schema [ 'contextMutations' ] ,
139137 Key extends AnyMutableOrReadonlyArray = ComposeQueryKey < BaseKey , ExtractNullableKey < SchemaQueryKey > > ,
140- > = SchemaQueryKey extends null
141- ? MutationOptionsStruct < Key , MutationFn > & {
138+ > =
139+ SchemaQueryKey extends null ?
140+ MutationOptionsStruct < Key , MutationFn > & {
142141 _ctx : {
143- [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey
144- ? DynamicMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
145- : ContextMutations [ P ] extends MutationFactoryProperty
146- ? StaticMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
147- : never ;
142+ [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey ?
143+ DynamicMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
144+ : ContextMutations [ P ] extends MutationFactoryProperty ?
145+ StaticMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
146+ : never ;
148147 } ;
149148 }
150149 : DefinitionKey < BaseKey > &
151150 MutationOptionsStruct < Key , MutationFn > & {
152151 _ctx : {
153- [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey
154- ? DynamicMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
155- : ContextMutations [ P ] extends MutationFactoryProperty
156- ? StaticMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
157- : never ;
152+ [ P in keyof ContextMutations ] : ContextMutations [ P ] extends MutationDynamicKey ?
153+ DynamicMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
154+ : ContextMutations [ P ] extends MutationFactoryProperty ?
155+ StaticMutationFactoryOutput < [ ...Key , P ] , ContextMutations [ P ] >
156+ : never ;
158157 } ;
159158 } ;
160159
161160type DynamicMutationFactoryOutput <
162161 Keys extends AnyMutableOrReadonlyArray ,
163162 Generator extends MutationDynamicKey ,
164163 Output extends ReturnType < Generator > = ReturnType < Generator > ,
165- > = ( (
166- ...args : Parameters < Generator >
167- ) => Output extends [ ...infer TupleResult ] | readonly [ ...infer TupleResult ]
168- ? Omit < MutationOptionsStruct < [ ...Keys , ...TupleResult ] , MutateFunction > , 'mutationFn' >
169- : Output extends DynamicMutationFactoryWithContextualMutationsSchema
170- ? Omit < FactoryMutationOptionsWithContextualQueriesOutput < Keys , Output > , '_def' >
171- : Output extends DynamicMutationFactorySchema
172- ? Omit < FactoryMutationOptionsOutput < Keys , Output > , '_def' >
173- : Output extends DynamicMutationKeySchemaWithContextualMutations
174- ? Omit < MutationFactoryWithContextualQueriesOutput < Keys , Output > , '_def' >
175- : Output extends MutationKeyRecord
176- ? Omit < FactoryMutationKeyRecordOutput < Keys , Output > , '_def' >
177- : never ) &
164+ > = ( ( ...args : Parameters < Generator > ) => Output extends [ ...infer TupleResult ] | readonly [ ...infer TupleResult ] ?
165+ Omit < MutationOptionsStruct < [ ...Keys , ...TupleResult ] , MutateFunction > , 'mutationFn' >
166+ : Output extends DynamicMutationFactoryWithContextualMutationsSchema ?
167+ Omit < FactoryMutationOptionsWithContextualQueriesOutput < Keys , Output > , '_def' >
168+ : Output extends DynamicMutationFactorySchema ? Omit < FactoryMutationOptionsOutput < Keys , Output > , '_def' >
169+ : Output extends DynamicMutationKeySchemaWithContextualMutations ?
170+ Omit < MutationFactoryWithContextualQueriesOutput < Keys , Output > , '_def' >
171+ : Output extends MutationKeyRecord ? Omit < FactoryMutationKeyRecordOutput < Keys , Output > , '_def' >
172+ : never ) &
178173 DefinitionKey < Keys > ;
179174
180175export type AnyMutationFactoryOutputCallback = DynamicMutationFactoryOutput < [ string , ...any [ ] ] , MutationDynamicKey > ;
181176
182177export type StaticMutationFactoryOutput <
183178 Keys extends AnyMutableOrReadonlyArray ,
184179 Property extends MutationFactoryProperty ,
185- > = Property extends null
186- ? Omit < MutationOptionsStruct < Keys , MutateFunction > , 'mutationFn' >
187- : Property extends [ ...infer Result ] | readonly [ ...infer Result ]
188- ? DefinitionKey < Keys > & Omit < MutationOptionsStruct < [ ...Keys , ...Result ] , MutateFunction > , 'mutationFn' >
189- : Property extends MutationFactoryWithContextualMutationsSchema
190- ? FactoryMutationOptionsWithContextualQueriesOutput < Keys , Property >
191- : Property extends $MutationFactorySchema
192- ? FactoryMutationOptionsOutput < Keys , Property >
193- : Property extends MutationKeySchemaWithContextualMutations
194- ? MutationFactoryWithContextualQueriesOutput < Keys , Property >
195- : Property extends NullableMutationKeyRecord
196- ? FactoryMutationKeyRecordOutput < Keys , Property >
180+ > =
181+ Property extends null ? Omit < MutationOptionsStruct < Keys , MutateFunction > , 'mutationFn' >
182+ : Property extends [ ...infer Result ] | readonly [ ...infer Result ] ?
183+ DefinitionKey < Keys > & Omit < MutationOptionsStruct < [ ...Keys , ...Result ] , MutateFunction > , 'mutationFn' >
184+ : Property extends MutationFactoryWithContextualMutationsSchema ?
185+ FactoryMutationOptionsWithContextualQueriesOutput < Keys , Property >
186+ : Property extends $MutationFactorySchema ? FactoryMutationOptionsOutput < Keys , Property >
187+ : Property extends MutationKeySchemaWithContextualMutations ?
188+ MutationFactoryWithContextualQueriesOutput < Keys , Property >
189+ : Property extends NullableMutationKeyRecord ? FactoryMutationKeyRecordOutput < Keys , Property >
197190 : never ;
198191
199192type MutationFactoryOutput < Key extends string , Schema extends MutationFactorySchema > = DefinitionKey < [ Key ] > & {
200- [ P in keyof Schema ] : Schema [ P ] extends MutationDynamicKey
201- ? DynamicMutationFactoryOutput < [ Key , P ] , Schema [ P ] >
202- : Schema [ P ] extends MutationFactoryProperty
203- ? StaticMutationFactoryOutput < [ Key , P ] , Schema [ P ] >
204- : never ;
193+ [ P in keyof Schema ] : Schema [ P ] extends MutationDynamicKey ? DynamicMutationFactoryOutput < [ Key , P ] , Schema [ P ] >
194+ : Schema [ P ] extends MutationFactoryProperty ? StaticMutationFactoryOutput < [ Key , P ] , Schema [ P ] >
195+ : never ;
205196} ;
206197
207198export type MutationKeyFactoryResult < Key extends string , Schema extends MutationFactorySchema > = MutationFactoryOutput <
0 commit comments