Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): extensions generic type api #16936

Merged
merged 32 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cdfa857
fix typescript compiler crash
millsp Dec 16, 2022
e218d3a
update snaps
millsp Dec 16, 2022
1233184
feat(client): extensions generic type api
millsp Dec 21, 2022
b735b40
fix type performance
millsp Dec 22, 2022
ec21568
Merge branch 'main' of github.com:prisma/prisma into integration/feat…
millsp Dec 22, 2022
4f116b8
rework ctx and meta
millsp Dec 22, 2022
f9f3bf8
update snaps
millsp Dec 22, 2022
7d5330f
Merge branch 'main' into integration/feat/client-ext-generic-type-api
millsp Dec 22, 2022
dafbcf7
yet another significant type perf fix
millsp Dec 24, 2022
728211b
fix broken tests
millsp Dec 26, 2022
d450ab6
simplify meta.name and add tests
millsp Dec 27, 2022
15d79ef
implement altering internal params
millsp Dec 27, 2022
5aa62a9
use all models in test instead
millsp Dec 27, 2022
683f3ec
fix object id in tests
millsp Dec 27, 2022
1a427da
fix node length exceeded and payload export
millsp Jan 10, 2023
830bbca
second attempt to fix node inference
millsp Jan 11, 2023
080ba38
Merge branch 'main' of github.com:prisma/prisma into integration/feat…
millsp Jan 11, 2023
071b7f1
add Payload type utility
millsp Jan 11, 2023
a1a8183
fix and test exact types in generic context
millsp Jan 11, 2023
cdd115a
expose extension utils in non generated client
millsp Jan 12, 2023
cc88b77
fix issue wrt exact types not enforcing type-checks
millsp Jan 12, 2023
daac8ae
fix type mismatch
millsp Jan 12, 2023
d6def99
enable default client cross generated client extensions tests
millsp Jan 13, 2023
d4a80ec
Merge branch 'main' of github.com:prisma/prisma into integration/feat…
millsp Jan 13, 2023
485ede8
add regression test for tsc crash
millsp Jan 14, 2023
235f2a6
create sub-folder for extension publishing
millsp Jan 14, 2023
20b2904
add test fro extension publishing + various cleanups
millsp Jan 14, 2023
ed2fd95
exclude e2e from dep checks
millsp Jan 14, 2023
85b84a5
remove non needed payload kind
millsp Jan 14, 2023
e24a2c6
add comment
millsp Jan 14, 2023
648e866
remove payload kind from tests
millsp Jan 14, 2023
030fc63
Merge branch 'main' of github.com:prisma/prisma into integration/feat…
millsp Jan 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers/compile/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function dependencyCheck(options: BuildOptions) {
const buildPromise = esbuild.build({
entryPoints: glob.sync('**/*.{j,t}s', {
// We don't check dependencies in ecosystem tests because tests are isolated from the build.
ignore: ['./src/__tests__/**/*', './tests/ecosystem/**/*'],
ignore: ['./src/__tests__/**/*', './tests/e2e/**/*'],
gitignore: true,
}),
logLevel: 'silent', // there will be errors
Expand Down
50 changes: 31 additions & 19 deletions packages/client/scripts/default-index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable prettier/prettier */

import runtime from '@prisma/client/runtime'

/**
Expand All @@ -17,6 +15,7 @@ import runtime from '@prisma/client/runtime'
* Read more in our [docs](https://github.com/prisma/prisma/blob/main/docs/prisma-client-js/api.md).
*/
export declare const PrismaClient: any

/**
* ## Prisma Client ʲˢ
*
Expand All @@ -33,16 +32,20 @@ export declare const PrismaClient: any
*/
export declare type PrismaClient = any

export declare type PrismaClientExtends<ExtArgs extends runtime.Types.Extensions.Args = runtime.Types.Extensions.DefaultArgs> = {
export declare type PrismaClientExtends<
ExtArgs extends runtime.Types.Extensions.Args = runtime.Types.Extensions.DefaultArgs,
> = {
$extends: { extArgs: ExtArgs } & (<
R extends runtime.Types.Extensions.Args['result'] = {},
M extends runtime.Types.Extensions.Args['model'] = {},
Q extends runtime.Types.Extensions.Args['query'] = {},
C extends runtime.Types.Extensions.Args['client'] = {},
Args extends runtime.Types.Extensions.Args = { result: R; model: M; query: Q; client: C }
>(args: ((client: PrismaClientExtends<ExtArgs>) => { $extends: { extArgs: Args } }) | {
result?: R; model?: M; query?: Q; client?: C
}) => PrismaClientExtends<runtime.Types.Utils.PatchDeep<Args, ExtArgs>>)
R extends runtime.Types.Extensions.UserArgs['result'] = {},
M extends runtime.Types.Extensions.UserArgs['model'] = {},
Q extends runtime.Types.Extensions.UserArgs['query'] = {},
C extends runtime.Types.Extensions.UserArgs['client'] = {},
Args extends runtime.Types.Extensions.Args = runtime.Types.Extensions.InternalArgs<R, M, Q, C>,
>(
args:
| ((client: PrismaClientExtends<ExtArgs>) => { $extends: { extArgs: Args } })
| { name?: string; result?: R; model?: M; query?: Q; client?: C },
) => PrismaClientExtends<Args & ExtArgs>)
}

export declare const dmmf: any
Expand All @@ -62,12 +65,21 @@ export namespace Prisma {
export type TransactionClient = any

export function defineExtension<
R extends runtime.Types.Extensions.Args['result'] = {},
M extends runtime.Types.Extensions.Args['model'] = {},
Q extends runtime.Types.Extensions.Args['query'] = {},
C extends runtime.Types.Extensions.Args['client'] = {},
Args extends runtime.Types.Extensions.Args = { result: R; model: M; query: Q; client: C }
>(args: ((client: PrismaClientExtends) => { $extends: { extArgs: Args } }) | {
result?: R; model?: M; query?: Q; client?: C
}): (client: any) => PrismaClientExtends<Args>
R extends runtime.Types.Extensions.UserArgs['result'] = {},
M extends runtime.Types.Extensions.UserArgs['model'] = {},
Q extends runtime.Types.Extensions.UserArgs['query'] = {},
C extends runtime.Types.Extensions.UserArgs['client'] = {},
Args extends runtime.Types.Extensions.Args = runtime.Types.Extensions.InternalArgs<R, M, Q, C>,
>(
args:
| ((client: PrismaClientExtends) => { $extends: { extArgs: Args } })
| { name?: string; result?: R; model?: M; query?: Q; client?: C },
): (client: any) => PrismaClientExtends<Args>

export type Extension = runtime.Types.Extensions.UserArgs
export import getExtensionContext = runtime.Extensions.getExtensionContext
export type Args<T, F extends runtime.Types.Public.Operation> = runtime.Types.Public.Args<T, F> & {}
export type Payload<T, F extends runtime.Types.Public.Operation> = runtime.Types.Public.Payload<T, F> & {}
export type Result<T, A, F extends runtime.Types.Public.Operation> = runtime.Types.Public.Result<T, A, F> & {}
export type Exact<T, W> = runtime.Types.Public.Exact<T, W> & {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1243,19 +1243,11 @@ export namespace Prisma {

export type Keys<U extends Union> = U extends unknown ? keyof U : never

type Exact<A, W = unknown> =
W extends unknown ? A extends Narrowable ? Cast<A, W> : Cast<
{[K in keyof A]: K extends keyof W ? Exact<A[K], W[K]> : never},
{[K in keyof W]: K extends keyof A ? Exact<A[K], W[K]> : W[K]}>
: never;

type Narrowable = string | number | boolean | bigint;

type Cast<A, B> = A extends B ? A : B;

export const type: unique symbol;

export function validator<V>(): <S>(select: Exact<S, V>) => S;
export function validator<V>(): <S>(select: runtime.Types.Utils.LegacyExact<S, V>) => S;

/**
* Used by group by
Expand Down Expand Up @@ -1762,6 +1754,7 @@ export namespace Prisma {




}

/**
Expand Down Expand Up @@ -1872,6 +1865,7 @@ export namespace Prisma {




}

/**
Expand Down Expand Up @@ -2136,13 +2130,13 @@ export namespace Prisma {
: Post


type PostCountArgs = Merge<
type PostCountArgs =
Omit<PostFindManyArgs, 'select' | 'include'> & {
select?: PostCountAggregateInputType | true
}
>

export interface PostDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one Post that matches the filter.
* @param {PostFindUniqueArgs} args - Arguments to find a Post
Expand Down Expand Up @@ -3251,13 +3245,13 @@ export namespace Prisma {
: User


type UserCountArgs = Merge<
type UserCountArgs =
Omit<UserFindManyArgs, 'select' | 'include'> & {
select?: UserCountAggregateInputType | true
}
>

export interface UserDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one User that matches the filter.
* @param {UserFindUniqueArgs} args - Arguments to find a User
Expand Down Expand Up @@ -4265,13 +4259,13 @@ export namespace Prisma {
: EmbedHolder


type EmbedHolderCountArgs = Merge<
type EmbedHolderCountArgs =
Omit<EmbedHolderFindManyArgs, 'select' | 'include'> & {
select?: EmbedHolderCountAggregateInputType | true
}
>

export interface EmbedHolderDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one EmbedHolder that matches the filter.
* @param {EmbedHolderFindUniqueArgs} args - Arguments to find a EmbedHolder
Expand Down Expand Up @@ -5391,13 +5385,13 @@ export namespace Prisma {
: M


type MCountArgs = Merge<
type MCountArgs =
Omit<MFindManyArgs, 'select' | 'include'> & {
select?: MCountAggregateInputType | true
}
>

export interface MDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one M that matches the filter.
* @param {MFindUniqueArgs} args - Arguments to find a M
Expand Down Expand Up @@ -6511,13 +6505,13 @@ export namespace Prisma {
: N


type NCountArgs = Merge<
type NCountArgs =
Omit<NFindManyArgs, 'select' | 'include'> & {
select?: NCountAggregateInputType | true
}
>

export interface NDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one N that matches the filter.
* @param {NFindUniqueArgs} args - Arguments to find a N
Expand Down Expand Up @@ -7627,13 +7621,13 @@ export namespace Prisma {
: OneOptional


type OneOptionalCountArgs = Merge<
type OneOptionalCountArgs =
Omit<OneOptionalFindManyArgs, 'select' | 'include'> & {
select?: OneOptionalCountAggregateInputType | true
}
>

export interface OneOptionalDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one OneOptional that matches the filter.
* @param {OneOptionalFindUniqueArgs} args - Arguments to find a OneOptional
Expand Down Expand Up @@ -8747,13 +8741,13 @@ export namespace Prisma {
: ManyRequired


type ManyRequiredCountArgs = Merge<
type ManyRequiredCountArgs =
Omit<ManyRequiredFindManyArgs, 'select' | 'include'> & {
select?: ManyRequiredCountAggregateInputType | true
}
>

export interface ManyRequiredDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one ManyRequired that matches the filter.
* @param {ManyRequiredFindUniqueArgs} args - Arguments to find a ManyRequired
Expand Down Expand Up @@ -9846,13 +9840,13 @@ export namespace Prisma {
: OptionalSide1


type OptionalSide1CountArgs = Merge<
type OptionalSide1CountArgs =
Omit<OptionalSide1FindManyArgs, 'select' | 'include'> & {
select?: OptionalSide1CountAggregateInputType | true
}
>

export interface OptionalSide1Delegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one OptionalSide1 that matches the filter.
* @param {OptionalSide1FindUniqueArgs} args - Arguments to find a OptionalSide1
Expand Down Expand Up @@ -10937,13 +10931,13 @@ export namespace Prisma {
: OptionalSide2


type OptionalSide2CountArgs = Merge<
type OptionalSide2CountArgs =
Omit<OptionalSide2FindManyArgs, 'select' | 'include'> & {
select?: OptionalSide2CountAggregateInputType | true
}
>

export interface OptionalSide2Delegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one OptionalSide2 that matches the filter.
* @param {OptionalSide2FindUniqueArgs} args - Arguments to find a OptionalSide2
Expand Down Expand Up @@ -11968,13 +11962,13 @@ export namespace Prisma {
: A


type ACountArgs = Merge<
type ACountArgs =
Omit<AFindManyArgs, 'select' | 'include'> & {
select?: ACountAggregateInputType | true
}
>

export interface ADelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one A that matches the filter.
* @param {AFindUniqueArgs} args - Arguments to find a A
Expand Down Expand Up @@ -12930,13 +12924,13 @@ export namespace Prisma {
: B


type BCountArgs = Merge<
type BCountArgs =
Omit<BFindManyArgs, 'select' | 'include'> & {
select?: BCountAggregateInputType | true
}
>

export interface BDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one B that matches the filter.
* @param {BFindUniqueArgs} args - Arguments to find a B
Expand Down Expand Up @@ -13886,13 +13880,13 @@ export namespace Prisma {
: C


type CCountArgs = Merge<
type CCountArgs =
Omit<CFindManyArgs, 'select' | 'include'> & {
select?: CCountAggregateInputType | true
}
>

export interface CDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one C that matches the filter.
* @param {CFindUniqueArgs} args - Arguments to find a C
Expand Down Expand Up @@ -14864,13 +14858,13 @@ export namespace Prisma {
: D


type DCountArgs = Merge<
type DCountArgs =
Omit<DFindManyArgs, 'select' | 'include'> & {
select?: DCountAggregateInputType | true
}
>

export interface DDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one D that matches the filter.
* @param {DFindUniqueArgs} args - Arguments to find a D
Expand Down Expand Up @@ -15796,13 +15790,13 @@ export namespace Prisma {
: E


type ECountArgs = Merge<
type ECountArgs =
Omit<EFindManyArgs, 'select' | 'include'> & {
select?: ECountAggregateInputType | true
}
>

export interface EDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined> {

/**
* Find zero or one E that matches the filter.
* @param {EFindUniqueArgs} args - Arguments to find a E
Expand Down