diff --git a/TODO.md b/TODO.md index 4a861b4f..9628cc16 100644 --- a/TODO.md +++ b/TODO.md @@ -3,13 +3,13 @@ - [ ] CLI - [x] generate - [x] migrate - - [ ] db + - [x] db - [x] push - - [ ] seed + - [x] seed - [x] info - [x] init - [x] validate - - [ ] format + - [x] format - [ ] repl - [x] plugin mechanism - [x] built-in plugins @@ -85,7 +85,7 @@ - [x] Error system - [x] Custom table name - [x] Custom field name - - [ ] Global omit + - [x] Global omit - [ ] DbNull vs JsonNull - [ ] Migrate to tsdown - [x] @default validation diff --git a/package.json b/package.json index 26be83f1..45ad3252 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "zenstack-v3", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack", - "packageManager": "pnpm@10.20.0", + "packageManager": "pnpm@10.23.0", "scripts": { "build": "turbo run build", "watch": "turbo run watch build", @@ -25,14 +25,14 @@ "eslint": "~9.29.0", "glob": "^11.0.2", "prettier": "^3.5.3", + "prisma": "catalog:", "tsup": "^8.5.0", "tsx": "^4.20.3", "turbo": "^2.5.4", "typescript": "catalog:", "typescript-eslint": "^8.34.1", "vitest": "^3.2.4", - "yaml": "^2.8.0", - "prisma": "catalog:" + "yaml": "^2.8.0" }, "pnpm": { "onlyBuiltDependencies": [ diff --git a/packages/auth-adapters/better-auth/package.json b/packages/auth-adapters/better-auth/package.json index dbad04eb..91b1878e 100644 --- a/packages/auth-adapters/better-auth/package.json +++ b/packages/auth-adapters/better-auth/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/better-auth", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack Better Auth Adapter. This adapter is modified from better-auth's Prisma adapter.", "type": "module", "scripts": { diff --git a/packages/cli/package.json b/packages/cli/package.json index 96b529d5..533a91cc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack CLI", "description": "FullStack database toolkit with built-in access control and automatic API generation.", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "type": "module", "author": { "name": "ZenStack Team" diff --git a/packages/clients/tanstack-query/package.json b/packages/clients/tanstack-query/package.json index 5a03f883..e00100f0 100644 --- a/packages/clients/tanstack-query/package.json +++ b/packages/clients/tanstack-query/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/tanstack-query", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "TanStack Query Client for consuming ZenStack v3's CRUD service", "main": "index.js", "type": "module", diff --git a/packages/clients/tanstack-query/src/react.ts b/packages/clients/tanstack-query/src/react.ts index 92af99b5..57b9cea2 100644 --- a/packages/clients/tanstack-query/src/react.ts +++ b/packages/clients/tanstack-query/src/react.ts @@ -24,6 +24,7 @@ import type { AggregateArgs, AggregateResult, BatchResult, + ClientOptions, CountArgs, CountResult, CreateArgs, @@ -128,11 +129,14 @@ export type ModelMutationModelResult< Model extends GetModels, TArgs, Array extends boolean = false, -> = Omit, TArgs>, 'mutateAsync'> & { +> = Omit< + ModelMutationResult, TArgs, false, Array>, TArgs>, + 'mutateAsync' +> & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions, T, false, Array>, T>, + ): Promise, T, false, Array>>; }; export type ClientHooks = { @@ -147,46 +151,50 @@ export type ModelQueryHooks>( args: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useSuspenseFindUnique>( args: SelectSubset>, - options?: ModelSuspenseQueryOptions | null>, - ): ModelSuspenseQueryResult | null>; + options?: ModelSuspenseQueryOptions, T> | null>, + ): ModelSuspenseQueryResult, T> | null>; useFindFirst>( args?: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useSuspenseFindFirst>( args?: SelectSubset>, - options?: ModelSuspenseQueryOptions | null>, - ): ModelSuspenseQueryResult | null>; + options?: ModelSuspenseQueryOptions, T> | null>, + ): ModelSuspenseQueryResult, T> | null>; useFindMany>( args?: SelectSubset>, - options?: ModelQueryOptions[]>, - ): ModelQueryResult[]>; + options?: ModelQueryOptions, T>[]>, + ): ModelQueryResult, T>[]>; useSuspenseFindMany>( args?: SelectSubset>, - options?: ModelSuspenseQueryOptions[]>, - ): ModelSuspenseQueryResult[]>; + options?: ModelSuspenseQueryOptions, T>[]>, + ): ModelSuspenseQueryResult, T>[]>; useInfiniteFindMany>( args?: SelectSubset>, - options?: ModelInfiniteQueryOptions[]>, - ): ModelInfiniteQueryResult[]>>; + options?: ModelInfiniteQueryOptions, T>[]>, + ): ModelInfiniteQueryResult, T>[]>>; useSuspenseInfiniteFindMany>( args?: SelectSubset>, - options?: ModelSuspenseInfiniteQueryOptions[]>, - ): ModelSuspenseInfiniteQueryResult[]>>; + options?: ModelSuspenseInfiniteQueryOptions< + SimplifiedModelResult, T>[] + >, + ): ModelSuspenseInfiniteQueryResult< + InfiniteData, T>[]> + >; useCreate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useCreateMany>( @@ -194,11 +202,11 @@ export type ModelQueryHooks; useCreateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpdate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useUpdateMany>( @@ -206,15 +214,15 @@ export type ModelQueryHooks; useUpdateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpsert>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDelete>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDeleteMany>( diff --git a/packages/clients/tanstack-query/src/svelte.ts b/packages/clients/tanstack-query/src/svelte.ts index 8b40750c..447b11dc 100644 --- a/packages/clients/tanstack-query/src/svelte.ts +++ b/packages/clients/tanstack-query/src/svelte.ts @@ -20,6 +20,7 @@ import type { AggregateArgs, AggregateResult, BatchResult, + ClientOptions, CountArgs, CountResult, CreateArgs, @@ -118,13 +119,18 @@ export type ModelMutationModelResult< Array extends boolean = false, > = Readable< Omit< - UnwrapStore, TArgs>>, + UnwrapStore< + ModelMutationResult, TArgs, false, Array>, TArgs> + >, 'mutateAsync' > & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions< + SimplifiedModelResult, T, false, Array>, + T + >, + ): Promise, T, false, Array>>; } >; @@ -140,26 +146,26 @@ export type ModelQueryHooks>( args: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useFindFirst>( args?: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useFindMany>( args?: SelectSubset>, - options?: ModelQueryOptions[]>, - ): ModelQueryResult[]>; + options?: ModelQueryOptions, T>[]>, + ): ModelQueryResult, T>[]>; useInfiniteFindMany>( args?: SelectSubset>, - options?: ModelInfiniteQueryOptions[]>, - ): ModelInfiniteQueryResult[]>>; + options?: ModelInfiniteQueryOptions, T>[]>, + ): ModelInfiniteQueryResult, T>[]>>; useCreate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useCreateMany>( @@ -167,11 +173,11 @@ export type ModelQueryHooks; useCreateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpdate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useUpdateMany>( @@ -179,15 +185,15 @@ export type ModelQueryHooks; useUpdateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpsert>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDelete>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDeleteMany>( diff --git a/packages/clients/tanstack-query/src/vue.ts b/packages/clients/tanstack-query/src/vue.ts index e5051426..6d0cec9b 100644 --- a/packages/clients/tanstack-query/src/vue.ts +++ b/packages/clients/tanstack-query/src/vue.ts @@ -18,6 +18,7 @@ import type { AggregateArgs, AggregateResult, BatchResult, + ClientOptions, CountArgs, CountResult, CreateArgs, @@ -105,11 +106,14 @@ export type ModelMutationModelResult< Model extends GetModels, TArgs, Array extends boolean = false, -> = Omit, TArgs>, 'mutateAsync'> & { +> = Omit< + ModelMutationResult, TArgs, false, Array>, TArgs>, + 'mutateAsync' +> & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions, T, false, Array>, T>, + ): Promise, T, false, Array>>; }; export type ClientHooks = { @@ -124,26 +128,26 @@ export type ModelQueryHooks>( args: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useFindFirst>( args?: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; + options?: ModelQueryOptions, T> | null>, + ): ModelQueryResult, T> | null>; useFindMany>( args?: SelectSubset>, - options?: ModelQueryOptions[]>, - ): ModelQueryResult[]>; + options?: ModelQueryOptions, T>[]>, + ): ModelQueryResult, T>[]>; useInfiniteFindMany>( args?: SelectSubset>, - options?: ModelInfiniteQueryOptions[]>, - ): ModelInfiniteQueryResult[]>>; + options?: ModelInfiniteQueryOptions, T>[]>, + ): ModelInfiniteQueryResult, T>[]>>; useCreate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useCreateMany>( @@ -151,11 +155,11 @@ export type ModelQueryHooks; useCreateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpdate>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useUpdateMany>( @@ -163,15 +167,15 @@ export type ModelQueryHooks; useUpdateManyAndReturn>( - options?: ModelMutationOptions[], T>, + options?: ModelMutationOptions, T>[], T>, ): ModelMutationModelResult; useUpsert>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDelete>( - options?: ModelMutationOptions, T>, + options?: ModelMutationOptions, T>, T>, ): ModelMutationModelResult; useDeleteMany>( diff --git a/packages/clients/tanstack-query/test/schemas/basic/input.ts b/packages/clients/tanstack-query/test/schemas/basic/input.ts index 755f3b2b..29cf7929 100644 --- a/packages/clients/tanstack-query/test/schemas/basic/input.ts +++ b/packages/clients/tanstack-query/test/schemas/basic/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema-lite"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -47,7 +47,7 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; export type CategoryFindManyArgs = $FindManyArgs<$Schema, "Category">; export type CategoryFindUniqueArgs = $FindUniqueArgs<$Schema, "Category">; export type CategoryFindFirstArgs = $FindFirstArgs<$Schema, "Category">; @@ -67,7 +67,7 @@ export type CategoryWhereInput = $WhereInput<$Schema, "Category">; export type CategorySelect = $SelectInput<$Schema, "Category">; export type CategoryInclude = $IncludeInput<$Schema, "Category">; export type CategoryOmit = $OmitInput<$Schema, "Category">; -export type CategoryGetPayload> = $SimplifiedModelResult<$Schema, "Category", Args>; +export type CategoryGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Category", Options, Args>; export type FooFindManyArgs = $FindManyArgs<$Schema, "Foo">; export type FooFindUniqueArgs = $FindUniqueArgs<$Schema, "Foo">; export type FooFindFirstArgs = $FindFirstArgs<$Schema, "Foo">; @@ -87,7 +87,7 @@ export type FooWhereInput = $WhereInput<$Schema, "Foo">; export type FooSelect = $SelectInput<$Schema, "Foo">; export type FooInclude = $IncludeInput<$Schema, "Foo">; export type FooOmit = $OmitInput<$Schema, "Foo">; -export type FooGetPayload> = $SimplifiedModelResult<$Schema, "Foo", Args>; +export type FooGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Foo", Options, Args>; export type BarFindManyArgs = $FindManyArgs<$Schema, "Bar">; export type BarFindUniqueArgs = $FindUniqueArgs<$Schema, "Bar">; export type BarFindFirstArgs = $FindFirstArgs<$Schema, "Bar">; @@ -107,4 +107,4 @@ export type BarWhereInput = $WhereInput<$Schema, "Bar">; export type BarSelect = $SelectInput<$Schema, "Bar">; export type BarInclude = $IncludeInput<$Schema, "Bar">; export type BarOmit = $OmitInput<$Schema, "Bar">; -export type BarGetPayload> = $SimplifiedModelResult<$Schema, "Bar", Args>; +export type BarGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Bar", Options, Args>; diff --git a/packages/common-helpers/package.json b/packages/common-helpers/package.json index 71ce651d..3020e8dc 100644 --- a/packages/common-helpers/package.json +++ b/packages/common-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/common-helpers", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack Common Helpers", "type": "module", "scripts": { diff --git a/packages/config/eslint-config/package.json b/packages/config/eslint-config/package.json index 8713714d..f95ca2fd 100644 --- a/packages/config/eslint-config/package.json +++ b/packages/config/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/eslint-config", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "type": "module", "private": true, "license": "MIT" diff --git a/packages/config/typescript-config/package.json b/packages/config/typescript-config/package.json index d005e4e7..5e4aa3bd 100644 --- a/packages/config/typescript-config/package.json +++ b/packages/config/typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/typescript-config", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "private": true, "license": "MIT" } diff --git a/packages/config/vitest-config/package.json b/packages/config/vitest-config/package.json index f0fdece6..9e3f0c47 100644 --- a/packages/config/vitest-config/package.json +++ b/packages/config/vitest-config/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/vitest-config", "type": "module", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "private": true, "license": "MIT", "exports": { diff --git a/packages/create-zenstack/package.json b/packages/create-zenstack/package.json index e68f0535..a17ebb75 100644 --- a/packages/create-zenstack/package.json +++ b/packages/create-zenstack/package.json @@ -1,6 +1,6 @@ { "name": "create-zenstack", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "Create a new ZenStack project", "type": "module", "scripts": { diff --git a/packages/language/package.json b/packages/language/package.json index dd3b8e0e..57438636 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/language", "description": "ZenStack ZModel language specification", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "license": "MIT", "author": "ZenStack Team", "files": [ diff --git a/packages/language/res/stdlib.zmodel b/packages/language/res/stdlib.zmodel index d3bef43b..bbeafb07 100644 --- a/packages/language/res/stdlib.zmodel +++ b/packages/language/res/stdlib.zmodel @@ -393,6 +393,13 @@ attribute @ignore() @@@prisma */ attribute @@ignore() @@@prisma +/** + * Indicates that the field should be omitted by default when read with an ORM client. The omission can be + * overridden in options passed to create `ZenStackClient`, or at query time by explicitly passing in an + * `omit` clause. The attribute is only effective for ORM query APIs, not for query-builder APIs. + */ +attribute @omit() + /** * Automatically stores the time when a record was last updated. */ diff --git a/packages/language/src/validators/function-invocation-validator.ts b/packages/language/src/validators/function-invocation-validator.ts index f4552743..a2ff34fd 100644 --- a/packages/language/src/validators/function-invocation-validator.ts +++ b/packages/language/src/validators/function-invocation-validator.ts @@ -179,6 +179,17 @@ export default class FunctionInvocationValidator implements AstValidator { @@ -184,10 +184,9 @@ export class ZModelScopeProvider extends DefaultScopeProvider { const globalScope = this.getGlobalScope(referenceType, context); const collection = collectionPredicate.left; - // TODO: generalize it + // TODO: full support of typedef member access // // typedef's fields are only added to the scope if the access starts with `auth().` - // const allowTypeDefScope = isAuthOrAuthMemberAccess(collection); - const allowTypeDefScope = false; + const allowTypeDefScope = isAuthOrAuthMemberAccess(collection); return match(collection) .when(isReferenceExpr, (expr) => { diff --git a/packages/orm/package.json b/packages/orm/package.json index 6bb619c0..40250acd 100644 --- a/packages/orm/package.json +++ b/packages/orm/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/orm", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack ORM", "type": "module", "scripts": { diff --git a/packages/orm/src/client/client-impl.ts b/packages/orm/src/client/client-impl.ts index 834aef79..8e2c8382 100644 --- a/packages/orm/src/client/client-impl.ts +++ b/packages/orm/src/client/client-impl.ts @@ -10,7 +10,7 @@ import { Transaction, type KyselyProps, } from 'kysely'; -import type { GetModels, ProcedureDef, SchemaDef } from '../schema'; +import type { ProcedureDef, SchemaDef } from '../schema'; import type { AnyKysely } from '../utils/kysely-utils'; import type { UnwrapTuplePromises } from '../utils/type-utils'; import type { @@ -38,7 +38,6 @@ import { SchemaDbPusher } from './helpers/schema-db-pusher'; import type { ClientOptions, ProceduresOptions } from './options'; import type { RuntimePlugin } from './plugin'; import { createZenStackPromise, type ZenStackPromise } from './promise'; -import type { ToKysely } from './query-builder'; import { ResultProcessor } from './result-processor'; /** @@ -49,21 +48,21 @@ export const ZenStackClient = function ( schema: Schema, options: ClientOptions, ) { - return new ClientImpl(schema, options); + return new ClientImpl(schema, options as ClientOptions); } as unknown as ClientConstructor; -export class ClientImpl { - private kysely: ToKysely; +export class ClientImpl { + private kysely: AnyKysely; private kyselyRaw: AnyKysely; - public readonly $options: ClientOptions; - public readonly $schema: Schema; + public readonly $options: ClientOptions; + public readonly $schema: SchemaDef; readonly kyselyProps: KyselyProps; - private auth: AuthType | undefined; + private auth: AuthType | undefined; constructor( - private readonly schema: Schema, - private options: ClientOptions, - baseClient?: ClientImpl, + private readonly schema: SchemaDef, + private options: ClientOptions, + baseClient?: ClientImpl, executor?: QueryExecutor, ) { this.$schema = schema; @@ -139,12 +138,12 @@ export class ClientImpl { // overload for interactive transaction $transaction( - callback: (tx: ClientContract) => Promise, + callback: (tx: ClientContract) => Promise, options?: { isolationLevel?: TransactionIsolationLevel }, ): Promise; // overload for sequential transaction - $transaction

[]>( + $transaction

[]>( arg: [...P], options?: { isolationLevel?: TransactionIsolationLevel }, ): Promise>; @@ -169,12 +168,12 @@ export class ClientImpl { } private async interactiveTransaction( - callback: (tx: ClientContract) => Promise, + callback: (tx: ClientContract) => Promise, options?: { isolationLevel?: TransactionIsolationLevel }, ): Promise { if (this.kysely.isTransaction) { // proceed directly if already in a transaction - return callback(this as unknown as ClientContract); + return callback(this as unknown as ClientContract); } else { // otherwise, create a new transaction, clone the client, and execute the callback let txBuilder = this.kysely.transaction(); @@ -182,23 +181,23 @@ export class ClientImpl { txBuilder = txBuilder.setIsolationLevel(options.isolationLevel); } return txBuilder.execute((tx) => { - const txClient = new ClientImpl(this.schema, this.$options, this); + const txClient = new ClientImpl(this.schema, this.$options, this); txClient.kysely = tx; - return callback(txClient as unknown as ClientContract); + return callback(txClient as unknown as ClientContract); }); } } private async sequentialTransaction( - arg: ZenStackPromise[], + arg: ZenStackPromise[], options?: { isolationLevel?: TransactionIsolationLevel }, ) { const execute = async (tx: AnyKysely) => { - const txClient = new ClientImpl(this.schema, this.$options, this); + const txClient = new ClientImpl(this.schema, this.$options, this); txClient.kysely = tx; const result: any[] = []; for (const promise of arg) { - result.push(await promise.cb(txClient as unknown as ClientContract)); + result.push(await promise.cb(txClient as unknown as ClientContract)); } return result; }; @@ -228,7 +227,7 @@ export class ClientImpl { } const procOptions = this.$options.procedures as ProceduresOptions< - Schema & { + SchemaDef & { procedures: Record; } >; @@ -253,45 +252,45 @@ export class ClientImpl { await new SchemaDbPusher(this.schema, this.kysely).push(); } - $use(plugin: RuntimePlugin) { + $use(plugin: RuntimePlugin) { // tsc perf - const newPlugins: RuntimePlugin[] = [...(this.$options.plugins ?? []), plugin]; - const newOptions: ClientOptions = { + const newPlugins: RuntimePlugin[] = [...(this.$options.plugins ?? []), plugin]; + const newOptions: ClientOptions = { ...this.options, plugins: newPlugins, }; - return new ClientImpl(this.schema, newOptions, this); + return new ClientImpl(this.schema, newOptions, this); } $unuse(pluginId: string) { // tsc perf - const newPlugins: RuntimePlugin[] = []; + const newPlugins: RuntimePlugin[] = []; for (const plugin of this.options.plugins ?? []) { if (plugin.id !== pluginId) { newPlugins.push(plugin); } } - const newOptions: ClientOptions = { + const newOptions: ClientOptions = { ...this.options, plugins: newPlugins, }; - return new ClientImpl(this.schema, newOptions, this); + return new ClientImpl(this.schema, newOptions, this); } $unuseAll() { // tsc perf - const newOptions: ClientOptions = { + const newOptions: ClientOptions = { ...this.options, - plugins: [] as RuntimePlugin[], + plugins: [] as RuntimePlugin[], }; - return new ClientImpl(this.schema, newOptions, this); + return new ClientImpl(this.schema, newOptions, this); } - $setAuth(auth: AuthType | undefined) { + $setAuth(auth: AuthType | undefined) { if (auth !== undefined && typeof auth !== 'object') { throw new Error('Invalid auth object'); } - const newClient = new ClientImpl(this.schema, this.$options, this); + const newClient = new ClientImpl(this.schema, this.$options, this); newClient.auth = auth; return newClient; } @@ -300,12 +299,19 @@ export class ClientImpl { return this.auth; } + $setOptions>(options: Options): ClientContract { + return new ClientImpl(this.schema, options as ClientOptions, this) as unknown as ClientContract< + SchemaDef, + Options + >; + } + $setInputValidation(enable: boolean) { - const newOptions: ClientOptions = { + const newOptions: ClientOptions = { ...this.options, validateInput: enable, }; - return new ClientImpl(this.schema, newOptions, this); + return new ClientImpl(this.schema, newOptions, this); } $executeRaw(query: TemplateStringsArray, ...values: any[]) { @@ -344,8 +350,8 @@ export class ClientImpl { } } -function createClientProxy(client: ClientImpl): ClientImpl { - const inputValidator = new InputValidator(client as unknown as ClientContract); +function createClientProxy(client: ClientImpl): ClientImpl { + const inputValidator = new InputValidator(client as any); const resultProcessor = new ResultProcessor(client.$schema, client.$options); return new Proxy(client, { @@ -357,35 +363,30 @@ function createClientProxy(client: ClientImpl) if (typeof prop === 'string') { const model = Object.keys(client.$schema.models).find((m) => m.toLowerCase() === prop.toLowerCase()); if (model) { - return createModelCrudHandler( - client as unknown as ClientContract, - model as GetModels, - inputValidator, - resultProcessor, - ); + return createModelCrudHandler(client as any, model, inputValidator, resultProcessor); } } return Reflect.get(target, prop, receiver); }, - }) as unknown as ClientImpl; + }) as unknown as ClientImpl; } -function createModelCrudHandler>( - client: ClientContract, - model: Model, - inputValidator: InputValidator, - resultProcessor: ResultProcessor, -): ModelOperations { +function createModelCrudHandler( + client: ClientContract, + model: string, + inputValidator: InputValidator, + resultProcessor: ResultProcessor, +): ModelOperations { const createPromise = ( operation: CoreCrudOperation, nominalOperation: AllCrudOperation, args: unknown, - handler: BaseOperationHandler, + handler: BaseOperationHandler, postProcess = false, throwIfNoResult = false, ) => { - return createZenStackPromise(async (txClient?: ClientContract) => { + return createZenStackPromise(async (txClient?: ClientContract) => { let proceed = async (_args: unknown) => { const _handler = txClient ? handler.withClient(txClient) : handler; const r = await _handler.handle(operation, _args); @@ -431,7 +432,7 @@ function createModelCrudHandler(client, model, inputValidator), + new FindOperationHandler(client, model, inputValidator), true, ); }, @@ -441,7 +442,7 @@ function createModelCrudHandler(client, model, inputValidator), + new FindOperationHandler(client, model, inputValidator), true, true, ); @@ -452,7 +453,7 @@ function createModelCrudHandler(client, model, inputValidator), + new FindOperationHandler(client, model, inputValidator), true, ); }, @@ -462,7 +463,7 @@ function createModelCrudHandler(client, model, inputValidator), + new FindOperationHandler(client, model, inputValidator), true, true, ); @@ -473,7 +474,7 @@ function createModelCrudHandler(client, model, inputValidator), + new FindOperationHandler(client, model, inputValidator), true, ); }, @@ -483,7 +484,7 @@ function createModelCrudHandler(client, model, inputValidator), + new CreateOperationHandler(client, model, inputValidator), true, ); }, @@ -493,7 +494,7 @@ function createModelCrudHandler(client, model, inputValidator), + new CreateOperationHandler(client, model, inputValidator), false, ); }, @@ -503,7 +504,7 @@ function createModelCrudHandler(client, model, inputValidator), + new CreateOperationHandler(client, model, inputValidator), true, ); }, @@ -513,7 +514,7 @@ function createModelCrudHandler(client, model, inputValidator), + new UpdateOperationHandler(client, model, inputValidator), true, ); }, @@ -523,7 +524,7 @@ function createModelCrudHandler(client, model, inputValidator), + new UpdateOperationHandler(client, model, inputValidator), false, ); }, @@ -533,7 +534,7 @@ function createModelCrudHandler(client, model, inputValidator), + new UpdateOperationHandler(client, model, inputValidator), true, ); }, @@ -543,7 +544,7 @@ function createModelCrudHandler(client, model, inputValidator), + new UpdateOperationHandler(client, model, inputValidator), true, ); }, @@ -553,7 +554,7 @@ function createModelCrudHandler(client, model, inputValidator), + new DeleteOperationHandler(client, model, inputValidator), true, ); }, @@ -563,7 +564,7 @@ function createModelCrudHandler(client, model, inputValidator), + new DeleteOperationHandler(client, model, inputValidator), false, ); }, @@ -573,7 +574,7 @@ function createModelCrudHandler(client, model, inputValidator), + new CountOperationHandler(client, model, inputValidator), false, ); }, @@ -583,7 +584,7 @@ function createModelCrudHandler(client, model, inputValidator), + new AggregateOperationHandler(client, model, inputValidator), false, ); }, @@ -593,9 +594,9 @@ function createModelCrudHandler(client, model, inputValidator), + new GroupByOperationHandler(client, model, inputValidator), true, ); }, - } as ModelOperations; + } as ModelOperations; } diff --git a/packages/orm/src/client/contract.ts b/packages/orm/src/client/contract.ts index 4ef52dd5..57cd9b05 100644 --- a/packages/orm/src/client/contract.ts +++ b/packages/orm/src/client/contract.ts @@ -2,6 +2,7 @@ import type Decimal from 'decimal.js'; import { type FieldIsArray, type GetModels, + type GetTypeDefs, type IsDelegateModel, type ProcedureDef, type RelationFields, @@ -32,6 +33,7 @@ import type { SelectSubset, SimplifiedModelResult, Subset, + TypeDefResult, UpdateArgs, UpdateManyAndReturnArgs, UpdateManyArgs, @@ -58,13 +60,16 @@ export enum TransactionIsolationLevel { /** * ZenStack client interface. */ -export type ClientContract = { +export type ClientContract = ClientOptions> = { + /** + * The schema definition. + */ readonly $schema: Schema; /** * The client options. */ - readonly $options: ClientOptions; + readonly $options: Options; /** * Executes a prepared raw query and returns the number of affected rows. @@ -112,13 +117,24 @@ export type ClientContract = { /** * Sets the current user identity. */ - $setAuth(auth: AuthType | undefined): ClientContract; + $setAuth(auth: AuthType | undefined): ClientContract; + + /** + * Returns a new client with new options applied. + * @example + * ``` + * const dbNoValidation = db.$setOptions({ ...db.$options, validateInput: false }); + * ``` + */ + $setOptions>(options: Options): ClientContract; /** * Returns a new client enabling/disabling input validations expressed with attributes like * `@email`, `@regex`, `@@validate`, etc. + * + * @deprecated Use `$setOptions` instead. */ - $setInputValidation(enable: boolean): ClientContract; + $setInputValidation(enable: boolean): ClientContract; /** * The Kysely query builder instance. @@ -134,7 +150,7 @@ export type ClientContract = { * Starts an interactive transaction. */ $transaction( - callback: (tx: Omit, TransactionUnsupportedMethods>) => Promise, + callback: (tx: Omit, TransactionUnsupportedMethods>) => Promise, options?: { isolationLevel?: TransactionIsolationLevel }, ): Promise; @@ -149,17 +165,17 @@ export type ClientContract = { /** * Returns a new client with the specified plugin installed. */ - $use(plugin: RuntimePlugin): ClientContract; + $use(plugin: RuntimePlugin): ClientContract; /** * Returns a new client with the specified plugin removed. */ - $unuse(pluginId: string): ClientContract; + $unuse(pluginId: string): ClientContract; /** * Returns a new client with all plugins removed. */ - $unuseAll(): ClientContract; + $unuseAll(): ClientContract; /** * Eagerly connects to the database. @@ -177,14 +193,14 @@ export type ClientContract = { */ $pushSchema(): Promise; } & { - [Key in GetModels as Uncapitalize]: ModelOperations; + [Key in GetModels as Uncapitalize]: ModelOperations; } & Procedures; /** * The contract for a client in a transaction. */ -export type TransactionClientContract = Omit< - ClientContract, +export type TransactionClientContract> = Omit< + ClientContract, TransactionUnsupportedMethods >; @@ -227,7 +243,10 @@ type MapProcedureParams = { * Creates a new ZenStack client instance. */ export interface ClientConstructor { - new (schema: Schema, options: ClientOptions): ClientContract; + new >( + schema: Schema, + options: Options, + ): ClientContract; } /** @@ -252,7 +271,11 @@ export const CRUD_EXT = [...CRUD, 'post-update'] as const; //#region Model operations -export type AllModelOperations> = { +export type AllModelOperations< + Schema extends SchemaDef, + Model extends GetModels, + Options extends ClientOptions, +> = { /** * Returns a list of entities. * @param args - query args @@ -336,7 +359,7 @@ export type AllModelOperations>( args?: SelectSubset>, - ): ZenStackPromise[]>; + ): ZenStackPromise[]>; /** * Returns a uniquely identified entity. @@ -346,7 +369,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise | null>; + ): ZenStackPromise | null>; /** * Returns a uniquely identified entity or throws `NotFoundError` if not found. @@ -356,7 +379,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Returns the first entity. @@ -366,7 +389,7 @@ export type AllModelOperations>( args?: SelectSubset>, - ): ZenStackPromise | null>; + ): ZenStackPromise | null>; /** * Returns the first entity or throws `NotFoundError` if not found. @@ -376,7 +399,7 @@ export type AllModelOperations>( args?: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Creates a new entity. @@ -432,7 +455,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Creates multiple entities. Only scalar fields are allowed. @@ -483,7 +506,7 @@ export type AllModelOperations>( args?: SelectSubset>, - ): ZenStackPromise[]>; + ): ZenStackPromise[]>; /** * Updates a uniquely identified entity. @@ -604,7 +627,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Updates multiple entities. @@ -654,7 +677,7 @@ export type AllModelOperations>( args: Subset>, - ): ZenStackPromise[]>; + ): ZenStackPromise[]>; /** * Creates or updates an entity. @@ -678,7 +701,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Deletes a uniquely identifiable entity. @@ -701,7 +724,7 @@ export type AllModelOperations>( args: SelectSubset>, - ): ZenStackPromise>; + ): ZenStackPromise>; /** * Deletes multiple entities. @@ -809,8 +832,12 @@ export type AllModelOperations> = Omit< - AllModelOperations, +export type ModelOperations< + Schema extends SchemaDef, + Model extends GetModels, + Options extends ClientOptions = ClientOptions, +> = Omit< + AllModelOperations, // exclude operations not applicable to delegate models IsDelegateModel extends true ? OperationsIneligibleForDelegateModels : never >; @@ -824,7 +851,7 @@ export type ModelOperations> = Partial< - DefaultModelResult + DefaultModelResult> > & { [Key in RelationFields]?: FieldIsArray extends true ? AuthModelType>[] @@ -832,10 +859,10 @@ type AuthModelType> = }; export type AuthType = - string extends GetModels - ? Record - : Schema['authType'] extends GetModels - ? AuthModelType - : never; + Schema['authType'] extends GetModels + ? AuthModelType + : Schema['authType'] extends GetTypeDefs + ? TypeDefResult + : Record; //#endregion diff --git a/packages/orm/src/client/crud-types.ts b/packages/orm/src/client/crud-types.ts index 6fe3f076..55e3edfd 100644 --- a/packages/orm/src/client/crud-types.ts +++ b/packages/orm/src/client/crud-types.ts @@ -38,11 +38,13 @@ import type { NullableIf, Optional, OrArray, + PartialIf, Simplify, ValueOfPotentialTuple, WrapType, XOR, } from '../utils/type-utils'; +import type { ClientOptions } from './options'; import type { ToKyselySchema } from './query-builder'; //#region Query results @@ -50,34 +52,86 @@ import type { ToKyselySchema } from './query-builder'; export type DefaultModelResult< Schema extends SchemaDef, Model extends GetModels, + Options extends ClientOptions = ClientOptions, Omit = undefined, Optional = false, Array = false, > = WrapType< IsDelegateModel extends true ? // delegate model's selection result is a union of all sub-models - DelegateUnionResult, Omit> + DelegateUnionResult, Omit> : { - [Key in NonRelationFields as Key extends keyof Omit - ? Omit[Key] extends true - ? never - : Key + [Key in NonRelationFields as ShouldOmitField< + Schema, + Model, + Options, + Key, + Omit + > extends true + ? never : Key]: MapModelFieldType; }, Optional, Array >; +// precedence: query-level omit > options-level omit > schema-level omit +type ShouldOmitField< + Schema extends SchemaDef, + Model extends GetModels, + Options extends ClientOptions, + Field extends GetModelFields, + Omit, +> = + QueryLevelOmit extends boolean + ? QueryLevelOmit + : OptionsLevelOmit extends boolean + ? OptionsLevelOmit + : SchemaLevelOmit; + +type QueryLevelOmit< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, + Omit, +> = Field extends keyof Omit ? (Omit[Field] extends boolean ? Omit[Field] : undefined) : undefined; + +type OptionsLevelOmit< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, + Options extends ClientOptions, +> = Model extends keyof Options['omit'] + ? Field extends keyof Options['omit'][Model] + ? Options['omit'][Model][Field] extends boolean + ? Options['omit'][Model][Field] + : undefined + : undefined + : undefined; + +type SchemaLevelOmit< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, +> = GetModelField['omit'] extends true ? true : false; + type DelegateUnionResult< Schema extends SchemaDef, Model extends GetModels, + Options extends ClientOptions, SubModel extends GetModels, Omit = undefined, > = SubModel extends string // typescript union distribution - ? DefaultModelResult & { [K in GetModelDiscriminator]: SubModel } // fixate discriminated field + ? DefaultModelResult & { [K in GetModelDiscriminator]: SubModel } // fixate discriminated field : never; -type ModelSelectResult, Select, Omit> = { +type ModelSelectResult< + Schema extends SchemaDef, + Model extends GetModels, + Options extends ClientOptions, + Select, + Omit, +> = { [Key in keyof Select as Select[Key] extends false | undefined ? never : Key extends keyof Omit @@ -102,6 +156,7 @@ type ModelSelectResult ? ModelResult< Schema, RelationFieldType, + Options, Pick, ModelFieldIsOptional, FieldIsArray @@ -109,6 +164,7 @@ type ModelSelectResult : ModelResult< Schema, RelationFieldType, + Options, Pick, ModelFieldIsOptional, FieldIsArray @@ -116,6 +172,7 @@ type ModelSelectResult : DefaultModelResult< Schema, RelationFieldType, + Options, Omit, ModelFieldIsOptional, FieldIsArray @@ -135,6 +192,7 @@ type SelectCountResult export type ModelResult< Schema extends SchemaDef, Model extends GetModels, + Options extends ClientOptions = ClientOptions, Args = {}, Optional = false, Array = false, @@ -143,12 +201,12 @@ export type ModelResult< select: infer S; omit?: infer O; } - ? ModelSelectResult + ? ModelSelectResult : Args extends { include: infer I; omit?: infer O; } - ? DefaultModelResult & { + ? DefaultModelResult & { [Key in keyof I & RelationFields as I[Key] extends false | undefined ? never : Key]: I[Key] extends FindArgs< @@ -159,6 +217,7 @@ export type ModelResult< ? ModelResult< Schema, RelationFieldType, + Options, I[Key], ModelFieldIsOptional, FieldIsArray @@ -166,14 +225,15 @@ export type ModelResult< : DefaultModelResult< Schema, RelationFieldType, + Options, undefined, ModelFieldIsOptional, FieldIsArray >; } : Args extends { omit: infer O } - ? DefaultModelResult - : DefaultModelResult, + ? DefaultModelResult + : DefaultModelResult, Optional, Array >; @@ -181,22 +241,37 @@ export type ModelResult< export type SimplifiedModelResult< Schema extends SchemaDef, Model extends GetModels, + Options extends ClientOptions, Args = {}, Optional = false, Array = false, -> = Simplify>; +> = Simplify>; -export type TypeDefResult> = Optional< - { - [Key in GetTypeDefFields]: MapTypeDefFieldType; - }, - // optionality - keyof { - [Key in GetTypeDefFields as TypeDefFieldIsOptional extends true - ? Key - : never]: true; - } ->; +export type TypeDefResult< + Schema extends SchemaDef, + TypeDef extends GetTypeDefs, + Partial extends boolean = false, +> = PartialIf< + Optional< + { + [Key in GetTypeDefFields]: MapFieldDefType< + Schema, + GetTypeDefField, + Partial + >; + }, + // optionality + Partial extends true + ? never + : keyof { + [Key in GetTypeDefFields as TypeDefFieldIsOptional extends true + ? Key + : never]: true; + } + >, + Partial +> & + Record; export type BatchResult = { count: number }; @@ -557,17 +632,15 @@ type MapModelFieldType< Field extends GetModelFields, > = MapFieldDefType>; -type MapTypeDefFieldType< +type MapFieldDefType< Schema extends SchemaDef, - TypeDef extends GetTypeDefs, - Field extends GetTypeDefFields, -> = MapFieldDefType>; - -type MapFieldDefType> = WrapType< + T extends Pick, + Partial extends boolean = false, +> = WrapType< T['type'] extends GetEnums ? keyof GetEnum : T['type'] extends GetTypeDefs - ? TypeDefResult & Record + ? TypeDefResult & Record : MapBaseType, T['optional'], T['array'] diff --git a/packages/orm/src/client/crud/dialects/base-dialect.ts b/packages/orm/src/client/crud/dialects/base-dialect.ts index 2b96941e..42af09d2 100644 --- a/packages/orm/src/client/crud/dialects/base-dialect.ts +++ b/packages/orm/src/client/crud/dialects/base-dialect.ts @@ -873,7 +873,7 @@ export abstract class BaseCrudDialect { if (isRelationField(this.schema, model, field)) { continue; } - if (omit?.[field] === true) { + if (this.shouldOmitField(omit, model, field)) { continue; } result = this.buildSelectField(result, model, modelAlias, field); @@ -901,6 +901,26 @@ export abstract class BaseCrudDialect { return result; } + shouldOmitField(omit: unknown, model: string, field: string) { + // query-level + if (omit && typeof omit === 'object' && typeof (omit as any)[field] === 'boolean') { + return (omit as any)[field]; + } + + // options-level + if ( + this.options.omit?.[model] && + typeof this.options.omit[model] === 'object' && + typeof (this.options.omit[model] as any)[field] === 'boolean' + ) { + return (this.options.omit[model] as any)[field]; + } + + // schema-level + const fieldDef = requireField(this.schema, model, field); + return !!fieldDef.omit; + } + protected buildModelSelect( model: GetModels, subQueryAlias: string, diff --git a/packages/orm/src/client/crud/dialects/postgresql.ts b/packages/orm/src/client/crud/dialects/postgresql.ts index a37e603b..660356dd 100644 --- a/packages/orm/src/client/crud/dialects/postgresql.ts +++ b/packages/orm/src/client/crud/dialects/postgresql.ts @@ -12,6 +12,7 @@ import { match } from 'ts-pattern'; import type { BuiltinType, FieldDef, GetModels, SchemaDef } from '../../../schema'; import { DELEGATE_JOINED_FIELD_PREFIX } from '../../constants'; import type { FindArgs } from '../../crud-types'; +import { createInternalError } from '../../errors'; import type { ClientOptions } from '../../options'; import { buildJoinPairs, @@ -23,7 +24,6 @@ import { requireModel, } from '../../query-utils'; import { BaseCrudDialect } from './base-dialect'; -import { createInternalError } from '../../errors'; export class PostgresCrudDialect extends BaseCrudDialect { constructor(schema: Schema, options: ClientOptions) { @@ -305,11 +305,12 @@ export class PostgresCrudDialect extends BaseCrudDiale } if (payload === true || !payload.select) { - // select all scalar fields + // select all scalar fields except for omitted + const omit = typeof payload === 'object' ? payload.omit : undefined; objArgs.push( ...Object.entries(relationModelDef.fields) .filter(([, value]) => !value.relation) - .filter(([name]) => !(typeof payload === 'object' && (payload.omit as any)?.[name] === true)) + .filter(([name]) => !this.shouldOmitField(omit, relationModel, name)) .map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, relationModelAlias, false)]) .flatMap((v) => v), ); diff --git a/packages/orm/src/client/crud/dialects/sqlite.ts b/packages/orm/src/client/crud/dialects/sqlite.ts index 464e30dc..04b22d03 100644 --- a/packages/orm/src/client/crud/dialects/sqlite.ts +++ b/packages/orm/src/client/crud/dialects/sqlite.ts @@ -198,11 +198,12 @@ export class SqliteCrudDialect extends BaseCrudDialect } if (payload === true || !payload.select) { - // select all scalar fields + // select all scalar fields except for omitted + const omit = typeof payload === 'object' ? payload.omit : undefined; objArgs.push( ...Object.entries(relationModelDef.fields) .filter(([, value]) => !value.relation) - .filter(([name]) => !(typeof payload === 'object' && (payload.omit as any)?.[name] === true)) + .filter(([name]) => !this.shouldOmitField(omit, relationModel, name)) .map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, subQueryName, false)]) .flatMap((v) => v), ); diff --git a/packages/orm/src/client/crud/operations/base.ts b/packages/orm/src/client/crud/operations/base.ts index ce788831..f5fbca54 100644 --- a/packages/orm/src/client/crud/operations/base.ts +++ b/packages/orm/src/client/crud/operations/base.ts @@ -2141,20 +2141,21 @@ export abstract class BaseOperationHandler { const computedFields = Object.values(modelDef.fields) .filter((f) => f.computed) .map((f) => f.name); - const omit = Object.entries(args.omit ?? {}) - .filter(([, v]) => v) - .map(([k]) => k); const allFieldsSelected: string[] = []; if (!args.select || typeof args.select !== 'object') { // all non-relation fields selected - allFieldsSelected.push(...allFields.filter((f) => !relationFields.includes(f) && !omit.includes(f))); + allFieldsSelected.push( + ...allFields.filter( + (f) => !relationFields.includes(f) && !this.dialect.shouldOmitField(args.omit, model, f), + ), + ); } else { // explicit select allFieldsSelected.push( ...Object.entries(args.select) - .filter(([k, v]) => v && !omit.includes(k)) + .filter(([k, v]) => v && !this.dialect.shouldOmitField(args.omit, model, k)) .map(([k]) => k), ); } diff --git a/packages/orm/src/client/crud/validator/index.ts b/packages/orm/src/client/crud/validator/index.ts index 4be44346..30032224 100644 --- a/packages/orm/src/client/crud/validator/index.ts +++ b/packages/orm/src/client/crud/validator/index.ts @@ -61,6 +61,10 @@ export class InputValidator { return this.client.$schema; } + private get options() { + return this.client.$options; + } + private get extraValidationsEnabled() { return this.client.$options.validateInput !== false; } @@ -783,7 +787,13 @@ export class InputValidator { for (const field of Object.keys(modelDef.fields)) { const fieldDef = requireField(this.schema, model, field); if (!fieldDef.relation) { - fields[field] = z.boolean().optional(); + if (this.options.allowQueryTimeOmitOverride !== false) { + // if override is allowed, use boolean + fields[field] = z.boolean().optional(); + } else { + // otherwise only allow true + fields[field] = z.literal(true).optional(); + } } } return z.strictObject(fields); @@ -1302,6 +1312,7 @@ export class InputValidator { where: this.makeWhereSchema(model, true), select: this.makeSelectSchema(model).optional().nullable(), include: this.makeIncludeSchema(model).optional().nullable(), + omit: this.makeOmitSchema(model).optional().nullable(), }); schema = this.refineForSelectIncludeMutuallyExclusive(schema); schema = this.refineForSelectOmitMutuallyExclusive(schema); diff --git a/packages/orm/src/client/executor/zenstack-query-executor.ts b/packages/orm/src/client/executor/zenstack-query-executor.ts index 06f8d133..201c3229 100644 --- a/packages/orm/src/client/executor/zenstack-query-executor.ts +++ b/packages/orm/src/client/executor/zenstack-query-executor.ts @@ -24,7 +24,7 @@ import { type RootOperationNode, } from 'kysely'; import { match } from 'ts-pattern'; -import type { GetModels, ModelDef, SchemaDef, TypeDefDef } from '../../schema'; +import type { ModelDef, SchemaDef, TypeDefDef } from '../../schema'; import { type ClientImpl } from '../client-impl'; import { TransactionIsolationLevel, type ClientContract } from '../contract'; import { createDBQueryError, createInternalError, ORMError } from '../errors'; @@ -35,17 +35,17 @@ import type { ZenStackDriver } from './zenstack-driver'; type MutationQueryNode = InsertQueryNode | UpdateQueryNode | DeleteQueryNode; -type MutationInfo = { - model: GetModels; +type MutationInfo = { + model: string; action: 'create' | 'update' | 'delete'; where: WhereNode | undefined; }; -export class ZenStackQueryExecutor extends DefaultQueryExecutor { +export class ZenStackQueryExecutor extends DefaultQueryExecutor { private readonly nameMapper: QueryNameMapper | undefined; constructor( - private client: ClientImpl, + private client: ClientImpl, private readonly driver: ZenStackDriver, private readonly compiler: QueryCompiler, adapter: DialectAdapter, @@ -63,7 +63,7 @@ export class ZenStackQueryExecutor extends DefaultQuer } } - private schemaHasMappedNames(schema: Schema) { + private schemaHasMappedNames(schema: SchemaDef) { const hasMapAttr = (decl: ModelDef | TypeDefDef) => { if (decl.attributes?.some((attr) => attr.name === '@@map')) { return true; @@ -134,7 +134,7 @@ export class ZenStackQueryExecutor extends DefaultQuer ) { let proceed = (q: RootOperationNode) => this.proceedQuery(connection, q, parameters, queryId); - const hooks: OnKyselyQueryCallback[] = []; + const hooks: OnKyselyQueryCallback[] = []; // tsc perf for (const plugin of this.client.$options.plugins ?? []) { if (plugin.onKyselyQuery) { @@ -147,7 +147,7 @@ export class ZenStackQueryExecutor extends DefaultQuer proceed = async (query: RootOperationNode) => { const _p = (q: RootOperationNode) => _proceed(q); const hookResult = await hook!({ - client: this.client as ClientContract, + client: this.client as unknown as ClientContract, schema: this.client.$schema, query, proceed: _p, @@ -161,7 +161,7 @@ export class ZenStackQueryExecutor extends DefaultQuer return result; } - private getMutationInfo(queryNode: MutationQueryNode): MutationInfo { + private getMutationInfo(queryNode: MutationQueryNode): MutationInfo { const model = this.getMutationModel(queryNode); const { action, where } = match(queryNode) .when(InsertQueryNode.is, () => ({ @@ -275,7 +275,7 @@ export class ZenStackQueryExecutor extends DefaultQuer if (inTx) { innerClient.forceTransaction(); } - return innerClient as ClientContract; + return innerClient as unknown as ClientContract; } private get hasEntityMutationPlugins() { @@ -353,7 +353,7 @@ export class ZenStackQueryExecutor extends DefaultQuer return newExecutor; } - private getMutationModel(queryNode: OperationNode): GetModels { + private getMutationModel(queryNode: OperationNode): string { return match(queryNode) .when(InsertQueryNode.is, (node) => { invariant(node.into, 'InsertQueryNode must have an into clause'); @@ -373,14 +373,14 @@ export class ZenStackQueryExecutor extends DefaultQuer }) .otherwise((node) => { throw createInternalError(`Invalid query node: ${node}`); - }) as GetModels; + }) as string; } private async callBeforeMutationHooks( queryNode: OperationNode, - mutationInfo: MutationInfo, + mutationInfo: MutationInfo, loadBeforeMutationEntities: () => Promise[] | undefined>, - client: ClientContract, + client: ClientContract, queryId: QueryId, ) { if (this.options.plugins) { @@ -405,12 +405,12 @@ export class ZenStackQueryExecutor extends DefaultQuer private async callAfterMutationHooks( queryResult: QueryResult, queryNode: OperationNode, - mutationInfo: MutationInfo, - client: ClientContract, + mutationInfo: MutationInfo, + client: ClientContract, filterFor: 'inTx' | 'outTx' | 'all', queryId: QueryId, ) { - const hooks: AfterEntityMutationCallback[] = []; + const hooks: AfterEntityMutationCallback[] = []; // tsc perf for (const plugin of this.options.plugins ?? []) { @@ -457,7 +457,7 @@ export class ZenStackQueryExecutor extends DefaultQuer } private async loadEntities( - model: GetModels, + model: string, where: WhereNode | undefined, connection: DatabaseConnection, ): Promise[]> { diff --git a/packages/orm/src/client/options.ts b/packages/orm/src/client/options.ts index 2f6f7af7..ed2f9512 100644 --- a/packages/orm/src/client/options.ts +++ b/packages/orm/src/client/options.ts @@ -1,5 +1,5 @@ import type { Dialect, Expression, ExpressionBuilder, KyselyConfig } from 'kysely'; -import type { GetModel, GetModels, ProcedureDef, SchemaDef } from '../schema'; +import type { GetModel, GetModelFields, GetModels, ProcedureDef, ScalarFields, SchemaDef } from '../schema'; import type { PrependParameter } from '../utils/type-utils'; import type { ClientContract, CRUD_EXT, ProcedureFunc } from './contract'; import type { BaseCrudDialect } from './crud/dialects/base-dialect'; @@ -78,6 +78,18 @@ export type ClientOptions = { * `@@validate`, etc. Defaults to `true`. */ validateInput?: boolean; + + /** + * Options for omitting fields in ORM query results. + */ + omit?: OmitOptions; + + /** + * Whether to allow overriding omit settings at query time. Defaults to `true`. When set to + * `false`, an `omit` clause that sets field to `false` (not omitting) will trigger a validation + * error. + */ + allowQueryTimeOmitOverride?: boolean; } & (HasComputedFields extends true ? { /** @@ -95,6 +107,15 @@ export type ClientOptions = { } : {}); +/** + * Options for omitting fields in ORM query results. + */ +export type OmitOptions = { + [Model in GetModels]?: { + [Field in GetModelFields as Field extends ScalarFields ? Field : never]?: boolean; + }; +}; + export type ComputedFieldsOptions = { [Model in GetModels as 'computedFields' extends keyof GetModel ? Model : never]: { [Field in keyof Schema['models'][Model]['computedFields']]: PrependParameter< diff --git a/packages/orm/src/client/promise.ts b/packages/orm/src/client/promise.ts index f3c261a1..0f389932 100644 --- a/packages/orm/src/client/promise.ts +++ b/packages/orm/src/client/promise.ts @@ -16,16 +16,16 @@ export type ZenStackPromise = Promise & { * Creates a promise that only executes when it's awaited or .then() is called. * @see https://github.com/prisma/prisma/blob/main/packages/client/src/runtime/core/request/createPrismaPromise.ts */ -export function createZenStackPromise( - callback: (txClient?: ClientContract) => Promise, -): ZenStackPromise { - let promise: Promise | undefined; - const cb = (txClient?: ClientContract) => { +export function createZenStackPromise( + callback: (txClient?: ClientContract) => Promise, +): ZenStackPromise { + let promise: Promise | undefined; + const cb = (txClient?: ClientContract) => { try { return (promise ??= valueToPromise(callback(txClient))); } catch (err) { // deal with synchronous errors - return Promise.reject(err); + return Promise.reject(err); } }; diff --git a/packages/orm/src/utils/schema-utils.ts b/packages/orm/src/utils/schema-utils.ts index 8c0824d4..b928b078 100644 --- a/packages/orm/src/utils/schema-utils.ts +++ b/packages/orm/src/utils/schema-utils.ts @@ -12,9 +12,11 @@ import type { UnaryExpression, } from '../schema'; +export type VisitResult = void | { abort: true }; + export class ExpressionVisitor { - visit(expr: Expression): void { - match(expr) + visit(expr: Expression): VisitResult { + return match(expr) .with({ kind: 'literal' }, (e) => this.visitLiteral(e)) .with({ kind: 'array' }, (e) => this.visitArray(e)) .with({ kind: 'field' }, (e) => this.visitField(e)) @@ -27,32 +29,69 @@ export class ExpressionVisitor { .exhaustive(); } - protected visitLiteral(_e: LiteralExpression) {} + protected visitLiteral(_e: LiteralExpression): VisitResult {} - protected visitArray(e: ArrayExpression) { - e.items.forEach((item) => this.visit(item)); + protected visitArray(e: ArrayExpression): VisitResult { + for (const item of e.items) { + const result = this.visit(item); + if (result?.abort) { + return result; + } + } } - protected visitField(_e: FieldExpression) {} + protected visitField(_e: FieldExpression): VisitResult {} - protected visitMember(e: MemberExpression) { - this.visit(e.receiver); + protected visitMember(e: MemberExpression): VisitResult { + return this.visit(e.receiver); } - protected visitBinary(e: BinaryExpression) { - this.visit(e.left); - this.visit(e.right); + protected visitBinary(e: BinaryExpression): VisitResult { + const l = this.visit(e.left); + if (l?.abort) { + return l; + } else { + return this.visit(e.right); + } } - protected visitUnary(e: UnaryExpression) { - this.visit(e.operand); + protected visitUnary(e: UnaryExpression): VisitResult { + return this.visit(e.operand); } - protected visitCall(e: CallExpression) { - e.args?.forEach((arg) => this.visit(arg)); + protected visitCall(e: CallExpression): VisitResult { + for (const arg of e.args ?? []) { + const r = this.visit(arg); + if (r?.abort) { + return r; + } + } } - protected visitThis(_e: ThisExpression) {} + protected visitThis(_e: ThisExpression): VisitResult {} + + protected visitNull(_e: NullExpression): VisitResult {} +} - protected visitNull(_e: NullExpression) {} +export class MatchingExpressionVisitor extends ExpressionVisitor { + private found = false; + + constructor(private predicate: (expr: Expression) => boolean) { + super(); + } + + find(expr: Expression) { + this.found = false; + this.visit(expr); + return this.found; + } + + override visit(expr: Expression) { + if (this.predicate(expr)) { + this.found = true; + return { abort: true } as const; + } else { + return super.visit(expr); + } + } } diff --git a/packages/orm/src/utils/type-utils.ts b/packages/orm/src/utils/type-utils.ts index 47b4e095..26828cf6 100644 --- a/packages/orm/src/utils/type-utils.ts +++ b/packages/orm/src/utils/type-utils.ts @@ -2,8 +2,12 @@ import type Decimal from 'decimal.js'; export type Optional = Omit & Partial>; +export type PartialIf = Condition extends true ? Partial : T; + export type NullableIf = Condition extends true ? T | null : T; +export type ArrayIf = Condition extends true ? T[] : T; + export type PartialRecord = Partial>; type _Preserve = Date | Function | Decimal | Uint8Array | JsonObject | JsonValue; diff --git a/packages/plugins/policy/package.json b/packages/plugins/policy/package.json index 52dc2270..16d7952a 100644 --- a/packages/plugins/policy/package.json +++ b/packages/plugins/policy/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/plugin-policy", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack Policy Plugin", "type": "module", "scripts": { diff --git a/packages/plugins/policy/src/expression-evaluator.ts b/packages/plugins/policy/src/expression-evaluator.ts index a09c87d1..45c7b855 100644 --- a/packages/plugins/policy/src/expression-evaluator.ts +++ b/packages/plugins/policy/src/expression-evaluator.ts @@ -79,6 +79,11 @@ export class ExpressionEvaluator { const left = this.evaluate(expr.left, context); const right = this.evaluate(expr.right, context); + if (!['==', '!='].includes(expr.op) && (left === null || right === null)) { + // non-equality comparison with null always yields null (follow SQL logic) + return null; + } + return match(expr.op) .with('==', () => left === right) .with('!=', () => left !== right) @@ -101,8 +106,8 @@ export class ExpressionEvaluator { invariant(op === '?' || op === '!' || op === '^', 'expected "?" or "!" or "^" operator'); const left = this.evaluate(expr.left, context); - if (!left) { - return false; + if (left === null || left === undefined) { + return null; } invariant(Array.isArray(left), 'expected array'); diff --git a/packages/plugins/policy/src/expression-transformer.ts b/packages/plugins/policy/src/expression-transformer.ts index 8036eb16..0ea84a97 100644 --- a/packages/plugins/policy/src/expression-transformer.ts +++ b/packages/plugins/policy/src/expression-transformer.ts @@ -1,5 +1,12 @@ import { invariant } from '@zenstackhq/common-helpers'; -import { getCrudDialect, QueryUtils, type BaseCrudDialect, type ClientContract, type CRUD_EXT } from '@zenstackhq/orm'; +import { + getCrudDialect, + QueryUtils, + SchemaUtils, + type BaseCrudDialect, + type ClientContract, + type CRUD_EXT, +} from '@zenstackhq/orm'; import type { BinaryExpression, BinaryOperator, @@ -40,6 +47,7 @@ import { } from 'kysely'; import { match } from 'ts-pattern'; import { ExpressionEvaluator } from './expression-evaluator'; +import { CollectionPredicateOperator } from './types'; import { conjunction, createUnsupportedError, @@ -50,12 +58,49 @@ import { trueNode, } from './utils'; +/** + * Context for transforming a policy expression + */ export type ExpressionTransformerContext = { - model: string; + /** + * The current model or type name fields should be resolved against + */ + modelOrType: string; + + /** + * The alias name that should be used to address a model + */ alias?: string; + + /** + * The CRUD operation + */ operation: CRUD_EXT; + + /** + * In case of transforming a collection predicate's LHS, the compiled RHS filter expression + */ memberFilter?: OperationNode; + + /** + * In case of transforming a collection predicate's LHS, the field name to select as the predicate result + */ memberSelect?: SelectionNode; + + /** + * The value object that fields should be evaluated against + */ + contextValue?: Record; + + /** + * The model or type name that `this` keyword refers to + */ + thisType: string; + + /** + * The table alias name used to compile `this` keyword + */ + thisAlias?: string; }; // a registry of expression handlers marked with @expr @@ -122,7 +167,13 @@ export class ExpressionTransformer { @expr('field') private _field(expr: FieldExpression, context: ExpressionTransformerContext) { - const fieldDef = QueryUtils.requireField(this.schema, context.model, expr.field); + if (context.contextValue) { + // if we're transforming against a value object, fields should be evaluated directly + const fieldDef = QueryUtils.requireField(this.schema, context.modelOrType, expr.field); + return this.transformValue(context.contextValue[expr.field], fieldDef.type as BuiltinType); + } + + const fieldDef = QueryUtils.requireField(this.schema, context.modelOrType, expr.field); if (!fieldDef.relation) { return this.createColumnRef(expr.field, context); } else { @@ -202,35 +253,45 @@ export class ExpressionTransformer { } private transformNullCheck(expr: OperationNode, operator: BinaryOperator) { - invariant(operator === '==' || operator === '!=', 'operator must be "==" or "!=" for null comparison'); - if (ValueNode.is(expr)) { - if (expr.value === null) { - return operator === '==' ? trueNode(this.dialect) : falseNode(this.dialect); + if (operator === '==' || operator === '!=') { + // equality checks against null + if (ValueNode.is(expr)) { + if (expr.value === null) { + return operator === '==' ? trueNode(this.dialect) : falseNode(this.dialect); + } else { + return operator === '==' ? falseNode(this.dialect) : trueNode(this.dialect); + } } else { - return operator === '==' ? falseNode(this.dialect) : trueNode(this.dialect); + return operator === '==' + ? BinaryOperationNode.create(expr, OperatorNode.create('is'), ValueNode.createImmediate(null)) + : BinaryOperationNode.create(expr, OperatorNode.create('is not'), ValueNode.createImmediate(null)); } } else { - return operator === '==' - ? BinaryOperationNode.create(expr, OperatorNode.create('is'), ValueNode.createImmediate(null)) - : BinaryOperationNode.create(expr, OperatorNode.create('is not'), ValueNode.createImmediate(null)); + // otherwise any comparison with null is null + return ValueNode.createImmediate(null); } } private normalizeBinaryOperationOperands(expr: BinaryExpression, context: ExpressionTransformerContext) { + if (context.contextValue) { + // no normalization needed if evaluating against a value object + return { normalizedLeft: expr.left, normalizedRight: expr.right }; + } + // if relation fields are used directly in comparison, it can only be compared with null, // so we normalize the args with the id field (use the first id field if multiple) let normalizedLeft: Expression = expr.left; - if (this.isRelationField(expr.left, context.model)) { + if (this.isRelationField(expr.left, context.modelOrType)) { invariant(ExpressionUtils.isNull(expr.right), 'only null comparison is supported for relation field'); - const leftRelDef = this.getFieldDefFromFieldRef(expr.left, context.model); + const leftRelDef = this.getFieldDefFromFieldRef(expr.left, context.modelOrType); invariant(leftRelDef, 'failed to get relation field definition'); const idFields = QueryUtils.requireIdFields(this.schema, leftRelDef.type); normalizedLeft = this.makeOrAppendMember(normalizedLeft, idFields[0]!); } let normalizedRight: Expression = expr.right; - if (this.isRelationField(expr.right, context.model)) { + if (this.isRelationField(expr.right, context.modelOrType)) { invariant(ExpressionUtils.isNull(expr.left), 'only null comparison is supported for relation field'); - const rightRelDef = this.getFieldDefFromFieldRef(expr.right, context.model); + const rightRelDef = this.getFieldDefFromFieldRef(expr.right, context.modelOrType); invariant(rightRelDef, 'failed to get relation field definition'); const idFields = QueryUtils.requireIdFields(this.schema, rightRelDef.type); normalizedRight = this.makeOrAppendMember(normalizedRight, idFields[0]!); @@ -239,22 +300,35 @@ export class ExpressionTransformer { } private transformCollectionPredicate(expr: BinaryExpression, context: ExpressionTransformerContext) { - invariant(expr.op === '?' || expr.op === '!' || expr.op === '^', 'expected "?" or "!" or "^" operator'); + this.ensureCollectionPredicateOperator(expr.op); - if (this.isAuthCall(expr.left) || this.isAuthMember(expr.left)) { - const value = new ExpressionEvaluator().evaluate(expr, { - auth: this.auth, - }); - return this.transformValue(value, 'Boolean'); + if (this.isAuthMember(expr.left) || context.contextValue) { + invariant( + ExpressionUtils.isMember(expr.left) || ExpressionUtils.isField(expr.left), + 'expected member or field expression', + ); + + // LHS of the expression is evaluated as a value + const evaluator = new ExpressionEvaluator(); + const receiver = evaluator.evaluate(expr.left, { thisValue: context.contextValue, auth: this.auth }); + + // get LHS's type + const baseType = this.isAuthMember(expr.left) ? this.authType : context.modelOrType; + const memberType = this.getMemberType(baseType, expr.left); + + // transform the entire expression with a value LHS and the correct context type + return this.transformValueCollectionPredicate(receiver, expr, { ...context, modelOrType: memberType }); } + // otherwise, transform the expression with relation joins + invariant( ExpressionUtils.isField(expr.left) || ExpressionUtils.isMember(expr.left), 'left operand must be field or member access', ); let newContextModel: string; - const fieldDef = this.getFieldDefFromFieldRef(expr.left, context.model); + const fieldDef = this.getFieldDefFromFieldRef(expr.left, context.modelOrType); if (fieldDef) { invariant(fieldDef.relation, `field is not a relation: ${JSON.stringify(expr.left)}`); newContextModel = fieldDef.type; @@ -263,7 +337,7 @@ export class ExpressionTransformer { ExpressionUtils.isMember(expr.left) && ExpressionUtils.isField(expr.left.receiver), 'left operand must be member access with field receiver', ); - const fieldDef = QueryUtils.requireField(this.schema, context.model, expr.left.receiver.field); + const fieldDef = QueryUtils.requireField(this.schema, context.modelOrType, expr.left.receiver.field); newContextModel = fieldDef.type; for (const member of expr.left.members) { const memberDef = QueryUtils.requireField(this.schema, newContextModel, member); @@ -273,7 +347,7 @@ export class ExpressionTransformer { let predicateFilter = this.transform(expr.right, { ...context, - model: newContextModel, + modelOrType: newContextModel, alias: undefined, }); @@ -296,10 +370,80 @@ export class ExpressionTransformer { }); } + private ensureCollectionPredicateOperator(op: BinaryOperator): asserts op is CollectionPredicateOperator { + invariant(CollectionPredicateOperator.includes(op as any), 'expected "?" or "!" or "^" operator'); + } + + private transformValueCollectionPredicate( + receiver: any, + expr: BinaryExpression, + context: ExpressionTransformerContext, + ) { + if (!receiver) { + return ValueNode.createImmediate(null); + } + + this.ensureCollectionPredicateOperator(expr.op); + + const visitor = new SchemaUtils.MatchingExpressionVisitor((e) => ExpressionUtils.isThis(e)); + if (!visitor.find(expr.right)) { + // right side only refers to the value tree, evaluate directly as an optimization + const value = new ExpressionEvaluator().evaluate(expr, { + auth: this.auth, + thisValue: context.contextValue, + }); + return this.transformValue(value, 'Boolean'); + } else { + // right side refers to `this`, need expand into a real filter + // e.g.: `auth().profiles?[age == this.age], where `this` refer to the containing model + invariant(Array.isArray(receiver), 'array value is expected'); + + // for each LHS element, transform RHS + // e.g.: `auth().profiles[age == this.age]`, each `auth().profiles` element (which is a value) + // is used to build an expression for the RHS `age == this.age` + // the transformation happens recursively for nested collection predicates + const components = receiver.map((item) => + this.transform(expr.right, { + operation: context.operation, + thisType: context.thisType, + thisAlias: context.thisAlias, + modelOrType: context.modelOrType, + contextValue: item, + }), + ); + + // compose the components based on the operator + return ( + match(expr.op) + // some + .with('?', () => disjunction(this.dialect, components)) + // every + .with('!', () => conjunction(this.dialect, components)) + // none + .with('^', () => logicalNot(this.dialect, disjunction(this.dialect, components))) + .exhaustive() + ); + } + } + + private getMemberType(receiverType: string, expr: MemberExpression | FieldExpression) { + if (ExpressionUtils.isField(expr)) { + const fieldDef = QueryUtils.requireField(this.schema, receiverType, expr.field); + return fieldDef.type; + } else { + let currType = receiverType; + for (const member of expr.members) { + const fieldDef = QueryUtils.requireField(this.schema, currType, member); + currType = fieldDef.type; + } + return currType; + } + } + private transformAuthBinary(expr: BinaryExpression, context: ExpressionTransformerContext) { if (expr.op !== '==' && expr.op !== '!=') { throw createUnsupportedError( - `Unsupported operator for \`auth()\` in policy of model "${context.model}": ${expr.op}`, + `Unsupported operator for \`auth()\` in policy of model "${context.modelOrType}": ${expr.op}`, ); } @@ -319,7 +463,7 @@ export class ExpressionTransformer { const authModel = QueryUtils.getModel(this.schema, this.authType); if (!authModel) { throw createUnsupportedError( - `Unsupported use of \`auth()\` in policy of model "${context.model}", comparing with \`auth()\` is only possible when auth type is a model`, + `Unsupported use of \`auth()\` in policy of model "${context.modelOrType}", comparing with \`auth()\` is only possible when auth type is a model`, ); } @@ -358,7 +502,13 @@ export class ExpressionTransformer { } else if (value === false) { return falseNode(this.dialect); } else { - return ValueNode.create(this.dialect.transformPrimitive(value, type, false) ?? null); + const transformed = this.dialect.transformPrimitive(value, type, false) ?? null; + if (!Array.isArray(transformed)) { + // simple primitives can be immediate values + return ValueNode.createImmediate(transformed); + } else { + return ValueNode.create(transformed); + } } } @@ -396,8 +546,8 @@ export class ExpressionTransformer { { client: this.client, dialect: this.dialect, - model: context.model as GetModels, - modelAlias: context.alias ?? context.model, + model: context.modelOrType as GetModels, + modelAlias: context.alias ?? context.modelOrType, operation: context.operation, }, ); @@ -476,10 +626,16 @@ export class ExpressionTransformer { if (ExpressionUtils.isThis(expr.receiver)) { if (expr.members.length === 1) { // `this.relation` case, equivalent to field access - return this._field(ExpressionUtils.field(expr.members[0]!), context); + return this._field(ExpressionUtils.field(expr.members[0]!), { + ...context, + alias: context.thisAlias, + modelOrType: context.thisType, + thisType: context.thisType, + contextValue: undefined, + }); } else { // transform the first segment into a relation access, then continue with the rest of the members - const firstMemberFieldDef = QueryUtils.requireField(this.schema, context.model, expr.members[0]!); + const firstMemberFieldDef = QueryUtils.requireField(this.schema, context.thisType, expr.members[0]!); receiver = this.transformRelationAccess(expr.members[0]!, firstMemberFieldDef.type, restContext); members = expr.members.slice(1); } @@ -491,11 +647,11 @@ export class ExpressionTransformer { let startType: string; if (ExpressionUtils.isField(expr.receiver)) { - const receiverField = QueryUtils.requireField(this.schema, context.model, expr.receiver.field); + const receiverField = QueryUtils.requireField(this.schema, context.modelOrType, expr.receiver.field); startType = receiverField.type; } else { - // "this." case, start type is the model of the context - startType = context.model; + // "this." case + startType = context.thisType; } // traverse forward to collect member types @@ -516,7 +672,7 @@ export class ExpressionTransformer { if (fieldDef.relation) { const relation = this.transformRelationAccess(member, fieldDef.type, { ...restContext, - model: fromModel, + modelOrType: fromModel, alias: undefined, }); @@ -554,14 +710,24 @@ export class ExpressionTransformer { return ValueNode.createImmediate(null); } - if (expr.members.length !== 1) { - throw new Error(`Only single member access is supported`); - } + invariant(expr.members.length > 0, 'member expression must have at least one member'); - const field = expr.members[0]!; - const fieldDef = QueryUtils.requireField(this.schema, receiverType, field); - const fieldValue = receiver[field] ?? null; - return this.transformValue(fieldValue, fieldDef.type as BuiltinType); + let curr: any = receiver; + let currType = receiverType; + for (let i = 0; i < expr.members.length; i++) { + const field = expr.members[i]!; + curr = curr?.[field]; + if (curr === undefined) { + curr = ValueNode.createImmediate(null); + break; + } + currType = QueryUtils.requireField(this.schema, currType, field).type; + if (i === expr.members.length - 1) { + // last segment (which is the value), make sure it's transformed + curr = this.transformValue(curr, currType as BuiltinType); + } + } + return curr; } private transformRelationAccess( @@ -569,12 +735,12 @@ export class ExpressionTransformer { relationModel: string, context: ExpressionTransformerContext, ): SelectQueryNode { - const m2m = QueryUtils.getManyToManyRelation(this.schema, context.model, field); + const m2m = QueryUtils.getManyToManyRelation(this.schema, context.modelOrType, field); if (m2m) { return this.transformManyToManyRelationAccess(m2m, context); } - const fromModel = context.model; + const fromModel = context.modelOrType; const relationFieldDef = QueryUtils.requireField(this.schema, fromModel, field); const { keyPairs, ownedByModel } = QueryUtils.getRelationForeignKeyFieldPairs(this.schema, fromModel, field); @@ -641,7 +807,7 @@ export class ExpressionTransformer { .onRef( `${m2m.joinTable}.${m2m.parentFkName}`, '=', - `${context.alias ?? context.model}.${m2m.parentPKName}`, + `${context.alias ?? context.modelOrType}.${m2m.parentPKName}`, ), ); return relationQuery.toOperationNode(); @@ -651,7 +817,7 @@ export class ExpressionTransformer { // if field comes from a delegate base model, we need to use the join alias // of that base model - const tableName = context.alias ?? context.model; + const tableName = context.alias ?? context.modelOrType; // "create" policies evaluate table from "VALUES" node so no join from delegate bases are // created and thus we should directly use the model table name @@ -659,12 +825,12 @@ export class ExpressionTransformer { return ReferenceNode.create(ColumnNode.create(column), TableNode.create(tableName)); } - const fieldDef = QueryUtils.requireField(this.schema, context.model, column); - if (!fieldDef.originModel || fieldDef.originModel === context.model) { + const fieldDef = QueryUtils.requireField(this.schema, context.modelOrType, column); + if (!fieldDef.originModel || fieldDef.originModel === context.modelOrType) { return ReferenceNode.create(ColumnNode.create(column), TableNode.create(tableName)); } - return this.buildDelegateBaseFieldSelect(context.model, tableName, column, fieldDef.originModel); + return this.buildDelegateBaseFieldSelect(context.modelOrType, tableName, column, fieldDef.originModel); } private buildDelegateBaseFieldSelect(model: string, modelAlias: string, field: string, baseModel: string) { @@ -723,13 +889,13 @@ export class ExpressionTransformer { private getFieldDefFromFieldRef(expr: Expression, model: string): FieldDef | undefined { if (ExpressionUtils.isField(expr)) { - return QueryUtils.requireField(this.schema, model, expr.field); + return QueryUtils.getField(this.schema, model, expr.field); } else if ( ExpressionUtils.isMember(expr) && expr.members.length === 1 && ExpressionUtils.isThis(expr.receiver) ) { - return QueryUtils.requireField(this.schema, model, expr.members[0]!); + return QueryUtils.getField(this.schema, model, expr.members[0]!); } else { return undefined; } diff --git a/packages/plugins/policy/src/policy-handler.ts b/packages/plugins/policy/src/policy-handler.ts index e1c24d6c..eeb4a8b8 100644 --- a/packages/plugins/policy/src/policy-handler.ts +++ b/packages/plugins/policy/src/policy-handler.ts @@ -881,7 +881,9 @@ export class PolicyHandler extends OperationNodeTransf private compilePolicyCondition(model: string, alias: string | undefined, operation: CRUD_EXT, policy: Policy) { return new ExpressionTransformer(this.client).transform(policy.condition, { - model, + modelOrType: model, + thisType: model, // type name for `this`, never changed during the entire transformation + thisAlias: alias, // alias for `this`, never changed during the entire transformation alias, operation, }); diff --git a/packages/plugins/policy/src/types.ts b/packages/plugins/policy/src/types.ts index dc042aa9..8f2f635b 100644 --- a/packages/plugins/policy/src/types.ts +++ b/packages/plugins/policy/src/types.ts @@ -19,3 +19,13 @@ export type Policy = { operations: readonly PolicyOperation[]; condition: Expression; }; + +/** + * Operators allowed for collection predicate expressions. + */ +export const CollectionPredicateOperator = ['?', '!', '^'] as const; + +/** + * Operators allowed for collection predicate expressions. + */ +export type CollectionPredicateOperator = (typeof CollectionPredicateOperator)[number]; diff --git a/packages/schema/package.json b/packages/schema/package.json index d1a86d25..10437710 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/schema", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack Runtime Schema", "type": "module", "scripts": { diff --git a/packages/schema/src/schema.ts b/packages/schema/src/schema.ts index 13fc90b9..abc98ace 100644 --- a/packages/schema/src/schema.ts +++ b/packages/schema/src/schema.ts @@ -15,7 +15,7 @@ export type SchemaDef = { typeDefs?: Record; plugins: Record; procedures?: Record; - authType?: GetModels; + authType?: GetModels | GetTypeDefs; }; export type ModelDef = { @@ -69,6 +69,7 @@ export type FieldDef = { updatedAt?: boolean; attributes?: AttributeApplication[]; default?: MappedBuiltinType | Expression | unknown[]; + omit?: boolean; relation?: RelationInfo; foreignKeyFor?: string[]; computed?: boolean; @@ -240,6 +241,12 @@ export type TypeDefFieldIsOptional< Field extends GetTypeDefFields, > = GetTypeDefField['optional'] extends true ? true : false; +export type TypeDefFieldIsArray< + Schema extends SchemaDef, + TypeDef extends GetTypeDefs, + Field extends GetTypeDefFields, +> = GetTypeDefField['array'] extends true ? true : false; + export type FieldIsRelation< Schema extends SchemaDef, Model extends GetModels, diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8b77a248..19f49a23 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack SDK", "type": "module", "scripts": { diff --git a/packages/sdk/src/model-utils.ts b/packages/sdk/src/model-utils.ts index c9102c22..2473f284 100644 --- a/packages/sdk/src/model-utils.ts +++ b/packages/sdk/src/model-utils.ts @@ -106,7 +106,7 @@ export function getAuthDecl(model: Model) { (d) => (isDataModel(d) || isTypeDef(d)) && d.attributes.some((attr) => attr.decl.$refText === '@@auth'), ); if (!found) { - found = model.declarations.find((d) => isDataModel(d) && d.name === 'User'); + found = model.declarations.find((d) => (isDataModel(d) || isTypeDef(d)) && d.name === 'User'); } return found; } diff --git a/packages/sdk/src/ts-schema-generator.ts b/packages/sdk/src/ts-schema-generator.ts index 7a62e757..780817aa 100644 --- a/packages/sdk/src/ts-schema-generator.ts +++ b/packages/sdk/src/ts-schema-generator.ts @@ -296,18 +296,26 @@ export class TsSchemaGenerator { private createModelsObject(model: Model, lite: boolean): ts.Expression { return ts.factory.createObjectLiteralExpression( - model.declarations - .filter((d): d is DataModel => isDataModel(d) && !hasAttribute(d, '@@ignore')) - .map((dm) => ts.factory.createPropertyAssignment(dm.name, this.createDataModelObject(dm, lite))), + this.getAllDataModels(model).map((dm) => + ts.factory.createPropertyAssignment(dm.name, this.createDataModelObject(dm, lite)), + ), true, ); } + private getAllDataModels(model: Model) { + return model.declarations.filter((d): d is DataModel => isDataModel(d) && !hasAttribute(d, '@@ignore')); + } + + private getAllTypeDefs(model: Model) { + return model.declarations.filter((d): d is TypeDef => isTypeDef(d) && !hasAttribute(d, '@@ignore')); + } + private createTypeDefsObject(model: Model, lite: boolean): ts.Expression { return ts.factory.createObjectLiteralExpression( - model.declarations - .filter((d): d is TypeDef => isTypeDef(d)) - .map((td) => ts.factory.createPropertyAssignment(td.name, this.createTypeDefObject(td, lite))), + this.getAllTypeDefs(model).map((td) => + ts.factory.createPropertyAssignment(td.name, this.createTypeDefObject(td, lite)), + ), true, ); } @@ -543,6 +551,10 @@ export class TsSchemaGenerator { objectFields.push(ts.factory.createPropertyAssignment('updatedAt', ts.factory.createTrue())); } + if (hasAttribute(field, '@omit')) { + objectFields.push(ts.factory.createPropertyAssignment('omit', ts.factory.createTrue())); + } + // originModel if ( contextModel && @@ -1337,7 +1349,7 @@ export class TsSchemaGenerator { ); // generate: export type Model = $ModelResult; - const dataModels = model.declarations.filter(isDataModel); + const dataModels = this.getAllDataModels(model); for (const dm of dataModels) { let modelType = ts.factory.createTypeAliasDeclaration( [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], @@ -1355,7 +1367,7 @@ export class TsSchemaGenerator { } // generate: export type TypeDef = $TypeDefResult; - const typeDefs = model.declarations.filter(isTypeDef); + const typeDefs = this.getAllTypeDefs(model); for (const td of typeDefs) { let typeDef = ts.factory.createTypeAliasDeclaration( [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], @@ -1492,7 +1504,7 @@ export class TsSchemaGenerator { } private generateInputTypes(model: Model, options: TsSchemaGeneratorOptions) { - const dataModels = model.declarations.filter(isDataModel); + const dataModels = this.getAllDataModels(model); const statements: ts.Statement[] = []; // generate: import { SchemaType as $Schema } from './schema'; @@ -1542,15 +1554,20 @@ export class TsSchemaGenerator { ts.factory.createImportClause( true, undefined, - ts.factory.createNamedImports( - inputTypes.map((inputType) => + ts.factory.createNamedImports([ + ...inputTypes.map((inputType) => ts.factory.createImportSpecifier( false, undefined, ts.factory.createIdentifier(`${inputType} as $${inputType}`), ), ), - ), + ts.factory.createImportSpecifier( + false, + undefined, + ts.factory.createIdentifier('ClientOptions as $ClientOptions'), + ), + ]), ), ts.factory.createStringLiteral('@zenstackhq/orm'), ), @@ -1599,7 +1616,7 @@ export class TsSchemaGenerator { ); } - // generate: export type ModelGetPayload> = $SimplifiedModelResult; + // generate: export type ModelGetPayload, Options extends ClientOptions> = $SimplifiedModelResult; statements.push( ts.factory.createTypeAliasDeclaration( [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], @@ -1614,10 +1631,21 @@ export class TsSchemaGenerator { ts.factory.createLiteralTypeNode(ts.factory.createTrue()), ]), ), + ts.factory.createTypeParameterDeclaration( + undefined, + 'Options', + ts.factory.createTypeReferenceNode('$ClientOptions', [ + ts.factory.createTypeReferenceNode('$Schema'), + ]), + ts.factory.createTypeReferenceNode('$ClientOptions', [ + ts.factory.createTypeReferenceNode('$Schema'), + ]), + ), ], ts.factory.createTypeReferenceNode('$SimplifiedModelResult', [ ts.factory.createTypeReferenceNode('$Schema'), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(dm.name)), + ts.factory.createTypeReferenceNode('Options'), ts.factory.createTypeReferenceNode('Args'), ]), ), diff --git a/packages/server/package.json b/packages/server/package.json index d6ec7c9e..8ba75d41 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack automatic CRUD API handlers and server adapters", "type": "module", "scripts": { diff --git a/packages/testtools/package.json b/packages/testtools/package.json index 5e6f7269..bbae0430 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "ZenStack Test Tools", "type": "module", "scripts": { diff --git a/packages/testtools/src/client.ts b/packages/testtools/src/client.ts index b00c38ae..c756f126 100644 --- a/packages/testtools/src/client.ts +++ b/packages/testtools/src/client.ts @@ -32,7 +32,7 @@ const TEST_PG_CONFIG = { password: process.env['TEST_PG_PASSWORD'] ?? 'postgres', }; -export type CreateTestClientOptions = Omit, 'dialect'> & { +type ExtraTestClientOptions = { /** * Database provider */ @@ -81,23 +81,27 @@ export type CreateTestClientOptions = Omit( - schema: Schema, - options?: CreateTestClientOptions, -): Promise>; -export async function createTestClient( - schema: string, - options?: CreateTestClientOptions, -): Promise; -export async function createTestClient( - schema: Schema | string, - options?: CreateTestClientOptions, +export type CreateTestClientOptions = Omit, 'dialect'> & + ExtraTestClientOptions; + +export async function createTestClient< + Schema extends SchemaDef, + Options extends ClientOptions, + CreateOptions = Omit, +>(schema: Schema, options?: CreateOptions): Promise>; +export async function createTestClient(schema: string, options?: CreateTestClientOptions): Promise; +export async function createTestClient( + schema: SchemaDef | string, + options?: CreateTestClientOptions, ): Promise { let workDir = options?.workDir; - let _schema: Schema; + let _schema: SchemaDef; const provider = options?.provider ?? getTestDbProvider() ?? 'sqlite'; const dbName = options?.dbName ?? getTestDbName(provider); const dbUrl = @@ -118,7 +122,7 @@ export async function createTestClient( ...generated.schema.provider, type: provider, }, - } as Schema; + } as SchemaDef; } else { // replace schema's provider _schema = { @@ -148,9 +152,9 @@ export async function createTestClient( invariant(workDir); const { plugins, ...rest } = options ?? {}; - const _options: ClientOptions = { + const _options = { ...rest, - } as ClientOptions; + } as ClientOptions; if (options?.debug) { console.log(`Work directory: ${workDir}`); diff --git a/packages/zod/package.json b/packages/zod/package.json index 99539ed2..0466d07d 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/zod", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "", "type": "module", "main": "index.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f313b66c..5e1199a7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,8 +67,8 @@ catalogs: specifier: ^5.7.1 version: 5.7.1 typescript: - specifier: ^5.8.0 - version: 5.8.3 + specifier: ^5.9.3 + version: 5.9.3 vue: specifier: 3.5.22 version: 3.5.22 @@ -97,10 +97,10 @@ importers: version: 3.5.3 prisma: specifier: 'catalog:' - version: 6.19.0(magicast@0.3.5)(typescript@5.8.3) + version: 6.19.0(magicast@0.3.5)(typescript@5.9.3) tsup: specifier: ^8.5.0 - version: 8.5.0(@swc/core@1.12.5)(jiti@2.6.1)(postcss@8.5.6)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0) + version: 8.5.0(@swc/core@1.12.5)(jiti@2.6.1)(postcss@8.5.6)(tsx@4.20.3)(typescript@5.9.3)(yaml@2.8.0) tsx: specifier: ^4.20.3 version: 4.20.3 @@ -109,10 +109,10 @@ importers: version: 2.5.4 typescript: specifier: 'catalog:' - version: 5.8.3 + version: 5.9.3 typescript-eslint: specifier: ^8.34.1 - version: 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + version: 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) vitest: specifier: ^3.2.4 version: 3.2.4(@types/node@20.19.24)(happy-dom@20.0.10)(jiti@2.6.1)(jsdom@27.1.0)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.0) @@ -185,7 +185,7 @@ importers: version: 1.3.0 prisma: specifier: 'catalog:' - version: 6.19.0(magicast@0.3.5)(typescript@5.8.3) + version: 6.19.0(magicast@0.3.5)(typescript@5.9.3) semver: specifier: ^7.7.2 version: 7.7.2 @@ -250,7 +250,7 @@ importers: version: 5.90.2(svelte@5.43.3) '@tanstack/vue-query': specifier: 5.90.6 - version: 5.90.6(vue@3.5.22(typescript@5.8.3)) + version: 5.90.6(vue@3.5.22(typescript@5.9.3)) '@testing-library/dom': specifier: ^10.4.1 version: 10.4.1 @@ -289,7 +289,7 @@ importers: version: 5.43.3 vue: specifier: 'catalog:' - version: 3.5.22(typescript@5.8.3) + version: 3.5.22(typescript@5.9.3) packages/common-helpers: devDependencies: @@ -529,7 +529,7 @@ importers: version: 5.7.1 typescript: specifier: 'catalog:' - version: 5.8.3 + version: 5.9.3 devDependencies: '@zenstackhq/eslint-config': specifier: workspace:* @@ -600,7 +600,7 @@ importers: version: 2.2.0 elysia: specifier: ^1.3.1 - version: 1.4.13(@sinclair/typebox@0.34.41)(exact-mirror@0.2.2(@sinclair/typebox@0.34.41))(file-type@21.0.0)(openapi-types@12.1.3)(typescript@5.8.3) + version: 1.4.13(@sinclair/typebox@0.34.41)(exact-mirror@0.2.2(@sinclair/typebox@0.34.41))(file-type@21.0.0)(openapi-types@12.1.3)(typescript@5.9.3) express: specifier: ^5.0.0 version: 5.1.0 @@ -621,7 +621,7 @@ importers: version: 16.0.1(@babel/core@7.28.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0) nuxt: specifier: ^4.2.0 - version: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) + version: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) supertest: specifier: ^7.1.4 version: 7.1.4 @@ -663,7 +663,7 @@ importers: version: 8.16.3 prisma: specifier: 'catalog:' - version: 6.19.0(magicast@0.3.5)(typescript@5.8.3) + version: 6.19.0(magicast@0.3.5)(typescript@5.9.3) tmp: specifier: 'catalog:' version: 0.2.3 @@ -691,7 +691,7 @@ importers: version: link:../config/typescript-config typescript: specifier: 'catalog:' - version: 5.8.3 + version: 5.9.3 packages/zod: dependencies: @@ -768,13 +768,13 @@ importers: version: 9.29.0(jiti@2.6.1) eslint-config-next: specifier: 16.0.1 - version: 16.0.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + version: 16.0.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) tailwindcss: specifier: ^4 version: 4.1.16 typescript: - specifier: ^5 - version: 5.8.3 + specifier: 'catalog:' + version: 5.9.3 samples/orm: dependencies: @@ -802,7 +802,7 @@ importers: version: link:../../packages/config/typescript-config prisma: specifier: 'catalog:' - version: 6.19.0(magicast@0.3.5)(typescript@5.8.3) + version: 6.19.0(magicast@0.3.5)(typescript@5.9.3) tests/e2e: dependencies: @@ -7080,8 +7080,8 @@ packages: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <6.0.0' - typescript@5.8.3: - resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} hasBin: true @@ -8512,12 +8512,12 @@ snapshots: prompts: 2.4.2 semver: 7.7.3 - '@nuxt/devtools@2.7.0(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3))': + '@nuxt/devtools@2.7.0(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3))': dependencies: '@nuxt/devtools-kit': 2.7.0(magicast@0.3.5)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)) '@nuxt/devtools-wizard': 2.7.0 '@nuxt/kit': 3.20.0(magicast@0.3.5) - '@vue/devtools-core': 7.7.7(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)) + '@vue/devtools-core': 7.7.7(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)) '@vue/devtools-kit': 7.7.7 birpc: 2.6.1 consola: 3.4.2 @@ -8544,7 +8544,7 @@ snapshots: tinyglobby: 0.2.15 vite: 7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) vite-plugin-inspect: 11.3.3(@nuxt/kit@3.20.0(magicast@0.3.5))(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)) - vite-plugin-vue-tracer: 1.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)) + vite-plugin-vue-tracer: 1.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)) which: 5.0.0 ws: 8.18.3 transitivePeerDependencies: @@ -8630,11 +8630,11 @@ snapshots: transitivePeerDependencies: - magicast - '@nuxt/nitro-server@4.2.0(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(ioredis@5.8.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(typescript@5.8.3)': + '@nuxt/nitro-server@4.2.0(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(ioredis@5.8.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(typescript@5.9.3)': dependencies: '@nuxt/devalue': 2.0.2 '@nuxt/kit': 4.2.0(magicast@0.5.0) - '@unhead/vue': 2.0.19(vue@3.5.22(typescript@5.8.3)) + '@unhead/vue': 2.0.19(vue@3.5.22(typescript@5.9.3)) '@vue/shared': 3.5.22 consola: 3.4.2 defu: 6.1.4 @@ -8648,7 +8648,7 @@ snapshots: klona: 2.0.6 mocked-exports: 0.1.1 nitropack: 2.12.9(better-sqlite3@12.2.0) - nuxt: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) + nuxt: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) pathe: 2.0.3 pkg-types: 2.3.0 radix3: 1.1.2 @@ -8656,7 +8656,7 @@ snapshots: ufo: 1.6.1 unctx: 2.4.1 unstorage: 1.17.1(db0@0.3.4(better-sqlite3@12.2.0))(ioredis@5.8.2) - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) vue-bundle-renderer: 2.2.0 vue-devtools-stub: 0.1.0 transitivePeerDependencies: @@ -8719,12 +8719,12 @@ snapshots: transitivePeerDependencies: - magicast - '@nuxt/vite-builder@4.2.0(@types/node@20.19.24)(eslint@9.29.0(jiti@2.6.1))(lightningcss@1.30.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vue@3.5.22(typescript@5.8.3))(yaml@2.8.1)': + '@nuxt/vite-builder@4.2.0(@types/node@20.19.24)(eslint@9.29.0(jiti@2.6.1))(lightningcss@1.30.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vue@3.5.22(typescript@5.9.3))(yaml@2.8.1)': dependencies: '@nuxt/kit': 4.2.0(magicast@0.5.0) '@rollup/plugin-replace': 6.0.3(rollup@4.52.5) - '@vitejs/plugin-vue': 6.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)) - '@vitejs/plugin-vue-jsx': 5.1.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)) + '@vitejs/plugin-vue': 6.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)) + '@vitejs/plugin-vue-jsx': 5.1.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)) autoprefixer: 10.4.21(postcss@8.5.6) consola: 3.4.2 cssnano: 7.1.2(postcss@8.5.6) @@ -8739,7 +8739,7 @@ snapshots: magic-string: 0.30.21 mlly: 1.8.0 mocked-exports: 0.1.1 - nuxt: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) + nuxt: 4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1) pathe: 2.0.3 pkg-types: 2.3.0 postcss: 8.5.6 @@ -8750,8 +8750,8 @@ snapshots: unenv: 2.0.0-rc.24 vite: 7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) vite-node: 3.2.4(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) - vite-plugin-checker: 0.11.0(eslint@9.29.0(jiti@2.6.1))(optionator@0.9.4)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)) - vue: 3.5.22(typescript@5.8.3) + vite-plugin-checker: 0.11.0(eslint@9.29.0(jiti@2.6.1))(optionator@0.9.4)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)) + vue: 3.5.22(typescript@5.9.3) vue-bundle-renderer: 2.2.0 transitivePeerDependencies: - '@biomejs/biome' @@ -9554,13 +9554,13 @@ snapshots: '@tanstack/query-core': 5.90.2 svelte: 5.43.3 - '@tanstack/vue-query@5.90.6(vue@3.5.22(typescript@5.8.3))': + '@tanstack/vue-query@5.90.6(vue@3.5.22(typescript@5.9.3))': dependencies: '@tanstack/match-sorter-utils': 8.19.4 '@tanstack/query-core': 5.90.6 '@vue/devtools-api': 6.6.4 - vue: 3.5.22(typescript@5.8.3) - vue-demi: 0.14.10(vue@3.5.22(typescript@5.8.3)) + vue: 3.5.22(typescript@5.9.3) + vue-demi: 0.14.10(vue@3.5.22(typescript@5.9.3)) '@testing-library/dom@10.4.1': dependencies: @@ -9730,79 +9730,79 @@ snapshots: '@types/whatwg-mimetype@3.0.2': {} - '@typescript-eslint/eslint-plugin@8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/parser': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.34.1 - '@typescript-eslint/type-utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/type-utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.34.1 eslint: 9.29.0(jiti@2.6.1) graphemer: 1.4.0 ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.46.2 - '@typescript-eslint/type-utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/type-utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.46.2 eslint: 9.29.0(jiti@2.6.1) graphemer: 1.4.0 ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.34.1 '@typescript-eslint/types': 8.34.1 - '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.34.1 debug: 4.4.1 eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.46.2 '@typescript-eslint/types': 8.46.2 - '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.46.2 debug: 4.4.1 eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.34.1(typescript@5.8.3)': + '@typescript-eslint/project-service@8.34.1(typescript@5.9.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.9.3) '@typescript-eslint/types': 8.34.1 debug: 4.4.1 - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.46.2(typescript@5.8.3)': + '@typescript-eslint/project-service@8.46.2(typescript@5.9.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.46.2(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.46.2(typescript@5.9.3) '@typescript-eslint/types': 8.46.2 debug: 4.4.1 - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -9816,34 +9816,34 @@ snapshots: '@typescript-eslint/types': 8.46.2 '@typescript-eslint/visitor-keys': 8.46.2 - '@typescript-eslint/tsconfig-utils@8.34.1(typescript@5.8.3)': + '@typescript-eslint/tsconfig-utils@8.34.1(typescript@5.9.3)': dependencies: - typescript: 5.8.3 + typescript: 5.9.3 - '@typescript-eslint/tsconfig-utils@8.46.2(typescript@5.8.3)': + '@typescript-eslint/tsconfig-utils@8.46.2(typescript@5.9.3)': dependencies: - typescript: 5.8.3 + typescript: 5.9.3 - '@typescript-eslint/type-utils@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/type-utils@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3) - '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.9.3) + '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) debug: 4.4.1 eslint: 9.29.0(jiti@2.6.1) - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/type-utils@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/type-utils@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.46.2 - '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.8.3) - '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) + '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) debug: 4.4.1 eslint: 9.29.0(jiti@2.6.1) - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -9851,10 +9851,10 @@ snapshots: '@typescript-eslint/types@8.46.2': {} - '@typescript-eslint/typescript-estree@8.34.1(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.34.1(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.34.1(typescript@5.8.3) - '@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3) + '@typescript-eslint/project-service': 8.34.1(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.9.3) '@typescript-eslint/types': 8.34.1 '@typescript-eslint/visitor-keys': 8.34.1 debug: 4.4.1 @@ -9862,15 +9862,15 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.7.2 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.46.2(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.46.2(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.46.2(typescript@5.8.3) - '@typescript-eslint/tsconfig-utils': 8.46.2(typescript@5.8.3) + '@typescript-eslint/project-service': 8.46.2(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.46.2(typescript@5.9.3) '@typescript-eslint/types': 8.46.2 '@typescript-eslint/visitor-keys': 8.46.2 debug: 4.4.1 @@ -9878,30 +9878,30 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.7.3 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/utils@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@eslint-community/eslint-utils': 4.7.0(eslint@9.29.0(jiti@2.6.1)) '@typescript-eslint/scope-manager': 8.34.1 '@typescript-eslint/types': 8.34.1 - '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.9.3) eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3)': + '@typescript-eslint/utils@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@eslint-community/eslint-utils': 4.7.0(eslint@9.29.0(jiti@2.6.1)) '@typescript-eslint/scope-manager': 8.46.2 '@typescript-eslint/types': 8.46.2 - '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -9915,11 +9915,11 @@ snapshots: '@typescript-eslint/types': 8.46.2 eslint-visitor-keys: 4.2.1 - '@unhead/vue@2.0.19(vue@3.5.22(typescript@5.8.3))': + '@unhead/vue@2.0.19(vue@3.5.22(typescript@5.9.3))': dependencies: hookable: 5.5.3 unhead: 2.0.19 - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) '@unrs/resolver-binding-android-arm-eabi@1.11.1': optional: true @@ -9999,7 +9999,7 @@ snapshots: - rollup - supports-color - '@vitejs/plugin-vue-jsx@5.1.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3))': + '@vitejs/plugin-vue-jsx@5.1.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3))': dependencies: '@babel/core': 7.28.5 '@babel/plugin-syntax-typescript': 7.27.1(@babel/core@7.28.5) @@ -10007,15 +10007,15 @@ snapshots: '@rolldown/pluginutils': 1.0.0-beta.45 '@vue/babel-plugin-jsx': 1.5.0(@babel/core@7.28.5) vite: 7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue@6.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3))': + '@vitejs/plugin-vue@6.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3))': dependencies: '@rolldown/pluginutils': 1.0.0-beta.29 vite: 7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) '@vitest/expect@3.2.4': dependencies: @@ -10065,7 +10065,7 @@ snapshots: '@volar/source-map@2.4.23': {} - '@vue-macros/common@3.1.1(vue@3.5.22(typescript@5.8.3))': + '@vue-macros/common@3.1.1(vue@3.5.22(typescript@5.9.3))': dependencies: '@vue/compiler-sfc': 3.5.22 ast-kit: 2.1.3 @@ -10073,7 +10073,7 @@ snapshots: magic-string-ast: 1.0.3 unplugin-utils: 0.3.1 optionalDependencies: - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) '@vue/babel-helper-vue-transform-on@1.5.0': {} @@ -10136,7 +10136,7 @@ snapshots: '@vue/devtools-api@6.6.4': {} - '@vue/devtools-core@7.7.7(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3))': + '@vue/devtools-core@7.7.7(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3))': dependencies: '@vue/devtools-kit': 7.7.7 '@vue/devtools-shared': 7.7.7 @@ -10144,7 +10144,7 @@ snapshots: nanoid: 5.1.6 pathe: 2.0.3 vite-hot-client: 2.1.0(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)) - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) transitivePeerDependencies: - vite @@ -10162,7 +10162,7 @@ snapshots: dependencies: rfdc: 1.4.1 - '@vue/language-core@3.1.2(typescript@5.8.3)': + '@vue/language-core@3.1.2(typescript@5.9.3)': dependencies: '@volar/language-core': 2.4.23 '@vue/compiler-dom': 3.5.22 @@ -10172,7 +10172,7 @@ snapshots: path-browserify: 1.0.1 picomatch: 4.0.3 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 '@vue/reactivity@3.5.22': dependencies: @@ -10190,11 +10190,11 @@ snapshots: '@vue/shared': 3.5.22 csstype: 3.1.3 - '@vue/server-renderer@3.5.22(vue@3.5.22(typescript@5.8.3))': + '@vue/server-renderer@3.5.22(vue@3.5.22(typescript@5.9.3))': dependencies: '@vue/compiler-ssr': 3.5.22 '@vue/shared': 3.5.22 - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) '@vue/shared@3.5.22': {} @@ -11042,7 +11042,7 @@ snapshots: electron-to-chromium@1.5.243: {} - elysia@1.4.13(@sinclair/typebox@0.34.41)(exact-mirror@0.2.2(@sinclair/typebox@0.34.41))(file-type@21.0.0)(openapi-types@12.1.3)(typescript@5.8.3): + elysia@1.4.13(@sinclair/typebox@0.34.41)(exact-mirror@0.2.2(@sinclair/typebox@0.34.41))(file-type@21.0.0)(openapi-types@12.1.3)(typescript@5.9.3): dependencies: '@sinclair/typebox': 0.34.41 cookie: 1.0.2 @@ -11052,7 +11052,7 @@ snapshots: memoirist: 0.4.0 openapi-types: 12.1.3 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 emoji-regex@8.0.0: {} @@ -11248,20 +11248,20 @@ snapshots: escape-string-regexp@5.0.0: {} - eslint-config-next@16.0.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3): + eslint-config-next@16.0.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3): dependencies: '@next/eslint-plugin-next': 16.0.1 eslint: 9.29.0(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react: 7.37.5(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react-hooks: 7.0.1(eslint@9.29.0(jiti@2.6.1)) globals: 16.4.0 - typescript-eslint: 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + typescript-eslint: 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - '@typescript-eslint/parser' - eslint-import-resolver-webpack @@ -11276,7 +11276,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.4.1 @@ -11287,22 +11287,22 @@ snapshots: tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): + eslint-module-utils@2.12.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): dependencies: debug: 3.2.7 optionalDependencies: - '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) eslint: 9.29.0(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -11313,7 +11313,7 @@ snapshots: doctrine: 2.1.0 eslint: 9.29.0(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 @@ -11325,7 +11325,7 @@ snapshots: string.prototype.trimend: 1.0.9 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -12844,17 +12844,17 @@ snapshots: dependencies: boolbase: 1.0.0 - nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1): + nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1): dependencies: '@dxup/nuxt': 0.2.0(magicast@0.5.0) '@nuxt/cli': 3.29.3(magicast@0.5.0) - '@nuxt/devtools': 2.7.0(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)) + '@nuxt/devtools': 2.7.0(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)) '@nuxt/kit': 4.2.0(magicast@0.5.0) - '@nuxt/nitro-server': 4.2.0(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(ioredis@5.8.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(typescript@5.8.3) + '@nuxt/nitro-server': 4.2.0(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(ioredis@5.8.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(typescript@5.9.3) '@nuxt/schema': 4.2.0 '@nuxt/telemetry': 2.6.6(magicast@0.5.0) - '@nuxt/vite-builder': 4.2.0(@types/node@20.19.24)(eslint@9.29.0(jiti@2.6.1))(lightningcss@1.30.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.8.3)(vue@3.5.22(typescript@5.8.3))(yaml@2.8.1) - '@unhead/vue': 2.0.19(vue@3.5.22(typescript@5.8.3)) + '@nuxt/vite-builder': 4.2.0(@types/node@20.19.24)(eslint@9.29.0(jiti@2.6.1))(lightningcss@1.30.2)(magicast@0.5.0)(nuxt@4.2.0(@parcel/watcher@2.5.1)(@types/node@20.19.24)(@vue/compiler-sfc@3.5.22)(better-sqlite3@12.2.0)(db0@0.3.4(better-sqlite3@12.2.0))(eslint@9.29.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.2)(magicast@0.5.0)(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(yaml@2.8.1))(optionator@0.9.4)(rollup@4.52.5)(terser@5.44.0)(tsx@4.20.3)(typescript@5.9.3)(vue@3.5.22(typescript@5.9.3))(yaml@2.8.1) + '@unhead/vue': 2.0.19(vue@3.5.22(typescript@5.9.3)) '@vue/shared': 3.5.22 c12: 3.3.1(magicast@0.5.0) chokidar: 4.0.3 @@ -12899,10 +12899,10 @@ snapshots: unctx: 2.4.1 unimport: 5.5.0 unplugin: 2.3.10 - unplugin-vue-router: 0.16.0(@vue/compiler-sfc@3.5.22)(typescript@5.8.3)(vue-router@4.6.3(vue@3.5.22(typescript@5.8.3)))(vue@3.5.22(typescript@5.8.3)) + unplugin-vue-router: 0.16.0(@vue/compiler-sfc@3.5.22)(typescript@5.9.3)(vue-router@4.6.3(vue@3.5.22(typescript@5.9.3)))(vue@3.5.22(typescript@5.9.3)) untyped: 2.0.0 - vue: 3.5.22(typescript@5.8.3) - vue-router: 4.6.3(vue@3.5.22(typescript@5.8.3)) + vue: 3.5.22(typescript@5.9.3) + vue-router: 4.6.3(vue@3.5.22(typescript@5.9.3)) optionalDependencies: '@parcel/watcher': 2.5.1 '@types/node': 20.19.24 @@ -13540,12 +13540,12 @@ snapshots: dependencies: parse-ms: 4.0.0 - prisma@6.19.0(magicast@0.3.5)(typescript@5.8.3): + prisma@6.19.0(magicast@0.3.5)(typescript@5.9.3): dependencies: '@prisma/config': 6.19.0(magicast@0.3.5) '@prisma/engines': 6.19.0 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - magicast @@ -14417,9 +14417,9 @@ snapshots: tree-kill@1.2.2: {} - ts-api-utils@2.1.0(typescript@5.8.3): + ts-api-utils@2.1.0(typescript@5.9.3): dependencies: - typescript: 5.8.3 + typescript: 5.9.3 ts-interface-checker@0.1.13: {} @@ -14438,7 +14438,7 @@ snapshots: tslib@2.8.1: {} - tsup@8.5.0(@swc/core@1.12.5)(jiti@2.6.1)(postcss@8.5.6)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0): + tsup@8.5.0(@swc/core@1.12.5)(jiti@2.6.1)(postcss@8.5.6)(tsx@4.20.3)(typescript@5.9.3)(yaml@2.8.0): dependencies: bundle-require: 5.1.0(esbuild@0.25.5) cac: 6.7.14 @@ -14460,7 +14460,7 @@ snapshots: optionalDependencies: '@swc/core': 1.12.5 postcss: 8.5.6 - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - jiti - supports-color @@ -14558,28 +14558,28 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript-eslint@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3): + typescript-eslint@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/parser': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/eslint-plugin': 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/parser': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - typescript-eslint@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3): + typescript-eslint@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) - '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.8.3) - '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.8.3) + '@typescript-eslint/eslint-plugin': 8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/parser': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) + '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) eslint: 9.29.0(jiti@2.6.1) - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - typescript@5.8.3: {} + typescript@5.9.3: {} ufo@1.6.1: {} @@ -14652,12 +14652,12 @@ snapshots: pathe: 2.0.3 picomatch: 4.0.3 - unplugin-vue-router@0.16.0(@vue/compiler-sfc@3.5.22)(typescript@5.8.3)(vue-router@4.6.3(vue@3.5.22(typescript@5.8.3)))(vue@3.5.22(typescript@5.8.3)): + unplugin-vue-router@0.16.0(@vue/compiler-sfc@3.5.22)(typescript@5.9.3)(vue-router@4.6.3(vue@3.5.22(typescript@5.9.3)))(vue@3.5.22(typescript@5.9.3)): dependencies: '@babel/generator': 7.28.5 - '@vue-macros/common': 3.1.1(vue@3.5.22(typescript@5.8.3)) + '@vue-macros/common': 3.1.1(vue@3.5.22(typescript@5.9.3)) '@vue/compiler-sfc': 3.5.22 - '@vue/language-core': 3.1.2(typescript@5.8.3) + '@vue/language-core': 3.1.2(typescript@5.9.3) ast-walker-scope: 0.8.3 chokidar: 4.0.3 json5: 2.2.3 @@ -14673,7 +14673,7 @@ snapshots: unplugin-utils: 0.3.1 yaml: 2.8.1 optionalDependencies: - vue-router: 4.6.3(vue@3.5.22(typescript@5.8.3)) + vue-router: 4.6.3(vue@3.5.22(typescript@5.9.3)) transitivePeerDependencies: - typescript - vue @@ -14818,7 +14818,7 @@ snapshots: - tsx - yaml - vite-plugin-checker@0.11.0(eslint@9.29.0(jiti@2.6.1))(optionator@0.9.4)(typescript@5.8.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)): + vite-plugin-checker@0.11.0(eslint@9.29.0(jiti@2.6.1))(optionator@0.9.4)(typescript@5.9.3)(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)): dependencies: '@babel/code-frame': 7.27.1 chokidar: 4.0.3 @@ -14832,7 +14832,7 @@ snapshots: optionalDependencies: eslint: 9.29.0(jiti@2.6.1) optionator: 0.9.4 - typescript: 5.8.3 + typescript: 5.9.3 vite-plugin-inspect@11.3.3(@nuxt/kit@3.20.0(magicast@0.3.5))(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1)): dependencies: @@ -14851,7 +14851,7 @@ snapshots: transitivePeerDependencies: - supports-color - vite-plugin-vue-tracer@1.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.8.3)): + vite-plugin-vue-tracer@1.0.1(vite@7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1))(vue@3.5.22(typescript@5.9.3)): dependencies: estree-walker: 3.0.3 exsolve: 1.0.7 @@ -14859,7 +14859,7 @@ snapshots: pathe: 2.0.3 source-map-js: 1.2.1 vite: 7.1.12(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.1) - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) vite@6.3.5(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.0): dependencies: @@ -14988,26 +14988,26 @@ snapshots: dependencies: ufo: 1.6.1 - vue-demi@0.14.10(vue@3.5.22(typescript@5.8.3)): + vue-demi@0.14.10(vue@3.5.22(typescript@5.9.3)): dependencies: - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) vue-devtools-stub@0.1.0: {} - vue-router@4.6.3(vue@3.5.22(typescript@5.8.3)): + vue-router@4.6.3(vue@3.5.22(typescript@5.9.3)): dependencies: '@vue/devtools-api': 6.6.4 - vue: 3.5.22(typescript@5.8.3) + vue: 3.5.22(typescript@5.9.3) - vue@3.5.22(typescript@5.8.3): + vue@3.5.22(typescript@5.9.3): dependencies: '@vue/compiler-dom': 3.5.22 '@vue/compiler-sfc': 3.5.22 '@vue/runtime-dom': 3.5.22 - '@vue/server-renderer': 3.5.22(vue@3.5.22(typescript@5.8.3)) + '@vue/server-renderer': 3.5.22(vue@3.5.22(typescript@5.9.3)) '@vue/shared': 3.5.22 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 w3c-xmlserializer@5.0.0: dependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 045fb619..e5cc8997 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -9,7 +9,7 @@ catalog: langium: 3.5.0 langium-cli: 3.5.0 ts-pattern: ^5.7.1 - typescript: ^5.8.0 + typescript: ^5.9.3 '@types/node': ^20.19.0 tmp: ^0.2.3 '@types/tmp': ^0.2.6 diff --git a/samples/next.js/package.json b/samples/next.js/package.json index 515ccd8d..67db4521 100644 --- a/samples/next.js/package.json +++ b/samples/next.js/package.json @@ -1,6 +1,6 @@ { "name": "next.js", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "private": true, "scripts": { "generate": "zen generate --lite", @@ -32,6 +32,6 @@ "eslint": "^9", "eslint-config-next": "16.0.1", "tailwindcss": "^4", - "typescript": "^5" + "typescript": "catalog:" } } diff --git a/samples/next.js/zenstack/input.ts b/samples/next.js/zenstack/input.ts index 31122290..7d1c6dbe 100644 --- a/samples/next.js/zenstack/input.ts +++ b/samples/next.js/zenstack/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema-lite"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -47,4 +47,4 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; diff --git a/samples/orm/package.json b/samples/orm/package.json index c088f015..8a4663f4 100644 --- a/samples/orm/package.json +++ b/samples/orm/package.json @@ -1,6 +1,6 @@ { "name": "sample-blog", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "description": "", "main": "index.js", "private": true, diff --git a/samples/orm/zenstack/input.ts b/samples/orm/zenstack/input.ts index c10942b2..c5ead56d 100644 --- a/samples/orm/zenstack/input.ts +++ b/samples/orm/zenstack/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; @@ -47,7 +47,7 @@ export type ProfileWhereInput = $WhereInput<$Schema, "Profile">; export type ProfileSelect = $SelectInput<$Schema, "Profile">; export type ProfileInclude = $IncludeInput<$Schema, "Profile">; export type ProfileOmit = $OmitInput<$Schema, "Profile">; -export type ProfileGetPayload> = $SimplifiedModelResult<$Schema, "Profile", Args>; +export type ProfileGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Profile", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -67,4 +67,4 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; diff --git a/tests/e2e/apps/rally/rally.test.ts b/tests/e2e/apps/rally/rally.test.ts index e14b8798..5b204275 100644 --- a/tests/e2e/apps/rally/rally.test.ts +++ b/tests/e2e/apps/rally/rally.test.ts @@ -17,7 +17,6 @@ describe('Rally app tests', () => { destination: 'models', }, ], - debug: true, dataSourceExtensions: ['citext'], usePrismaPush: true, }); diff --git a/tests/e2e/apps/rally/zenstack/input.ts b/tests/e2e/apps/rally/zenstack/input.ts index 65715c19..fcb5ede6 100644 --- a/tests/e2e/apps/rally/zenstack/input.ts +++ b/tests/e2e/apps/rally/zenstack/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type AccountFindManyArgs = $FindManyArgs<$Schema, "Account">; export type AccountFindUniqueArgs = $FindUniqueArgs<$Schema, "Account">; @@ -27,7 +27,7 @@ export type AccountWhereInput = $WhereInput<$Schema, "Account">; export type AccountSelect = $SelectInput<$Schema, "Account">; export type AccountInclude = $IncludeInput<$Schema, "Account">; export type AccountOmit = $OmitInput<$Schema, "Account">; -export type AccountGetPayload> = $SimplifiedModelResult<$Schema, "Account", Args>; +export type AccountGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Account", Options, Args>; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">; @@ -47,7 +47,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type VerificationTokenFindManyArgs = $FindManyArgs<$Schema, "VerificationToken">; export type VerificationTokenFindUniqueArgs = $FindUniqueArgs<$Schema, "VerificationToken">; export type VerificationTokenFindFirstArgs = $FindFirstArgs<$Schema, "VerificationToken">; @@ -67,7 +67,7 @@ export type VerificationTokenWhereInput = $WhereInput<$Schema, "VerificationToke export type VerificationTokenSelect = $SelectInput<$Schema, "VerificationToken">; export type VerificationTokenInclude = $IncludeInput<$Schema, "VerificationToken">; export type VerificationTokenOmit = $OmitInput<$Schema, "VerificationToken">; -export type VerificationTokenGetPayload> = $SimplifiedModelResult<$Schema, "VerificationToken", Args>; +export type VerificationTokenGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "VerificationToken", Options, Args>; export type SessionFindManyArgs = $FindManyArgs<$Schema, "Session">; export type SessionFindUniqueArgs = $FindUniqueArgs<$Schema, "Session">; export type SessionFindFirstArgs = $FindFirstArgs<$Schema, "Session">; @@ -87,7 +87,7 @@ export type SessionWhereInput = $WhereInput<$Schema, "Session">; export type SessionSelect = $SelectInput<$Schema, "Session">; export type SessionInclude = $IncludeInput<$Schema, "Session">; export type SessionOmit = $OmitInput<$Schema, "Session">; -export type SessionGetPayload> = $SimplifiedModelResult<$Schema, "Session", Args>; +export type SessionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Session", Options, Args>; export type VerificationFindManyArgs = $FindManyArgs<$Schema, "Verification">; export type VerificationFindUniqueArgs = $FindUniqueArgs<$Schema, "Verification">; export type VerificationFindFirstArgs = $FindFirstArgs<$Schema, "Verification">; @@ -107,7 +107,7 @@ export type VerificationWhereInput = $WhereInput<$Schema, "Verification">; export type VerificationSelect = $SelectInput<$Schema, "Verification">; export type VerificationInclude = $IncludeInput<$Schema, "Verification">; export type VerificationOmit = $OmitInput<$Schema, "Verification">; -export type VerificationGetPayload> = $SimplifiedModelResult<$Schema, "Verification", Args>; +export type VerificationGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Verification", Options, Args>; export type PollFindManyArgs = $FindManyArgs<$Schema, "Poll">; export type PollFindUniqueArgs = $FindUniqueArgs<$Schema, "Poll">; export type PollFindFirstArgs = $FindFirstArgs<$Schema, "Poll">; @@ -127,7 +127,7 @@ export type PollWhereInput = $WhereInput<$Schema, "Poll">; export type PollSelect = $SelectInput<$Schema, "Poll">; export type PollInclude = $IncludeInput<$Schema, "Poll">; export type PollOmit = $OmitInput<$Schema, "Poll">; -export type PollGetPayload> = $SimplifiedModelResult<$Schema, "Poll", Args>; +export type PollGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Poll", Options, Args>; export type WatcherFindManyArgs = $FindManyArgs<$Schema, "Watcher">; export type WatcherFindUniqueArgs = $FindUniqueArgs<$Schema, "Watcher">; export type WatcherFindFirstArgs = $FindFirstArgs<$Schema, "Watcher">; @@ -147,7 +147,7 @@ export type WatcherWhereInput = $WhereInput<$Schema, "Watcher">; export type WatcherSelect = $SelectInput<$Schema, "Watcher">; export type WatcherInclude = $IncludeInput<$Schema, "Watcher">; export type WatcherOmit = $OmitInput<$Schema, "Watcher">; -export type WatcherGetPayload> = $SimplifiedModelResult<$Schema, "Watcher", Args>; +export type WatcherGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Watcher", Options, Args>; export type ParticipantFindManyArgs = $FindManyArgs<$Schema, "Participant">; export type ParticipantFindUniqueArgs = $FindUniqueArgs<$Schema, "Participant">; export type ParticipantFindFirstArgs = $FindFirstArgs<$Schema, "Participant">; @@ -167,7 +167,7 @@ export type ParticipantWhereInput = $WhereInput<$Schema, "Participant">; export type ParticipantSelect = $SelectInput<$Schema, "Participant">; export type ParticipantInclude = $IncludeInput<$Schema, "Participant">; export type ParticipantOmit = $OmitInput<$Schema, "Participant">; -export type ParticipantGetPayload> = $SimplifiedModelResult<$Schema, "Participant", Args>; +export type ParticipantGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Participant", Options, Args>; export type OptionFindManyArgs = $FindManyArgs<$Schema, "Option">; export type OptionFindUniqueArgs = $FindUniqueArgs<$Schema, "Option">; export type OptionFindFirstArgs = $FindFirstArgs<$Schema, "Option">; @@ -187,7 +187,7 @@ export type OptionWhereInput = $WhereInput<$Schema, "Option">; export type OptionSelect = $SelectInput<$Schema, "Option">; export type OptionInclude = $IncludeInput<$Schema, "Option">; export type OptionOmit = $OmitInput<$Schema, "Option">; -export type OptionGetPayload> = $SimplifiedModelResult<$Schema, "Option", Args>; +export type OptionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Option", Options, Args>; export type VoteFindManyArgs = $FindManyArgs<$Schema, "Vote">; export type VoteFindUniqueArgs = $FindUniqueArgs<$Schema, "Vote">; export type VoteFindFirstArgs = $FindFirstArgs<$Schema, "Vote">; @@ -207,7 +207,7 @@ export type VoteWhereInput = $WhereInput<$Schema, "Vote">; export type VoteSelect = $SelectInput<$Schema, "Vote">; export type VoteInclude = $IncludeInput<$Schema, "Vote">; export type VoteOmit = $OmitInput<$Schema, "Vote">; -export type VoteGetPayload> = $SimplifiedModelResult<$Schema, "Vote", Args>; +export type VoteGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Vote", Options, Args>; export type CommentFindManyArgs = $FindManyArgs<$Schema, "Comment">; export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, "Comment">; export type CommentFindFirstArgs = $FindFirstArgs<$Schema, "Comment">; @@ -227,7 +227,7 @@ export type CommentWhereInput = $WhereInput<$Schema, "Comment">; export type CommentSelect = $SelectInput<$Schema, "Comment">; export type CommentInclude = $IncludeInput<$Schema, "Comment">; export type CommentOmit = $OmitInput<$Schema, "Comment">; -export type CommentGetPayload> = $SimplifiedModelResult<$Schema, "Comment", Args>; +export type CommentGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Comment", Options, Args>; export type PollViewFindManyArgs = $FindManyArgs<$Schema, "PollView">; export type PollViewFindUniqueArgs = $FindUniqueArgs<$Schema, "PollView">; export type PollViewFindFirstArgs = $FindFirstArgs<$Schema, "PollView">; @@ -247,7 +247,7 @@ export type PollViewWhereInput = $WhereInput<$Schema, "PollView">; export type PollViewSelect = $SelectInput<$Schema, "PollView">; export type PollViewInclude = $IncludeInput<$Schema, "PollView">; export type PollViewOmit = $OmitInput<$Schema, "PollView">; -export type PollViewGetPayload> = $SimplifiedModelResult<$Schema, "PollView", Args>; +export type PollViewGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "PollView", Options, Args>; export type SpaceFindManyArgs = $FindManyArgs<$Schema, "Space">; export type SpaceFindUniqueArgs = $FindUniqueArgs<$Schema, "Space">; export type SpaceFindFirstArgs = $FindFirstArgs<$Schema, "Space">; @@ -267,7 +267,7 @@ export type SpaceWhereInput = $WhereInput<$Schema, "Space">; export type SpaceSelect = $SelectInput<$Schema, "Space">; export type SpaceInclude = $IncludeInput<$Schema, "Space">; export type SpaceOmit = $OmitInput<$Schema, "Space">; -export type SpaceGetPayload> = $SimplifiedModelResult<$Schema, "Space", Args>; +export type SpaceGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Space", Options, Args>; export type SpaceMemberFindManyArgs = $FindManyArgs<$Schema, "SpaceMember">; export type SpaceMemberFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceMember">; export type SpaceMemberFindFirstArgs = $FindFirstArgs<$Schema, "SpaceMember">; @@ -287,7 +287,7 @@ export type SpaceMemberWhereInput = $WhereInput<$Schema, "SpaceMember">; export type SpaceMemberSelect = $SelectInput<$Schema, "SpaceMember">; export type SpaceMemberInclude = $IncludeInput<$Schema, "SpaceMember">; export type SpaceMemberOmit = $OmitInput<$Schema, "SpaceMember">; -export type SpaceMemberGetPayload> = $SimplifiedModelResult<$Schema, "SpaceMember", Args>; +export type SpaceMemberGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "SpaceMember", Options, Args>; export type SpaceMemberInviteFindManyArgs = $FindManyArgs<$Schema, "SpaceMemberInvite">; export type SpaceMemberInviteFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceMemberInvite">; export type SpaceMemberInviteFindFirstArgs = $FindFirstArgs<$Schema, "SpaceMemberInvite">; @@ -307,7 +307,7 @@ export type SpaceMemberInviteWhereInput = $WhereInput<$Schema, "SpaceMemberInvit export type SpaceMemberInviteSelect = $SelectInput<$Schema, "SpaceMemberInvite">; export type SpaceMemberInviteInclude = $IncludeInput<$Schema, "SpaceMemberInvite">; export type SpaceMemberInviteOmit = $OmitInput<$Schema, "SpaceMemberInvite">; -export type SpaceMemberInviteGetPayload> = $SimplifiedModelResult<$Schema, "SpaceMemberInvite", Args>; +export type SpaceMemberInviteGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "SpaceMemberInvite", Options, Args>; export type SubscriptionFindManyArgs = $FindManyArgs<$Schema, "Subscription">; export type SubscriptionFindUniqueArgs = $FindUniqueArgs<$Schema, "Subscription">; export type SubscriptionFindFirstArgs = $FindFirstArgs<$Schema, "Subscription">; @@ -327,7 +327,7 @@ export type SubscriptionWhereInput = $WhereInput<$Schema, "Subscription">; export type SubscriptionSelect = $SelectInput<$Schema, "Subscription">; export type SubscriptionInclude = $IncludeInput<$Schema, "Subscription">; export type SubscriptionOmit = $OmitInput<$Schema, "Subscription">; -export type SubscriptionGetPayload> = $SimplifiedModelResult<$Schema, "Subscription", Args>; +export type SubscriptionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Subscription", Options, Args>; export type PaymentMethodFindManyArgs = $FindManyArgs<$Schema, "PaymentMethod">; export type PaymentMethodFindUniqueArgs = $FindUniqueArgs<$Schema, "PaymentMethod">; export type PaymentMethodFindFirstArgs = $FindFirstArgs<$Schema, "PaymentMethod">; @@ -347,7 +347,7 @@ export type PaymentMethodWhereInput = $WhereInput<$Schema, "PaymentMethod">; export type PaymentMethodSelect = $SelectInput<$Schema, "PaymentMethod">; export type PaymentMethodInclude = $IncludeInput<$Schema, "PaymentMethod">; export type PaymentMethodOmit = $OmitInput<$Schema, "PaymentMethod">; -export type PaymentMethodGetPayload> = $SimplifiedModelResult<$Schema, "PaymentMethod", Args>; +export type PaymentMethodGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "PaymentMethod", Options, Args>; export type ScheduledEventFindManyArgs = $FindManyArgs<$Schema, "ScheduledEvent">; export type ScheduledEventFindUniqueArgs = $FindUniqueArgs<$Schema, "ScheduledEvent">; export type ScheduledEventFindFirstArgs = $FindFirstArgs<$Schema, "ScheduledEvent">; @@ -367,7 +367,7 @@ export type ScheduledEventWhereInput = $WhereInput<$Schema, "ScheduledEvent">; export type ScheduledEventSelect = $SelectInput<$Schema, "ScheduledEvent">; export type ScheduledEventInclude = $IncludeInput<$Schema, "ScheduledEvent">; export type ScheduledEventOmit = $OmitInput<$Schema, "ScheduledEvent">; -export type ScheduledEventGetPayload> = $SimplifiedModelResult<$Schema, "ScheduledEvent", Args>; +export type ScheduledEventGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "ScheduledEvent", Options, Args>; export type RescheduledEventDateFindManyArgs = $FindManyArgs<$Schema, "RescheduledEventDate">; export type RescheduledEventDateFindUniqueArgs = $FindUniqueArgs<$Schema, "RescheduledEventDate">; export type RescheduledEventDateFindFirstArgs = $FindFirstArgs<$Schema, "RescheduledEventDate">; @@ -387,7 +387,7 @@ export type RescheduledEventDateWhereInput = $WhereInput<$Schema, "RescheduledEv export type RescheduledEventDateSelect = $SelectInput<$Schema, "RescheduledEventDate">; export type RescheduledEventDateInclude = $IncludeInput<$Schema, "RescheduledEventDate">; export type RescheduledEventDateOmit = $OmitInput<$Schema, "RescheduledEventDate">; -export type RescheduledEventDateGetPayload> = $SimplifiedModelResult<$Schema, "RescheduledEventDate", Args>; +export type RescheduledEventDateGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "RescheduledEventDate", Options, Args>; export type ScheduledEventInviteFindManyArgs = $FindManyArgs<$Schema, "ScheduledEventInvite">; export type ScheduledEventInviteFindUniqueArgs = $FindUniqueArgs<$Schema, "ScheduledEventInvite">; export type ScheduledEventInviteFindFirstArgs = $FindFirstArgs<$Schema, "ScheduledEventInvite">; @@ -407,7 +407,7 @@ export type ScheduledEventInviteWhereInput = $WhereInput<$Schema, "ScheduledEven export type ScheduledEventInviteSelect = $SelectInput<$Schema, "ScheduledEventInvite">; export type ScheduledEventInviteInclude = $IncludeInput<$Schema, "ScheduledEventInvite">; export type ScheduledEventInviteOmit = $OmitInput<$Schema, "ScheduledEventInvite">; -export type ScheduledEventInviteGetPayload> = $SimplifiedModelResult<$Schema, "ScheduledEventInvite", Args>; +export type ScheduledEventInviteGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "ScheduledEventInvite", Options, Args>; export type CredentialFindManyArgs = $FindManyArgs<$Schema, "Credential">; export type CredentialFindUniqueArgs = $FindUniqueArgs<$Schema, "Credential">; export type CredentialFindFirstArgs = $FindFirstArgs<$Schema, "Credential">; @@ -427,7 +427,7 @@ export type CredentialWhereInput = $WhereInput<$Schema, "Credential">; export type CredentialSelect = $SelectInput<$Schema, "Credential">; export type CredentialInclude = $IncludeInput<$Schema, "Credential">; export type CredentialOmit = $OmitInput<$Schema, "Credential">; -export type CredentialGetPayload> = $SimplifiedModelResult<$Schema, "Credential", Args>; +export type CredentialGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Credential", Options, Args>; export type CalendarConnectionFindManyArgs = $FindManyArgs<$Schema, "CalendarConnection">; export type CalendarConnectionFindUniqueArgs = $FindUniqueArgs<$Schema, "CalendarConnection">; export type CalendarConnectionFindFirstArgs = $FindFirstArgs<$Schema, "CalendarConnection">; @@ -447,7 +447,7 @@ export type CalendarConnectionWhereInput = $WhereInput<$Schema, "CalendarConnect export type CalendarConnectionSelect = $SelectInput<$Schema, "CalendarConnection">; export type CalendarConnectionInclude = $IncludeInput<$Schema, "CalendarConnection">; export type CalendarConnectionOmit = $OmitInput<$Schema, "CalendarConnection">; -export type CalendarConnectionGetPayload> = $SimplifiedModelResult<$Schema, "CalendarConnection", Args>; +export type CalendarConnectionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "CalendarConnection", Options, Args>; export type ProviderCalendarFindManyArgs = $FindManyArgs<$Schema, "ProviderCalendar">; export type ProviderCalendarFindUniqueArgs = $FindUniqueArgs<$Schema, "ProviderCalendar">; export type ProviderCalendarFindFirstArgs = $FindFirstArgs<$Schema, "ProviderCalendar">; @@ -467,7 +467,7 @@ export type ProviderCalendarWhereInput = $WhereInput<$Schema, "ProviderCalendar" export type ProviderCalendarSelect = $SelectInput<$Schema, "ProviderCalendar">; export type ProviderCalendarInclude = $IncludeInput<$Schema, "ProviderCalendar">; export type ProviderCalendarOmit = $OmitInput<$Schema, "ProviderCalendar">; -export type ProviderCalendarGetPayload> = $SimplifiedModelResult<$Schema, "ProviderCalendar", Args>; +export type ProviderCalendarGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "ProviderCalendar", Options, Args>; export type InstanceSettingsFindManyArgs = $FindManyArgs<$Schema, "InstanceSettings">; export type InstanceSettingsFindUniqueArgs = $FindUniqueArgs<$Schema, "InstanceSettings">; export type InstanceSettingsFindFirstArgs = $FindFirstArgs<$Schema, "InstanceSettings">; @@ -487,7 +487,7 @@ export type InstanceSettingsWhereInput = $WhereInput<$Schema, "InstanceSettings" export type InstanceSettingsSelect = $SelectInput<$Schema, "InstanceSettings">; export type InstanceSettingsInclude = $IncludeInput<$Schema, "InstanceSettings">; export type InstanceSettingsOmit = $OmitInput<$Schema, "InstanceSettings">; -export type InstanceSettingsGetPayload> = $SimplifiedModelResult<$Schema, "InstanceSettings", Args>; +export type InstanceSettingsGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "InstanceSettings", Options, Args>; export type LicenseFindManyArgs = $FindManyArgs<$Schema, "License">; export type LicenseFindUniqueArgs = $FindUniqueArgs<$Schema, "License">; export type LicenseFindFirstArgs = $FindFirstArgs<$Schema, "License">; @@ -507,7 +507,7 @@ export type LicenseWhereInput = $WhereInput<$Schema, "License">; export type LicenseSelect = $SelectInput<$Schema, "License">; export type LicenseInclude = $IncludeInput<$Schema, "License">; export type LicenseOmit = $OmitInput<$Schema, "License">; -export type LicenseGetPayload> = $SimplifiedModelResult<$Schema, "License", Args>; +export type LicenseGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "License", Options, Args>; export type LicenseValidationFindManyArgs = $FindManyArgs<$Schema, "LicenseValidation">; export type LicenseValidationFindUniqueArgs = $FindUniqueArgs<$Schema, "LicenseValidation">; export type LicenseValidationFindFirstArgs = $FindFirstArgs<$Schema, "LicenseValidation">; @@ -527,7 +527,7 @@ export type LicenseValidationWhereInput = $WhereInput<$Schema, "LicenseValidatio export type LicenseValidationSelect = $SelectInput<$Schema, "LicenseValidation">; export type LicenseValidationInclude = $IncludeInput<$Schema, "LicenseValidation">; export type LicenseValidationOmit = $OmitInput<$Schema, "LicenseValidation">; -export type LicenseValidationGetPayload> = $SimplifiedModelResult<$Schema, "LicenseValidation", Args>; +export type LicenseValidationGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "LicenseValidation", Options, Args>; export type InstanceLicenseFindManyArgs = $FindManyArgs<$Schema, "InstanceLicense">; export type InstanceLicenseFindUniqueArgs = $FindUniqueArgs<$Schema, "InstanceLicense">; export type InstanceLicenseFindFirstArgs = $FindFirstArgs<$Schema, "InstanceLicense">; @@ -547,4 +547,4 @@ export type InstanceLicenseWhereInput = $WhereInput<$Schema, "InstanceLicense">; export type InstanceLicenseSelect = $SelectInput<$Schema, "InstanceLicense">; export type InstanceLicenseInclude = $IncludeInput<$Schema, "InstanceLicense">; export type InstanceLicenseOmit = $OmitInput<$Schema, "InstanceLicense">; -export type InstanceLicenseGetPayload> = $SimplifiedModelResult<$Schema, "InstanceLicense", Args>; +export type InstanceLicenseGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "InstanceLicense", Options, Args>; diff --git a/tests/e2e/orm/client-api/auth-typing.test.ts b/tests/e2e/orm/client-api/auth-typing.test.ts new file mode 100644 index 00000000..ce510227 --- /dev/null +++ b/tests/e2e/orm/client-api/auth-typing.test.ts @@ -0,0 +1,18 @@ +import { createTestClient } from '@zenstackhq/testtools'; +import { describe, it } from 'vitest'; +import { schema } from '../schemas/auth-type/schema'; + +describe('Custom auth typing tests', () => { + it('works with custom auth typing', async () => { + const db = await createTestClient(schema); + db.$setAuth({ + id: 1, + role: 'ADMIN', + permissions: [ + { + actionCode: 'MANAGE', + }, + ], + }); + }); +}); diff --git a/tests/e2e/orm/client-api/ignore.test.ts b/tests/e2e/orm/client-api/ignore.test.ts new file mode 100644 index 00000000..3a4e8022 --- /dev/null +++ b/tests/e2e/orm/client-api/ignore.test.ts @@ -0,0 +1,30 @@ +import type { DefaultModelResult } from '@zenstackhq/orm'; +import { createTestClient } from '@zenstackhq/testtools'; +import { describe, expect, it } from 'vitest'; +import { schema } from '../schemas/basic'; + +describe('Ignored models and fields test', () => { + it('correctly ignores fields', async () => { + const db = await createTestClient(schema); + db.user.findFirst({ + // @ts-expect-error + where: { password: 'abc' }, + }); + + const user = await db.user.create({ data: { email: 'u1@test.com' } }); + // @ts-expect-error + expect(user.password).toBeUndefined(); + + const u: DefaultModelResult = {} as any; + // @ts-expect-error + noop(u.password); + }); + + it('correctly ignores models', async () => { + const db = await createTestClient(schema); + // @ts-expect-error + expect(db.foo).toBeUndefined(); + }); +}); + +function noop(_value: unknown) {} diff --git a/tests/e2e/orm/client-api/omit.test.ts b/tests/e2e/orm/client-api/omit.test.ts new file mode 100644 index 00000000..7cabe4d8 --- /dev/null +++ b/tests/e2e/orm/client-api/omit.test.ts @@ -0,0 +1,162 @@ +import { createTestClient } from '@zenstackhq/testtools'; +import { describe, expect, it } from 'vitest'; +import { schema } from '../schemas/omit/schema'; + +describe('Field omission tests', () => { + it('respects schema-level omit', async () => { + const db = await createTestClient(schema); + const user = await db.user.create({ + data: { id: 1, name: 'User1', password: 'abc', posts: { create: { id: 1, title: 'Post1' } } }, + }); + // @ts-expect-error + expect(user.password).toBeUndefined(); + + const user1 = await db.user.findFirstOrThrow(); + // @ts-expect-error + expect(user1.password).toBeUndefined(); + + const userWithPosts = await db.user.findFirstOrThrow({ include: { posts: true } }); + // @ts-expect-error + expect(userWithPosts.password).toBeUndefined(); + + const user2 = await db.user.update({ + where: { id: 1 }, + data: { name: 'User2' }, + }); + + // @ts-expect-error + expect(user2.password).toBeUndefined(); + + const data = await db.post.findFirstOrThrow({ include: { author: true } }); + // @ts-expect-error + expect(data.author.password).toBeUndefined(); + + const user3 = await db.user.delete({ where: { id: 1 } }); + // @ts-expect-error + expect(user3.password).toBeUndefined(); + }); + + it('respects client omit options', async () => { + const options = { omit: { User: { name: true } }, dialect: {} as any } as const; + const db = await createTestClient(schema, options); + + const user = await db.user.create({ + data: { + id: 1, + name: 'User1', + password: 'abc', + posts: { create: { id: 1, title: 'Post1' } }, + }, + }); + + // inherited omit from schema + // @ts-expect-error + expect(user.password).toBeUndefined(); + + // options-level omit + // @ts-expect-error + expect(user.name).toBeUndefined(); + + const post = await db.post.findFirstOrThrow({ include: { author: true } }); + // @ts-expect-error + expect(post.author.password).toBeUndefined(); + // @ts-expect-error + expect(post.author.name).toBeUndefined(); + }); + + it('allows override at query options level', async () => { + // override schema-level omit + const options = { omit: { User: { password: false } }, dialect: {} as any } as const; + const db = await createTestClient(schema, options); + const user1 = await db.user.create({ + data: { + id: 1, + name: 'User1', + password: 'abc', + }, + }); + expect(user1.password).toBeTruthy(); + }); + + it('respects query-level omit', async () => { + const db = await createTestClient(schema); + const user = await db.user.create({ + data: { id: 1, name: 'User1', password: 'abc', posts: { create: { id: 1, title: 'Post1' } } }, + omit: { password: false }, + }); + expect(user.password).toBeTruthy(); + + const user1 = await db.user.findFirstOrThrow({ omit: { password: false } }); + expect(user1.password).toBeTruthy(); + + const user11 = await db.user.findFirstOrThrow({ omit: { name: true } }); + // @ts-expect-error + expect(user11.name).toBeUndefined(); + + const user2 = await db.user.findFirstOrThrow({ omit: { password: true } }); + // @ts-expect-error + expect(user2.password).toBeUndefined(); + + // override schema-level omit + const user3 = await db.user.update({ + where: { id: 1 }, + data: { name: 'User2' }, + omit: { password: false }, + }); + expect(user3.password).toBeTruthy(); + + const data = await db.post.findFirstOrThrow({ include: { author: { omit: { password: false } } } }); + expect(data.author.password).toBeTruthy(); + + const user4 = await db.user.delete({ where: { id: 1 }, omit: { password: false } }); + expect(user4.password).toBeTruthy(); + }); + + it('allows override at query level', async () => { + // override options-level omit + const options = { omit: { User: { name: true } }, dialect: {} as any } as const; + const db = await createTestClient(schema, options); + const user5 = await db.user.create({ + data: { id: 2, name: 'User2', password: 'abc' }, + }); + // @ts-expect-error + expect(user5.name).toBeUndefined(); + const user6 = await db.user.findFirstOrThrow({ omit: { name: false } }); + expect(user6.name).toBeTruthy(); + }); + + it('works with delegate models', async () => { + const db = await createTestClient(schema); + const sub = await db.sub.create({ + data: { id: 1, title: 'Sub1', content: 'Foo' }, + }); + // @ts-expect-error + expect(sub.content).toBeUndefined(); + + const read = await db.sub.findFirstOrThrow(); + // @ts-expect-error + expect(read.content).toBeUndefined(); + + const read1 = await db.sub.findFirstOrThrow({ omit: { content: false } }); + expect(read1.content).toBe('Foo'); + }); + + it('respects query-level omit override settings', async () => { + const base = await createTestClient(schema); + const db = base.$setOptions({ ...base.$options, allowQueryTimeOmitOverride: false }); + await expect( + db.user.create({ + data: { id: 1, name: 'User1', password: 'abc' }, + omit: { password: false }, + }), + ).toBeRejectedByValidation(); + + await db.user.create({ data: { id: 1, name: 'User1', password: 'abc' } }); + await expect(db.user.findFirstOrThrow({ omit: { password: false } })).toBeRejectedByValidation(); + + // allow set omit as true + const user = await db.user.findFirstOrThrow({ omit: { name: true } }); + // @ts-expect-error + expect(user.name).toBeUndefined(); + }); +}); diff --git a/tests/e2e/orm/policy/auth-access.test.ts b/tests/e2e/orm/policy/auth-access.test.ts new file mode 100644 index 00000000..b994324f --- /dev/null +++ b/tests/e2e/orm/policy/auth-access.test.ts @@ -0,0 +1,436 @@ +import { createPolicyTestClient } from '@zenstackhq/testtools'; +import { describe, expect, it } from 'vitest'; + +describe('Auth access tests', () => { + it('works with simple auth model', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + age Int +} + +model Foo { + id Int @id + name String + @@allow('all', auth().age > 18) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ age: 15 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ age: 20 }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with simple auth type', async () => { + const db = await createPolicyTestClient( + ` +type User { + age Int + @@auth +} + +model Foo { + id Int @id + name String + @@allow('all', auth().age > 18) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ age: 15 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ age: 20 }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with deep model value access', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profile Profile? +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int @unique + age Int +} + +model Foo { + id Int @id + name String + @@allow('all', auth().profile.age > 18) +}`, + ); + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profile: { age: 15 } }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profile: { age: 20 } }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with deep type value access', async () => { + const db = await createPolicyTestClient( + ` +type User { + profile Profile? + @@auth +} + +type Profile { + age Int +} + +model Foo { + id Int @id + name String + @@allow('all', auth().profile.age > 18) +}`, + ); + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({}).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profile: { age: 15 } }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profile: { age: 20 } }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with shallow auth model simple collection predicates', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profiles Profile[] +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + age Int +} + +model Foo { + id Int @id + name String + @@allow('all', auth().profiles?[age > 18]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [{ age: 15 }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profiles: [{ age: 20 }] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ profiles: [{ age: 15 }, { age: 20 }] }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with shallow auth model collection predicates involving fields - some', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profiles Profile[] +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + age Int +} + +model Foo { + id Int @id + name String + requiredAge Int + @@allow('all', auth().profiles?[age >= this.requiredAge]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test', requiredAge: 18 } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [{ age: 15 }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profiles: [{ age: 20 }] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ profiles: [{ age: 15 }, { age: 20 }] }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with deep auth model simple collection predicates', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profiles Profile[] +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + records ProfileRecord[] +} + +model ProfileRecord { + id Int @id + age Int + profile Profile @relation(fields: [profileId], references: [id]) + profileId Int +} + +model Foo { + id Int @id + name String + @@allow('all', auth().profiles?[records?[age > 18]]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test' } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [{ records: [] }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [{ records: [{ age: 15 }] }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profiles: [{ records: [{ age: 20 }] }] }).foo.findFirst()).toResolveTruthy(); + await expect( + db.$setAuth({ profiles: [{ records: [{ age: 15 }] }, { records: [{ age: 20 }] }] }).foo.findFirst(), + ).toResolveTruthy(); + await expect( + db.$setAuth({ profiles: [{ records: [{ age: 15 }, { age: 20 }] }] }).foo.findFirst(), + ).toResolveTruthy(); + }); + + it('works with shallow auth type collection predicates involving fields - some', async () => { + const db = await createPolicyTestClient( + ` +type User { + profiles Profile[] +} + +type Profile { + age Int +} + +model Foo { + id Int @id + name String + requiredAge Int + @@allow('all', auth().profiles?[age >= this.requiredAge]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test', requiredAge: 18 } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [{ age: 15 }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profiles: [{ age: 20 }] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ profiles: [{ age: 15 }, { age: 20 }] }).foo.findFirst()).toResolveTruthy(); + }); + + it('works with shallow auth model collection predicates involving fields - every', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profiles Profile[] +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + age Int +} + +model Foo { + id Int @id + name String + requiredAge Int + @@allow('all', auth().profiles![age >= this.requiredAge]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test', requiredAge: 18 } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ id: 1, profiles: [{ age: 15 }] }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ profiles: [{ age: 18 }, { age: 20 }] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ profiles: [{ age: 15 }, { age: 20 }] }).foo.findFirst()).toResolveFalsy(); + }); + + it('works with shallow auth model collection predicates involving fields - none', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + profiles Profile[] +} + +model Profile { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + age Int +} + +model Foo { + id Int @id + name String + requiredAge Int + @@allow('all', auth().profiles^[age >= this.requiredAge]) +} +`, + ); + + await db.$unuseAll().foo.create({ data: { id: 1, name: 'Test', requiredAge: 18 } }); + await expect(db.foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).foo.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, profiles: [] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ id: 1, profiles: [{ age: 15 }] }).foo.findFirst()).toResolveTruthy(); + await expect(db.$setAuth({ profiles: [{ age: 15 }, { age: 18 }] }).foo.findFirst()).toResolveNull(); + }); + + it('works with deep auth model collection predicates involving fields', async () => { + const db = await createPolicyTestClient( + ` +model User { + id Int @id + roles Role[] +} + +model Role { + id Int @id + user User @relation(fields: [userId], references: [id]) + userId Int + permissions Permission[] +} + +model Permission { + id Int @id + role Role @relation(fields: [roleId], references: [id]) + roleId Int + canReadTypes String[] +} + +model Post { + id Int @id + type String + @@allow('all', auth().roles?[permissions![this.type in canReadTypes]] ) +} +`, + { provider: 'postgresql' }, + ); + + await db.$unuseAll().post.create({ data: { id: 1, type: 'News' } }); + + await expect(db.post.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1 }).post.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, roles: [] }).post.findFirst()).toResolveNull(); + await expect(db.$setAuth({ id: 1, roles: [{ permissions: [] }] }).post.findFirst()).toResolveTruthy(); + await expect( + db.$setAuth({ id: 1, roles: [{ permissions: [{ canReadTypes: [] }] }] }).post.findFirst(), + ).toResolveNull(); + await expect( + db.$setAuth({ id: 1, roles: [{ permissions: [{ canReadTypes: ['News'] }] }] }).post.findFirst(), + ).toResolveTruthy(); + await expect( + db.$setAuth({ roles: [{ permissions: [{ canReadTypes: ['Blog'] }] }] }).post.findFirst(), + ).toResolveNull(); + await expect( + db.$setAuth({ roles: [{ permissions: [{ canReadTypes: ['Blog', 'News'] }] }] }).post.findFirst(), + ).toResolveTruthy(); + await expect( + db + .$setAuth({ roles: [{ permissions: [{ canReadTypes: ['Blog'] }, { canReadTypes: ['News'] }] }] }) + .post.findFirst(), + ).toResolveNull(); + await expect( + db + .$setAuth({ + roles: [ + { permissions: [{ canReadTypes: ['Blog'] }] }, + { permissions: [{ canReadTypes: ['News', 'Story'] }, { canReadTypes: ['Weather'] }] }, + ], + }) + .post.findFirst(), + ).toResolveNull(); + await expect( + db + .$setAuth({ + roles: [{ permissions: [{ canReadTypes: ['Blog', 'News'] }, { canReadTypes: ['News'] }] }], + }) + .post.findFirst(), + ).toResolveTruthy(); + }); + + it('works with regression1', async () => { + const schema = ` +model User { + id Int @id @default(autoincrement()) + permissions Permission[] +} + +model Permission { + id Int @id @default(autoincrement()) + name String + canUpdateChannelById Int[] + user User @relation(fields: [userId], references: [id]) + userId Int +} + +model Channel { + id Int @id @default(autoincrement()) + name String + + @@allow('create,read', true) + @@allow('update', auth().permissions?[this.id in canUpdateChannelById]) +} +`; + + const db = await createPolicyTestClient(schema, { provider: 'postgresql' }); + + await db.channel.create({ data: { id: 1, name: 'general' } }); + + await expect(db.channel.update({ where: { id: 1 }, data: { name: 'general-updated' } })).toBeRejectedNotFound(); + + const userDb1 = db.$setAuth({ + id: 3, + permissions: [ + { + id: 3, + name: 'update-general', + canUpdateChannelById: [2], + }, + ], + }); + await expect( + userDb1.channel.update({ where: { id: 1 }, data: { name: 'general-updated' } }), + ).toBeRejectedNotFound(); + + const userDb2 = db.$setAuth({ + id: 3, + permissions: [ + { + id: 3, + name: 'update-general', + canUpdateChannelById: [1], + }, + ], + }); + await expect( + userDb2.channel.update({ where: { id: 1 }, data: { name: 'general-updated' } }), + ).resolves.toBeTruthy(); + }); +}); diff --git a/tests/e2e/orm/schemas/auth-type/input.ts b/tests/e2e/orm/schemas/auth-type/input.ts new file mode 100644 index 00000000..9564b7f2 --- /dev/null +++ b/tests/e2e/orm/schemas/auth-type/input.ts @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; +import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; +export type FooFindManyArgs = $FindManyArgs<$Schema, "Foo">; +export type FooFindUniqueArgs = $FindUniqueArgs<$Schema, "Foo">; +export type FooFindFirstArgs = $FindFirstArgs<$Schema, "Foo">; +export type FooCreateArgs = $CreateArgs<$Schema, "Foo">; +export type FooCreateManyArgs = $CreateManyArgs<$Schema, "Foo">; +export type FooCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Foo">; +export type FooUpdateArgs = $UpdateArgs<$Schema, "Foo">; +export type FooUpdateManyArgs = $UpdateManyArgs<$Schema, "Foo">; +export type FooUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Foo">; +export type FooUpsertArgs = $UpsertArgs<$Schema, "Foo">; +export type FooDeleteArgs = $DeleteArgs<$Schema, "Foo">; +export type FooDeleteManyArgs = $DeleteManyArgs<$Schema, "Foo">; +export type FooCountArgs = $CountArgs<$Schema, "Foo">; +export type FooAggregateArgs = $AggregateArgs<$Schema, "Foo">; +export type FooGroupByArgs = $GroupByArgs<$Schema, "Foo">; +export type FooWhereInput = $WhereInput<$Schema, "Foo">; +export type FooSelect = $SelectInput<$Schema, "Foo">; +export type FooInclude = $IncludeInput<$Schema, "Foo">; +export type FooOmit = $OmitInput<$Schema, "Foo">; +export type FooGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Foo", Options, Args>; diff --git a/tests/e2e/orm/schemas/auth-type/models.ts b/tests/e2e/orm/schemas/auth-type/models.ts new file mode 100644 index 00000000..75911fc7 --- /dev/null +++ b/tests/e2e/orm/schemas/auth-type/models.ts @@ -0,0 +1,12 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from "@zenstackhq/orm"; +export type Foo = $ModelResult<$Schema, "Foo">; +export type Permission = $TypeDefResult<$Schema, "Permission">; +export type Auth = $TypeDefResult<$Schema, "Auth">; diff --git a/tests/e2e/orm/schemas/auth-type/schema.ts b/tests/e2e/orm/schemas/auth-type/schema.ts new file mode 100644 index 00000000..5904569b --- /dev/null +++ b/tests/e2e/orm/schemas/auth-type/schema.ts @@ -0,0 +1,74 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaDef } from "@zenstackhq/orm/schema"; +const _schema = { + provider: { + type: "sqlite" + }, + models: { + Foo: { + name: "Foo", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }] + } + }, + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + } + }, + typeDefs: { + Permission: { + name: "Permission", + fields: { + actionCode: { + name: "actionCode", + type: "String" + } + } + }, + Auth: { + name: "Auth", + fields: { + id: { + name: "id", + type: "Int", + attributes: [{ name: "@id" }] + }, + name: { + name: "name", + type: "String" + }, + permissions: { + name: "permissions", + type: "Permission", + array: true + }, + role: { + name: "role", + type: "String" + } + }, + attributes: [ + { name: "@@auth" } + ] + } + }, + authType: "Auth", + plugins: {} +} as const satisfies SchemaDef; +type Schema = typeof _schema & { + __brand?: "schema"; +}; +export const schema: Schema = _schema; +export type SchemaType = Schema; diff --git a/tests/e2e/orm/schemas/auth-type/schema.zmodel b/tests/e2e/orm/schemas/auth-type/schema.zmodel new file mode 100644 index 00000000..9ded3aae --- /dev/null +++ b/tests/e2e/orm/schemas/auth-type/schema.zmodel @@ -0,0 +1,21 @@ +datasource db { + provider = "sqlite" + url = "file:./dev.db" +} + +type Permission { + actionCode String +} + +type Auth { + id Int @id + name String + permissions Permission[] + role String + + @@auth +} + +model Foo { + id Int @id +} \ No newline at end of file diff --git a/tests/e2e/orm/schemas/basic/input.ts b/tests/e2e/orm/schemas/basic/input.ts index 70de8c2e..96a679c1 100644 --- a/tests/e2e/orm/schemas/basic/input.ts +++ b/tests/e2e/orm/schemas/basic/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -47,7 +47,7 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; export type CommentFindManyArgs = $FindManyArgs<$Schema, "Comment">; export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, "Comment">; export type CommentFindFirstArgs = $FindFirstArgs<$Schema, "Comment">; @@ -67,7 +67,7 @@ export type CommentWhereInput = $WhereInput<$Schema, "Comment">; export type CommentSelect = $SelectInput<$Schema, "Comment">; export type CommentInclude = $IncludeInput<$Schema, "Comment">; export type CommentOmit = $OmitInput<$Schema, "Comment">; -export type CommentGetPayload> = $SimplifiedModelResult<$Schema, "Comment", Args>; +export type CommentGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Comment", Options, Args>; export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; @@ -87,4 +87,4 @@ export type ProfileWhereInput = $WhereInput<$Schema, "Profile">; export type ProfileSelect = $SelectInput<$Schema, "Profile">; export type ProfileInclude = $IncludeInput<$Schema, "Profile">; export type ProfileOmit = $OmitInput<$Schema, "Profile">; -export type ProfileGetPayload> = $SimplifiedModelResult<$Schema, "Profile", Args>; +export type ProfileGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Profile", Options, Args>; diff --git a/tests/e2e/orm/schemas/basic/schema.zmodel b/tests/e2e/orm/schemas/basic/schema.zmodel index d3ace0a1..e6e2832b 100644 --- a/tests/e2e/orm/schemas/basic/schema.zmodel +++ b/tests/e2e/orm/schemas/basic/schema.zmodel @@ -19,12 +19,13 @@ type CommonFields { } model User with CommonFields { - email String @unique - name String? - role Role @default(USER) - posts Post[] - profile Profile? - meta Json? + email String @unique + name String? + password String @ignore + role Role @default(USER) + posts Post[] + profile Profile? + meta Json? // Access policies @@allow('all', auth().id == id) @@ -46,9 +47,9 @@ model Post with CommonFields { } model Comment with CommonFields { - content String - post Post? @relation(fields: [postId], references: [id], onUpdate: Cascade, onDelete: Cascade) - postId String? + content String + post Post? @relation(fields: [postId], references: [id], onUpdate: Cascade, onDelete: Cascade) + postId String? } model Profile with CommonFields { @@ -57,3 +58,9 @@ model Profile with CommonFields { user User? @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade) userId String? @unique } + +model Foo { + id String @id + @@ignore +} + diff --git a/tests/e2e/orm/schemas/default-auth/input.ts b/tests/e2e/orm/schemas/default-auth/input.ts index 5ebdd080..f7fa5424 100644 --- a/tests/e2e/orm/schemas/default-auth/input.ts +++ b/tests/e2e/orm/schemas/default-auth/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; @@ -47,7 +47,7 @@ export type ProfileWhereInput = $WhereInput<$Schema, "Profile">; export type ProfileSelect = $SelectInput<$Schema, "Profile">; export type ProfileInclude = $IncludeInput<$Schema, "Profile">; export type ProfileOmit = $OmitInput<$Schema, "Profile">; -export type ProfileGetPayload> = $SimplifiedModelResult<$Schema, "Profile", Args>; +export type ProfileGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Profile", Options, Args>; export type AddressFindManyArgs = $FindManyArgs<$Schema, "Address">; export type AddressFindUniqueArgs = $FindUniqueArgs<$Schema, "Address">; export type AddressFindFirstArgs = $FindFirstArgs<$Schema, "Address">; @@ -67,4 +67,4 @@ export type AddressWhereInput = $WhereInput<$Schema, "Address">; export type AddressSelect = $SelectInput<$Schema, "Address">; export type AddressInclude = $IncludeInput<$Schema, "Address">; export type AddressOmit = $OmitInput<$Schema, "Address">; -export type AddressGetPayload> = $SimplifiedModelResult<$Schema, "Address", Args>; +export type AddressGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Address", Options, Args>; diff --git a/tests/e2e/orm/schemas/delegate/input.ts b/tests/e2e/orm/schemas/delegate/input.ts index 1d43c413..f4d2a694 100644 --- a/tests/e2e/orm/schemas/delegate/input.ts +++ b/tests/e2e/orm/schemas/delegate/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type CommentFindManyArgs = $FindManyArgs<$Schema, "Comment">; export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, "Comment">; export type CommentFindFirstArgs = $FindFirstArgs<$Schema, "Comment">; @@ -47,7 +47,7 @@ export type CommentWhereInput = $WhereInput<$Schema, "Comment">; export type CommentSelect = $SelectInput<$Schema, "Comment">; export type CommentInclude = $IncludeInput<$Schema, "Comment">; export type CommentOmit = $OmitInput<$Schema, "Comment">; -export type CommentGetPayload> = $SimplifiedModelResult<$Schema, "Comment", Args>; +export type CommentGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Comment", Options, Args>; export type AssetFindManyArgs = $FindManyArgs<$Schema, "Asset">; export type AssetFindUniqueArgs = $FindUniqueArgs<$Schema, "Asset">; export type AssetFindFirstArgs = $FindFirstArgs<$Schema, "Asset">; @@ -67,7 +67,7 @@ export type AssetWhereInput = $WhereInput<$Schema, "Asset">; export type AssetSelect = $SelectInput<$Schema, "Asset">; export type AssetInclude = $IncludeInput<$Schema, "Asset">; export type AssetOmit = $OmitInput<$Schema, "Asset">; -export type AssetGetPayload> = $SimplifiedModelResult<$Schema, "Asset", Args>; +export type AssetGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Asset", Options, Args>; export type VideoFindManyArgs = $FindManyArgs<$Schema, "Video">; export type VideoFindUniqueArgs = $FindUniqueArgs<$Schema, "Video">; export type VideoFindFirstArgs = $FindFirstArgs<$Schema, "Video">; @@ -87,7 +87,7 @@ export type VideoWhereInput = $WhereInput<$Schema, "Video">; export type VideoSelect = $SelectInput<$Schema, "Video">; export type VideoInclude = $IncludeInput<$Schema, "Video">; export type VideoOmit = $OmitInput<$Schema, "Video">; -export type VideoGetPayload> = $SimplifiedModelResult<$Schema, "Video", Args>; +export type VideoGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Video", Options, Args>; export type RatedVideoFindManyArgs = $FindManyArgs<$Schema, "RatedVideo">; export type RatedVideoFindUniqueArgs = $FindUniqueArgs<$Schema, "RatedVideo">; export type RatedVideoFindFirstArgs = $FindFirstArgs<$Schema, "RatedVideo">; @@ -107,7 +107,7 @@ export type RatedVideoWhereInput = $WhereInput<$Schema, "RatedVideo">; export type RatedVideoSelect = $SelectInput<$Schema, "RatedVideo">; export type RatedVideoInclude = $IncludeInput<$Schema, "RatedVideo">; export type RatedVideoOmit = $OmitInput<$Schema, "RatedVideo">; -export type RatedVideoGetPayload> = $SimplifiedModelResult<$Schema, "RatedVideo", Args>; +export type RatedVideoGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "RatedVideo", Options, Args>; export type ImageFindManyArgs = $FindManyArgs<$Schema, "Image">; export type ImageFindUniqueArgs = $FindUniqueArgs<$Schema, "Image">; export type ImageFindFirstArgs = $FindFirstArgs<$Schema, "Image">; @@ -127,7 +127,7 @@ export type ImageWhereInput = $WhereInput<$Schema, "Image">; export type ImageSelect = $SelectInput<$Schema, "Image">; export type ImageInclude = $IncludeInput<$Schema, "Image">; export type ImageOmit = $OmitInput<$Schema, "Image">; -export type ImageGetPayload> = $SimplifiedModelResult<$Schema, "Image", Args>; +export type ImageGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Image", Options, Args>; export type GalleryFindManyArgs = $FindManyArgs<$Schema, "Gallery">; export type GalleryFindUniqueArgs = $FindUniqueArgs<$Schema, "Gallery">; export type GalleryFindFirstArgs = $FindFirstArgs<$Schema, "Gallery">; @@ -147,4 +147,4 @@ export type GalleryWhereInput = $WhereInput<$Schema, "Gallery">; export type GallerySelect = $SelectInput<$Schema, "Gallery">; export type GalleryInclude = $IncludeInput<$Schema, "Gallery">; export type GalleryOmit = $OmitInput<$Schema, "Gallery">; -export type GalleryGetPayload> = $SimplifiedModelResult<$Schema, "Gallery", Args>; +export type GalleryGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Gallery", Options, Args>; diff --git a/tests/e2e/orm/schemas/name-mapping/input.ts b/tests/e2e/orm/schemas/name-mapping/input.ts index 6c876632..fb776314 100644 --- a/tests/e2e/orm/schemas/name-mapping/input.ts +++ b/tests/e2e/orm/schemas/name-mapping/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -47,4 +47,4 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; diff --git a/tests/e2e/orm/schemas/omit/input.ts b/tests/e2e/orm/schemas/omit/input.ts new file mode 100644 index 00000000..35f840d1 --- /dev/null +++ b/tests/e2e/orm/schemas/omit/input.ts @@ -0,0 +1,90 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; +import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; +export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; +export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; +export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">; +export type UserCreateArgs = $CreateArgs<$Schema, "User">; +export type UserCreateManyArgs = $CreateManyArgs<$Schema, "User">; +export type UserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "User">; +export type UserUpdateArgs = $UpdateArgs<$Schema, "User">; +export type UserUpdateManyArgs = $UpdateManyArgs<$Schema, "User">; +export type UserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "User">; +export type UserUpsertArgs = $UpsertArgs<$Schema, "User">; +export type UserDeleteArgs = $DeleteArgs<$Schema, "User">; +export type UserDeleteManyArgs = $DeleteManyArgs<$Schema, "User">; +export type UserCountArgs = $CountArgs<$Schema, "User">; +export type UserAggregateArgs = $AggregateArgs<$Schema, "User">; +export type UserGroupByArgs = $GroupByArgs<$Schema, "User">; +export type UserWhereInput = $WhereInput<$Schema, "User">; +export type UserSelect = $SelectInput<$Schema, "User">; +export type UserInclude = $IncludeInput<$Schema, "User">; +export type UserOmit = $OmitInput<$Schema, "User">; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; +export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; +export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; +export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; +export type PostCreateArgs = $CreateArgs<$Schema, "Post">; +export type PostCreateManyArgs = $CreateManyArgs<$Schema, "Post">; +export type PostCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Post">; +export type PostUpdateArgs = $UpdateArgs<$Schema, "Post">; +export type PostUpdateManyArgs = $UpdateManyArgs<$Schema, "Post">; +export type PostUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Post">; +export type PostUpsertArgs = $UpsertArgs<$Schema, "Post">; +export type PostDeleteArgs = $DeleteArgs<$Schema, "Post">; +export type PostDeleteManyArgs = $DeleteManyArgs<$Schema, "Post">; +export type PostCountArgs = $CountArgs<$Schema, "Post">; +export type PostAggregateArgs = $AggregateArgs<$Schema, "Post">; +export type PostGroupByArgs = $GroupByArgs<$Schema, "Post">; +export type PostWhereInput = $WhereInput<$Schema, "Post">; +export type PostSelect = $SelectInput<$Schema, "Post">; +export type PostInclude = $IncludeInput<$Schema, "Post">; +export type PostOmit = $OmitInput<$Schema, "Post">; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; +export type BaseFindManyArgs = $FindManyArgs<$Schema, "Base">; +export type BaseFindUniqueArgs = $FindUniqueArgs<$Schema, "Base">; +export type BaseFindFirstArgs = $FindFirstArgs<$Schema, "Base">; +export type BaseCreateArgs = $CreateArgs<$Schema, "Base">; +export type BaseCreateManyArgs = $CreateManyArgs<$Schema, "Base">; +export type BaseCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Base">; +export type BaseUpdateArgs = $UpdateArgs<$Schema, "Base">; +export type BaseUpdateManyArgs = $UpdateManyArgs<$Schema, "Base">; +export type BaseUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Base">; +export type BaseUpsertArgs = $UpsertArgs<$Schema, "Base">; +export type BaseDeleteArgs = $DeleteArgs<$Schema, "Base">; +export type BaseDeleteManyArgs = $DeleteManyArgs<$Schema, "Base">; +export type BaseCountArgs = $CountArgs<$Schema, "Base">; +export type BaseAggregateArgs = $AggregateArgs<$Schema, "Base">; +export type BaseGroupByArgs = $GroupByArgs<$Schema, "Base">; +export type BaseWhereInput = $WhereInput<$Schema, "Base">; +export type BaseSelect = $SelectInput<$Schema, "Base">; +export type BaseInclude = $IncludeInput<$Schema, "Base">; +export type BaseOmit = $OmitInput<$Schema, "Base">; +export type BaseGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Base", Options, Args>; +export type SubFindManyArgs = $FindManyArgs<$Schema, "Sub">; +export type SubFindUniqueArgs = $FindUniqueArgs<$Schema, "Sub">; +export type SubFindFirstArgs = $FindFirstArgs<$Schema, "Sub">; +export type SubCreateArgs = $CreateArgs<$Schema, "Sub">; +export type SubCreateManyArgs = $CreateManyArgs<$Schema, "Sub">; +export type SubCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Sub">; +export type SubUpdateArgs = $UpdateArgs<$Schema, "Sub">; +export type SubUpdateManyArgs = $UpdateManyArgs<$Schema, "Sub">; +export type SubUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Sub">; +export type SubUpsertArgs = $UpsertArgs<$Schema, "Sub">; +export type SubDeleteArgs = $DeleteArgs<$Schema, "Sub">; +export type SubDeleteManyArgs = $DeleteManyArgs<$Schema, "Sub">; +export type SubCountArgs = $CountArgs<$Schema, "Sub">; +export type SubAggregateArgs = $AggregateArgs<$Schema, "Sub">; +export type SubGroupByArgs = $GroupByArgs<$Schema, "Sub">; +export type SubWhereInput = $WhereInput<$Schema, "Sub">; +export type SubSelect = $SelectInput<$Schema, "Sub">; +export type SubInclude = $IncludeInput<$Schema, "Sub">; +export type SubOmit = $OmitInput<$Schema, "Sub">; +export type SubGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Sub", Options, Args>; diff --git a/tests/e2e/orm/schemas/omit/models.ts b/tests/e2e/orm/schemas/omit/models.ts new file mode 100644 index 00000000..6636b4d5 --- /dev/null +++ b/tests/e2e/orm/schemas/omit/models.ts @@ -0,0 +1,13 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Post = $ModelResult<$Schema, "Post">; +export type Base = $ModelResult<$Schema, "Base">; +export type Sub = $ModelResult<$Schema, "Sub">; diff --git a/tests/e2e/orm/schemas/omit/schema.ts b/tests/e2e/orm/schemas/omit/schema.ts new file mode 100644 index 00000000..4543ccb7 --- /dev/null +++ b/tests/e2e/orm/schemas/omit/schema.ts @@ -0,0 +1,142 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; +const _schema = { + provider: { + type: "sqlite" + }, + models: { + User: { + name: "User", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }] + }, + name: { + name: "name", + type: "String" + }, + password: { + name: "password", + type: "String", + omit: true, + attributes: [{ name: "@omit" }] + }, + posts: { + name: "posts", + type: "Post", + array: true, + relation: { opposite: "author" } + } + }, + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + }, + Post: { + name: "Post", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }] + }, + title: { + name: "title", + type: "String" + }, + author: { + name: "author", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onDelete: "Cascade" } + }, + authorId: { + name: "authorId", + type: "Int", + foreignKeyFor: [ + "author" + ] + } + }, + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + }, + Base: { + name: "Base", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }] + }, + type: { + name: "type", + type: "String", + isDiscriminator: true + } + }, + attributes: [ + { name: "@@delegate", args: [{ name: "discriminator", value: ExpressionUtils.field("type") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + }, + isDelegate: true, + subModels: ["Sub"] + }, + Sub: { + name: "Sub", + baseModel: "Base", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }] + }, + type: { + name: "type", + type: "String", + originModel: "Base", + isDiscriminator: true + }, + title: { + name: "title", + type: "String" + }, + content: { + name: "content", + type: "String", + omit: true, + attributes: [{ name: "@omit" }] + } + }, + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + } + }, + authType: "User", + plugins: {} +} as const satisfies SchemaDef; +type Schema = typeof _schema & { + __brand?: "schema"; +}; +export const schema: Schema = _schema; +export type SchemaType = Schema; diff --git a/tests/e2e/orm/schemas/omit/schema.zmodel b/tests/e2e/orm/schemas/omit/schema.zmodel new file mode 100644 index 00000000..0fdba033 --- /dev/null +++ b/tests/e2e/orm/schemas/omit/schema.zmodel @@ -0,0 +1,29 @@ +datasource db { + provider = "sqlite" + url = "file:./dev.db" +} + +model User { + id Int @id + name String + password String @omit + posts Post[] +} + +model Post { + id Int @id + title String + author User @relation(fields: [authorId], references: [id], onDelete: Cascade) + authorId Int +} + +model Base { + id Int @id + type String + @@delegate(type) +} + +model Sub extends Base { + title String + content String @omit +} diff --git a/tests/e2e/orm/schemas/petstore/input.ts b/tests/e2e/orm/schemas/petstore/input.ts index 690d1d90..5ea5d622 100644 --- a/tests/e2e/orm/schemas/petstore/input.ts +++ b/tests/e2e/orm/schemas/petstore/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PetFindManyArgs = $FindManyArgs<$Schema, "Pet">; export type PetFindUniqueArgs = $FindUniqueArgs<$Schema, "Pet">; export type PetFindFirstArgs = $FindFirstArgs<$Schema, "Pet">; @@ -47,7 +47,7 @@ export type PetWhereInput = $WhereInput<$Schema, "Pet">; export type PetSelect = $SelectInput<$Schema, "Pet">; export type PetInclude = $IncludeInput<$Schema, "Pet">; export type PetOmit = $OmitInput<$Schema, "Pet">; -export type PetGetPayload> = $SimplifiedModelResult<$Schema, "Pet", Args>; +export type PetGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Pet", Options, Args>; export type OrderFindManyArgs = $FindManyArgs<$Schema, "Order">; export type OrderFindUniqueArgs = $FindUniqueArgs<$Schema, "Order">; export type OrderFindFirstArgs = $FindFirstArgs<$Schema, "Order">; @@ -67,4 +67,4 @@ export type OrderWhereInput = $WhereInput<$Schema, "Order">; export type OrderSelect = $SelectInput<$Schema, "Order">; export type OrderInclude = $IncludeInput<$Schema, "Order">; export type OrderOmit = $OmitInput<$Schema, "Order">; -export type OrderGetPayload> = $SimplifiedModelResult<$Schema, "Order", Args>; +export type OrderGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Order", Options, Args>; diff --git a/tests/e2e/orm/schemas/todo/input.ts b/tests/e2e/orm/schemas/todo/input.ts index 22fd5a19..c198bf58 100644 --- a/tests/e2e/orm/schemas/todo/input.ts +++ b/tests/e2e/orm/schemas/todo/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type SpaceFindManyArgs = $FindManyArgs<$Schema, "Space">; export type SpaceFindUniqueArgs = $FindUniqueArgs<$Schema, "Space">; @@ -27,7 +27,7 @@ export type SpaceWhereInput = $WhereInput<$Schema, "Space">; export type SpaceSelect = $SelectInput<$Schema, "Space">; export type SpaceInclude = $IncludeInput<$Schema, "Space">; export type SpaceOmit = $OmitInput<$Schema, "Space">; -export type SpaceGetPayload> = $SimplifiedModelResult<$Schema, "Space", Args>; +export type SpaceGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Space", Options, Args>; export type SpaceUserFindManyArgs = $FindManyArgs<$Schema, "SpaceUser">; export type SpaceUserFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceUser">; export type SpaceUserFindFirstArgs = $FindFirstArgs<$Schema, "SpaceUser">; @@ -47,7 +47,7 @@ export type SpaceUserWhereInput = $WhereInput<$Schema, "SpaceUser">; export type SpaceUserSelect = $SelectInput<$Schema, "SpaceUser">; export type SpaceUserInclude = $IncludeInput<$Schema, "SpaceUser">; export type SpaceUserOmit = $OmitInput<$Schema, "SpaceUser">; -export type SpaceUserGetPayload> = $SimplifiedModelResult<$Schema, "SpaceUser", Args>; +export type SpaceUserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "SpaceUser", Options, Args>; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">; @@ -67,7 +67,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type ListFindManyArgs = $FindManyArgs<$Schema, "List">; export type ListFindUniqueArgs = $FindUniqueArgs<$Schema, "List">; export type ListFindFirstArgs = $FindFirstArgs<$Schema, "List">; @@ -87,7 +87,7 @@ export type ListWhereInput = $WhereInput<$Schema, "List">; export type ListSelect = $SelectInput<$Schema, "List">; export type ListInclude = $IncludeInput<$Schema, "List">; export type ListOmit = $OmitInput<$Schema, "List">; -export type ListGetPayload> = $SimplifiedModelResult<$Schema, "List", Args>; +export type ListGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "List", Options, Args>; export type TodoFindManyArgs = $FindManyArgs<$Schema, "Todo">; export type TodoFindUniqueArgs = $FindUniqueArgs<$Schema, "Todo">; export type TodoFindFirstArgs = $FindFirstArgs<$Schema, "Todo">; @@ -107,4 +107,4 @@ export type TodoWhereInput = $WhereInput<$Schema, "Todo">; export type TodoSelect = $SelectInput<$Schema, "Todo">; export type TodoInclude = $IncludeInput<$Schema, "Todo">; export type TodoOmit = $OmitInput<$Schema, "Todo">; -export type TodoGetPayload> = $SimplifiedModelResult<$Schema, "Todo", Args>; +export type TodoGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Todo", Options, Args>; diff --git a/tests/e2e/orm/schemas/typing/input.ts b/tests/e2e/orm/schemas/typing/input.ts index 13d7d458..58e1ad6d 100644 --- a/tests/e2e/orm/schemas/typing/input.ts +++ b/tests/e2e/orm/schemas/typing/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; @@ -27,7 +27,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; @@ -47,7 +47,7 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">; export type PostSelect = $SelectInput<$Schema, "Post">; export type PostInclude = $IncludeInput<$Schema, "Post">; export type PostOmit = $OmitInput<$Schema, "Post">; -export type PostGetPayload> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; @@ -67,7 +67,7 @@ export type ProfileWhereInput = $WhereInput<$Schema, "Profile">; export type ProfileSelect = $SelectInput<$Schema, "Profile">; export type ProfileInclude = $IncludeInput<$Schema, "Profile">; export type ProfileOmit = $OmitInput<$Schema, "Profile">; -export type ProfileGetPayload> = $SimplifiedModelResult<$Schema, "Profile", Args>; +export type ProfileGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Profile", Options, Args>; export type TagFindManyArgs = $FindManyArgs<$Schema, "Tag">; export type TagFindUniqueArgs = $FindUniqueArgs<$Schema, "Tag">; export type TagFindFirstArgs = $FindFirstArgs<$Schema, "Tag">; @@ -87,7 +87,7 @@ export type TagWhereInput = $WhereInput<$Schema, "Tag">; export type TagSelect = $SelectInput<$Schema, "Tag">; export type TagInclude = $IncludeInput<$Schema, "Tag">; export type TagOmit = $OmitInput<$Schema, "Tag">; -export type TagGetPayload> = $SimplifiedModelResult<$Schema, "Tag", Args>; +export type TagGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Tag", Options, Args>; export type RegionFindManyArgs = $FindManyArgs<$Schema, "Region">; export type RegionFindUniqueArgs = $FindUniqueArgs<$Schema, "Region">; export type RegionFindFirstArgs = $FindFirstArgs<$Schema, "Region">; @@ -107,7 +107,7 @@ export type RegionWhereInput = $WhereInput<$Schema, "Region">; export type RegionSelect = $SelectInput<$Schema, "Region">; export type RegionInclude = $IncludeInput<$Schema, "Region">; export type RegionOmit = $OmitInput<$Schema, "Region">; -export type RegionGetPayload> = $SimplifiedModelResult<$Schema, "Region", Args>; +export type RegionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Region", Options, Args>; export type MetaFindManyArgs = $FindManyArgs<$Schema, "Meta">; export type MetaFindUniqueArgs = $FindUniqueArgs<$Schema, "Meta">; export type MetaFindFirstArgs = $FindFirstArgs<$Schema, "Meta">; @@ -127,4 +127,4 @@ export type MetaWhereInput = $WhereInput<$Schema, "Meta">; export type MetaSelect = $SelectInput<$Schema, "Meta">; export type MetaInclude = $IncludeInput<$Schema, "Meta">; export type MetaOmit = $OmitInput<$Schema, "Meta">; -export type MetaGetPayload> = $SimplifiedModelResult<$Schema, "Meta", Args>; +export type MetaGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Meta", Options, Args>; diff --git a/tests/e2e/orm/validation/custom-validation.test.ts b/tests/e2e/orm/validation/custom-validation.test.ts index 955121b0..56558108 100644 --- a/tests/e2e/orm/validation/custom-validation.test.ts +++ b/tests/e2e/orm/validation/custom-validation.test.ts @@ -143,8 +143,10 @@ describe('Custom validation tests', () => { }), ).toBeRejectedByValidation(); + const dbNoValidation = db.$setOptions({ ...db.$options, validateInput: false }); + await expect( - db.$setInputValidation(false).user.create({ + dbNoValidation.user.create({ data: { id: 1, email: 'xyz', @@ -153,7 +155,7 @@ describe('Custom validation tests', () => { ).toResolveTruthy(); await expect( - db.$setInputValidation(false).user.update({ + dbNoValidation.user.update({ where: { id: 1 }, data: { email: 'a@b.com', diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 5e864720..f023e507 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -1,6 +1,6 @@ { "name": "e2e", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "private": true, "type": "module", "scripts": { diff --git a/tests/regression/package.json b/tests/regression/package.json index fd80a796..af00968a 100644 --- a/tests/regression/package.json +++ b/tests/regression/package.json @@ -1,6 +1,6 @@ { "name": "regression", - "version": "3.0.0-beta.25", + "version": "3.0.0-beta.26", "private": true, "type": "module", "scripts": {