-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
116 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,25 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { RequiredArgs as Args } from '../extensions/$extends' | ||
import { Omit, PatchFlat3,Pick, } from './Utils' | ||
import { Omit, ReadonlyDeep } from './Utils' | ||
|
||
export type DefaultArgs = { result: {}; model: {}; query: {}; client: {} } | ||
|
||
export type GetResultPayload<Base extends object, R extends Args['result'][string]> = | ||
PatchFlat3<{}, { [K in keyof R]: ReturnType<R[K]['compute']> }, Base> | ||
{} extends R ? Base : { [K in keyof R]: ReturnType<R[K]['compute']> } & { [K in Exclude<keyof Base, keyof R>]: Base[K] } | ||
|
||
export type GetResultSelect<Base extends object, R extends Args['result'][string]> = | ||
Base & { [K in keyof R]?: true } | ||
R extends unknown ? Base & { [K in keyof R]?: boolean } : never | ||
|
||
export type GetModel<Base extends object, M extends Args['model'][string]> = | ||
PatchFlat3<M, Base, {}> | ||
M & Omit<Base, keyof M> | ||
|
||
export type GetClient<Base extends object, C extends Args['client'], CP extends Args['client']> = | ||
PatchFlat3<C, CP, Omit<Base, '$use'>> | ||
C & Omit<CP, keyof C> & Omit<Base, '$use' | keyof C | keyof CP> | ||
|
||
export type ReadonlySelector<T> = { | ||
readonly [K in keyof T as K extends 'include' | 'select' ? K : never]: ReadonlySelector<T[K]> | ||
export type ReadonlySelector<T> = T extends unknown ? { | ||
readonly [K in keyof T as K extends 'include' | 'select' ? K : never]: ReadonlyDeep<T[K]> | ||
} & { | ||
[K in keyof T as K extends 'include' | 'select' ? never : K]: T[K] | ||
} | ||
|
||
export type MergeArgs< | ||
ExtArgs extends Args, | ||
PrevExtArgs extends Args, | ||
ModelNames extends string, | ||
ApplyAllModels extends boolean = true, | ||
> = { | ||
result: '$allModels' extends keyof ExtArgs['result'] ? ApplyAllModels extends true | ||
? { [K in ModelNames]: PatchFlat3<ExtArgs['result'][K], ExtArgs['result']['$allModels'], PrevExtArgs['result'][K]> } | ||
: { [K in keyof ExtArgs['result'] | keyof PrevExtArgs['result']]: PatchFlat3<ExtArgs['result'][K], PrevExtArgs['result'][K], {}> } | ||
: { [K in keyof ExtArgs['result'] | keyof PrevExtArgs['result']]: PatchFlat3<ExtArgs['result'][K], PrevExtArgs['result'][K], {}> } | ||
model: '$allModels' extends keyof ExtArgs['model'] ? ApplyAllModels extends true | ||
? { [K in ModelNames]: PatchFlat3<ExtArgs['model'][K], ExtArgs['model']['$allModels'], PrevExtArgs['model'][K]> } | ||
: { [K in keyof ExtArgs['model'] | keyof PrevExtArgs['model']]: PatchFlat3<ExtArgs['model'][K], PrevExtArgs['model'][K], {}> } | ||
: { [K in keyof ExtArgs['model'] | keyof PrevExtArgs['model']]: PatchFlat3<ExtArgs['model'][K], PrevExtArgs['model'][K], {}> } | ||
client: Pick<PatchFlat3<ExtArgs['client'], PrevExtArgs['client'], {}>, `$${string}`> | ||
query: {} | ||
} | ||
} : never | ||
|
||
export type { Args } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters