diff --git a/BREAKINGCHANGES.md b/BREAKINGCHANGES.md index 0b84de03..f71db4ce 100644 --- a/BREAKINGCHANGES.md +++ b/BREAKINGCHANGES.md @@ -2,3 +2,4 @@ 1. `check()` ORM api has been removed 1. non-optional to-one relation doesn't automatically filter parent read when evaluating access policies 1. `@omit` and `@password` attributes have been removed +1. SWR plugin is removed diff --git a/package.json b/package.json index de6a7008..4867a361 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "zenstack-v3", "version": "3.0.0-beta.14", "description": "ZenStack", - "packageManager": "pnpm@10.12.1", + "packageManager": "pnpm@10.20.0", "scripts": { "build": "turbo run build", "watch": "turbo run watch build", diff --git a/packages/orm/package.json b/packages/orm/package.json index 75857d5c..2fb72d7c 100644 --- a/packages/orm/package.json +++ b/packages/orm/package.json @@ -97,6 +97,6 @@ "@zenstackhq/typescript-config": "workspace:*", "@zenstackhq/vitest-config": "workspace:*", "tsx": "^4.19.2", - "zod": "~3.25.0" + "zod": "^4.1.0" } } diff --git a/packages/orm/src/client/crud/validator/index.ts b/packages/orm/src/client/crud/validator/index.ts index f76a8a4e..b4c012ed 100644 --- a/packages/orm/src/client/crud/validator/index.ts +++ b/packages/orm/src/client/crud/validator/index.ts @@ -2,7 +2,7 @@ import { enumerate, invariant } from '@zenstackhq/common-helpers'; import Decimal from 'decimal.js'; import stableStringify from 'json-stable-stringify'; import { match, P } from 'ts-pattern'; -import { z, ZodSchema, ZodType } from 'zod'; +import { z, ZodType } from 'zod'; import { type AttributeApplication, type BuiltinType, @@ -830,7 +830,7 @@ export class InputValidator { private makeCreateSchema(model: string) { const dataSchema = this.makeCreateDataSchema(model, false); - let schema: ZodSchema = z.strictObject({ + let schema: ZodType = z.strictObject({ data: dataSchema, select: this.makeSelectSchema(model).optional(), include: this.makeIncludeSchema(model).optional(), @@ -1107,7 +1107,7 @@ export class InputValidator { // #region Update private makeUpdateSchema(model: string) { - let schema: ZodSchema = z.strictObject({ + let schema: ZodType = z.strictObject({ where: this.makeWhereSchema(model, true), data: this.makeUpdateDataSchema(model), select: this.makeSelectSchema(model).optional(), @@ -1129,7 +1129,7 @@ export class InputValidator { private makeUpdateManyAndReturnSchema(model: string) { const base = this.makeUpdateManySchema(model); - let schema: ZodSchema = base.extend({ + let schema: ZodType = base.extend({ select: this.makeSelectSchema(model).optional(), omit: this.makeOmitSchema(model).optional(), }); @@ -1138,7 +1138,7 @@ export class InputValidator { } private makeUpsertSchema(model: string) { - let schema: ZodSchema = z.strictObject({ + let schema: ZodType = z.strictObject({ where: this.makeWhereSchema(model, true), create: this.makeCreateDataSchema(model, false), update: this.makeUpdateDataSchema(model), @@ -1257,7 +1257,7 @@ export class InputValidator { // #region Delete private makeDeleteSchema(model: GetModels) { - let schema: ZodSchema = z.strictObject({ + let schema: ZodType = z.strictObject({ where: this.makeWhereSchema(model, true), select: this.makeSelectSchema(model).optional(), include: this.makeIncludeSchema(model).optional(), @@ -1387,7 +1387,7 @@ export class InputValidator { }); // fields used in `having` must be either in the `by` list, or aggregations - schema = schema.refine((value) => { + schema = schema.refine((value: any) => { const bys = typeof value.by === 'string' ? [value.by] : value.by; if (value.having && typeof value.having === 'object') { for (const [key, val] of Object.entries(value.having)) { @@ -1414,7 +1414,7 @@ export class InputValidator { }, 'fields in "having" must be in "by"'); // fields used in `orderBy` must be either in the `by` list, or aggregations - schema = schema.refine((value) => { + schema = schema.refine((value: any) => { const bys = typeof value.by === 'string' ? [value.by] : value.by; if ( value.orderBy && diff --git a/packages/orm/src/client/crud/validator/utils.ts b/packages/orm/src/client/crud/validator/utils.ts index 980fff50..6fd95a20 100644 --- a/packages/orm/src/client/crud/validator/utils.ts +++ b/packages/orm/src/client/crud/validator/utils.ts @@ -11,6 +11,7 @@ import type { import Decimal from 'decimal.js'; import { match, P } from 'ts-pattern'; import { z } from 'zod'; +import { ZodIssueCode } from 'zod/v3'; import { ExpressionUtils } from '../../../schema'; import { QueryError } from '../../errors'; @@ -171,8 +172,26 @@ export function addDecimalValidation( return schema.superRefine((v, ctx) => { const base = z.number(); const { error } = base[op](value).safeParse((v as Decimal).toNumber()); - error?.errors.forEach((e) => { - ctx.addIssue(e); + error?.issues.forEach((issue) => { + if (op === 'gt' || op === 'gte') { + ctx.addIssue({ + code: ZodIssueCode.too_small, + origin: 'number', + minimum: value, + type: 'decimal', + inclusive: op === 'gte', + message: issue.message, + }); + } else { + ctx.addIssue({ + code: ZodIssueCode.too_big, + origin: 'number', + maximum: value, + type: 'decimal', + inclusive: op === 'lte', + message: issue.message, + }); + } }); }); } @@ -258,9 +277,9 @@ function applyValidation( message: string | undefined, path: string[] | undefined, ) { - const options: z.CustomErrorParams = {}; + const options: Parameters[1] = {}; if (message) { - options.message = message; + options.error = message; } if (path) { options.path = path; diff --git a/packages/orm/src/utils/zod-utils.ts b/packages/orm/src/utils/zod-utils.ts index 2ca23ca8..6339dfa4 100644 --- a/packages/orm/src/utils/zod-utils.ts +++ b/packages/orm/src/utils/zod-utils.ts @@ -1,14 +1,9 @@ import { ZodError } from 'zod'; -import { fromError as fromError3 } from 'zod-validation-error/v3'; -import { fromError as fromError4 } from 'zod-validation-error/v4'; +import { fromError } from 'zod-validation-error/v4'; /** * Format ZodError into a readable string */ export function formatError(error: ZodError): string { - if ('_zod' in error) { - return fromError4(error).toString(); - } else { - return fromError3(error).toString(); - } + return fromError(error).toString(); } diff --git a/packages/server/package.json b/packages/server/package.json index 96a11f36..ad7697bc 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -149,7 +149,7 @@ "next": "^15.0.0", "nuxt": "^4.2.0", "supertest": "^7.1.4", - "zod": "~3.25.0" + "zod": "^4.1.0" }, "peerDependencies": { "@sveltejs/kit": "^2.0.0", diff --git a/packages/testtools/src/vitest-ext.ts b/packages/testtools/src/vitest-ext.ts index 6eef39b5..ab01d47c 100644 --- a/packages/testtools/src/vitest-ext.ts +++ b/packages/testtools/src/vitest-ext.ts @@ -21,7 +21,7 @@ function expectError(err: any, errorType: any) { function expectErrorMessages(expectedMessages: string[], message: string) { for (const m of expectedMessages) { - if (!message.includes(m)) { + if (!message.toLowerCase().includes(m.toLowerCase())) { return { message: () => `expected message not found in error: ${m}, got message: ${message}`, pass: false, diff --git a/packages/zod/package.json b/packages/zod/package.json index 707caa3e..27ff8d8f 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -31,7 +31,7 @@ "devDependencies": { "@zenstackhq/eslint-config": "workspace:*", "@zenstackhq/typescript-config": "workspace:*", - "zod": "~3.25.0" + "zod": "^4.1.0" }, "peerDependencies": { "zod": "catalog:" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e52d475..39dda3fe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -317,7 +317,7 @@ importers: version: 11.0.5 zod-validation-error: specifier: 'catalog:' - version: 4.0.1(zod@3.25.76) + version: 4.0.1(zod@4.1.12) devDependencies: '@types/better-sqlite3': specifier: ^7.6.13 @@ -347,8 +347,8 @@ importers: specifier: ^4.19.2 version: 4.20.3 zod: - specifier: ~3.25.0 - version: 3.25.76 + specifier: ^4.1.0 + version: 4.1.12 packages/plugins/policy: dependencies: @@ -437,7 +437,7 @@ importers: version: 1.0.3 zod-validation-error: specifier: 'catalog:' - version: 4.0.1(zod@3.25.76) + version: 4.0.1(zod@4.1.12) devDependencies: '@sveltejs/kit': specifier: ^2.48.3 @@ -494,8 +494,8 @@ importers: specifier: ^7.1.4 version: 7.1.4 zod: - specifier: ~3.25.0 - version: 3.25.76 + specifier: ^4.1.0 + version: 4.1.12 packages/tanstack-query: dependencies: @@ -590,8 +590,8 @@ importers: specifier: workspace:* version: link:../config/typescript-config zod: - specifier: ~3.25.0 - version: 3.25.76 + specifier: ^4.1.0 + version: 4.1.12 samples/blog: dependencies: @@ -6250,8 +6250,8 @@ packages: peerDependencies: zod: ^3.25.0 || ^4.0.0 - zod@3.25.76: - resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + zod@4.1.12: + resolution: {integrity: sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==} snapshots: @@ -12153,8 +12153,8 @@ snapshots: compress-commons: 6.0.2 readable-stream: 4.7.0 - zod-validation-error@4.0.1(zod@3.25.76): + zod-validation-error@4.0.1(zod@4.1.12): dependencies: - zod: 3.25.76 + zod: 4.1.12 - zod@3.25.76: {} + zod@4.1.12: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 4eb5466d..a702ade3 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,7 +4,7 @@ packages: - tests/** catalog: kysely: ^0.27.6 - zod: ^3.25.0 || ^4.0.0 + zod: ^4.0.0 prisma: ^6.10.0 langium: 3.5.0 langium-cli: 3.5.0 diff --git a/tests/e2e/orm/schemas/basic/input.ts b/tests/e2e/orm/schemas/basic/input.ts index b36565a2..70de8c2e 100644 --- a/tests/e2e/orm/schemas/basic/input.ts +++ b/tests/e2e/orm/schemas/basic/input.ts @@ -5,125 +5,86 @@ /* 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 { - 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> = $SimplifiedModelResult< - $Schema, - 'User', - 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> = $SimplifiedModelResult< - $Schema, - 'Post', - Args ->; -export type CommentFindManyArgs = $FindManyArgs<$Schema, 'Comment'>; -export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, 'Comment'>; -export type CommentFindFirstArgs = $FindFirstArgs<$Schema, 'Comment'>; -export type CommentCreateArgs = $CreateArgs<$Schema, 'Comment'>; -export type CommentCreateManyArgs = $CreateManyArgs<$Schema, 'Comment'>; -export type CommentCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Comment'>; -export type CommentUpdateArgs = $UpdateArgs<$Schema, 'Comment'>; -export type CommentUpdateManyArgs = $UpdateManyArgs<$Schema, 'Comment'>; -export type CommentUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Comment'>; -export type CommentUpsertArgs = $UpsertArgs<$Schema, 'Comment'>; -export type CommentDeleteArgs = $DeleteArgs<$Schema, 'Comment'>; -export type CommentDeleteManyArgs = $DeleteManyArgs<$Schema, 'Comment'>; -export type CommentCountArgs = $CountArgs<$Schema, 'Comment'>; -export type CommentAggregateArgs = $AggregateArgs<$Schema, 'Comment'>; -export type CommentGroupByArgs = $GroupByArgs<$Schema, 'Comment'>; -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 ProfileFindManyArgs = $FindManyArgs<$Schema, 'Profile'>; -export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, 'Profile'>; -export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, 'Profile'>; -export type ProfileCreateArgs = $CreateArgs<$Schema, 'Profile'>; -export type ProfileCreateManyArgs = $CreateManyArgs<$Schema, 'Profile'>; -export type ProfileCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Profile'>; -export type ProfileUpdateArgs = $UpdateArgs<$Schema, 'Profile'>; -export type ProfileUpdateManyArgs = $UpdateManyArgs<$Schema, 'Profile'>; -export type ProfileUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Profile'>; -export type ProfileUpsertArgs = $UpsertArgs<$Schema, 'Profile'>; -export type ProfileDeleteArgs = $DeleteArgs<$Schema, 'Profile'>; -export type ProfileDeleteManyArgs = $DeleteManyArgs<$Schema, 'Profile'>; -export type ProfileCountArgs = $CountArgs<$Schema, 'Profile'>; -export type ProfileAggregateArgs = $AggregateArgs<$Schema, 'Profile'>; -export type ProfileGroupByArgs = $GroupByArgs<$Schema, 'Profile'>; -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 ->; +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 { 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> = $SimplifiedModelResult<$Schema, "User", 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> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type CommentFindManyArgs = $FindManyArgs<$Schema, "Comment">; +export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, "Comment">; +export type CommentFindFirstArgs = $FindFirstArgs<$Schema, "Comment">; +export type CommentCreateArgs = $CreateArgs<$Schema, "Comment">; +export type CommentCreateManyArgs = $CreateManyArgs<$Schema, "Comment">; +export type CommentCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Comment">; +export type CommentUpdateArgs = $UpdateArgs<$Schema, "Comment">; +export type CommentUpdateManyArgs = $UpdateManyArgs<$Schema, "Comment">; +export type CommentUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Comment">; +export type CommentUpsertArgs = $UpsertArgs<$Schema, "Comment">; +export type CommentDeleteArgs = $DeleteArgs<$Schema, "Comment">; +export type CommentDeleteManyArgs = $DeleteManyArgs<$Schema, "Comment">; +export type CommentCountArgs = $CountArgs<$Schema, "Comment">; +export type CommentAggregateArgs = $AggregateArgs<$Schema, "Comment">; +export type CommentGroupByArgs = $GroupByArgs<$Schema, "Comment">; +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 ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; +export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; +export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; +export type ProfileCreateArgs = $CreateArgs<$Schema, "Profile">; +export type ProfileCreateManyArgs = $CreateManyArgs<$Schema, "Profile">; +export type ProfileCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Profile">; +export type ProfileUpdateArgs = $UpdateArgs<$Schema, "Profile">; +export type ProfileUpdateManyArgs = $UpdateManyArgs<$Schema, "Profile">; +export type ProfileUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Profile">; +export type ProfileUpsertArgs = $UpsertArgs<$Schema, "Profile">; +export type ProfileDeleteArgs = $DeleteArgs<$Schema, "Profile">; +export type ProfileDeleteManyArgs = $DeleteManyArgs<$Schema, "Profile">; +export type ProfileCountArgs = $CountArgs<$Schema, "Profile">; +export type ProfileAggregateArgs = $AggregateArgs<$Schema, "Profile">; +export type ProfileGroupByArgs = $GroupByArgs<$Schema, "Profile">; +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>; diff --git a/tests/e2e/orm/schemas/basic/models.ts b/tests/e2e/orm/schemas/basic/models.ts index 64d667b7..d532d7d4 100644 --- a/tests/e2e/orm/schemas/basic/models.ts +++ b/tests/e2e/orm/schemas/basic/models.ts @@ -5,12 +5,12 @@ /* eslint-disable */ -import { schema as $schema, type SchemaType as $Schema } from './schema'; -import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from '@zenstackhq/orm'; -export type User = $ModelResult<$Schema, 'User'>; -export type Post = $ModelResult<$Schema, 'Post'>; -export type Comment = $ModelResult<$Schema, 'Comment'>; -export type Profile = $ModelResult<$Schema, 'Profile'>; -export type CommonFields = $TypeDefResult<$Schema, 'CommonFields'>; +import { schema as $schema, type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Post = $ModelResult<$Schema, "Post">; +export type Comment = $ModelResult<$Schema, "Comment">; +export type Profile = $ModelResult<$Schema, "Profile">; +export type CommonFields = $TypeDefResult<$Schema, "CommonFields">; export const Role = $schema.enums.Role; export type Role = (typeof Role)[keyof typeof Role]; diff --git a/tests/e2e/orm/schemas/basic/schema.ts b/tests/e2e/orm/schemas/basic/schema.ts index 1816323a..14e627b9 100644 --- a/tests/e2e/orm/schemas/basic/schema.ts +++ b/tests/e2e/orm/schemas/basic/schema.ts @@ -5,392 +5,281 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'sqlite', + type: "sqlite" }, models: { User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, - attributes: [{ name: '@unique' }], + attributes: [{ name: "@unique" }] }, name: { - name: 'name', - type: 'String', - optional: true, + name: "name", + type: "String", + optional: true }, role: { - name: 'role', - type: 'Role', - attributes: [ - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal('USER') }] }, - ], - default: 'USER', + name: "role", + type: "Role", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }], + default: "USER" }, posts: { - name: 'posts', - type: 'Post', + name: "posts", + type: "Post", array: true, - relation: { opposite: 'author' }, + relation: { opposite: "author" } }, profile: { - name: 'profile', - type: 'Profile', + name: "profile", + type: "Profile", optional: true, - relation: { opposite: 'user' }, + relation: { opposite: "user" } }, meta: { - name: 'meta', - type: 'Json', - optional: true, - }, + name: "meta", + type: "Json", + optional: true + } }, attributes: [ - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - '==', - ExpressionUtils.field('id'), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '!=', ExpressionUtils._null()), - }, - ], - }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]), "==", ExpressionUtils.field("id")) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "!=", ExpressionUtils._null()) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - email: { type: 'String' }, - }, + id: { type: "String" }, + email: { type: "String" } + } }, Post: { - name: 'Post', + name: "Post", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, title: { - name: 'title', - type: 'String', + name: "title", + type: "String" }, content: { - name: 'content', - type: 'String', - optional: true, + name: "content", + type: "String", + optional: true }, published: { - name: 'published', - type: 'Boolean', - attributes: [ - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(false) }] }, - ], - default: false, + name: "published", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false }, 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: 'onUpdate', value: ExpressionUtils.literal('Cascade') }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { - opposite: 'posts', - fields: ['authorId'], - references: ['id'], - onUpdate: 'Cascade', - onDelete: 'Cascade', - }, + 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: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, authorId: { - name: 'authorId', - type: 'String', - foreignKeyFor: ['author'], + name: "authorId", + type: "String", + foreignKeyFor: [ + "author" + ] }, comments: { - name: 'comments', - type: 'Comment', + name: "comments", + type: "Comment", array: true, - relation: { opposite: 'post' }, - }, + relation: { opposite: "post" } + } }, attributes: [ - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '==', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - '==', - ExpressionUtils.field('authorId'), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { name: 'condition', value: ExpressionUtils.field('published') }, - ], - }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]), "==", ExpressionUtils.field("authorId")) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.field("published") }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, + id: { type: "String" } + } }, Comment: { - name: 'Comment', + name: "Comment", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, content: { - name: 'content', - type: 'String', + name: "content", + type: "String" }, post: { - name: 'post', - type: 'Post', + name: "post", + type: "Post", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('postId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onUpdate', value: ExpressionUtils.literal('Cascade') }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { - opposite: 'comments', - fields: ['postId'], - references: ['id'], - onUpdate: 'Cascade', - onDelete: 'Cascade', - }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("postId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "comments", fields: ["postId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, postId: { - name: 'postId', - type: 'String', + name: "postId", + type: "String", optional: true, - foreignKeyFor: ['post'], - }, + foreignKeyFor: [ + "post" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, + id: { type: "String" } + } }, Profile: { - name: 'Profile', + name: "Profile", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, bio: { - name: 'bio', - type: 'String', + name: "bio", + type: "String" }, age: { - name: 'age', - type: 'Int', - optional: true, + name: "age", + type: "Int", + optional: true }, user: { - name: 'user', - type: 'User', + name: "user", + type: "User", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('userId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onUpdate', value: ExpressionUtils.literal('Cascade') }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { - opposite: 'profile', - fields: ['userId'], - references: ['id'], - onUpdate: 'Cascade', - onDelete: 'Cascade', - }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "profile", fields: ["userId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, userId: { - name: 'userId', - type: 'String', + name: "userId", + type: "String", unique: true, optional: true, - attributes: [{ name: '@unique' }], - foreignKeyFor: ['user'], - }, + attributes: [{ name: "@unique" }], + foreignKeyFor: [ + "user" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - userId: { type: 'String' }, - }, - }, + id: { type: "String" }, + userId: { type: "String" } + } + } }, typeDefs: { CommonFields: { - name: 'CommonFields', + name: "CommonFields", fields: { id: { - name: 'id', - type: 'String', - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + name: "id", + type: "String", + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], - }, - }, - }, + attributes: [{ name: "@updatedAt" }] + } + } + } }, enums: { Role: { - ADMIN: 'ADMIN', - USER: 'USER', - }, + ADMIN: "ADMIN", + USER: "USER" + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema; diff --git a/tests/e2e/orm/schemas/delegate/input.ts b/tests/e2e/orm/schemas/delegate/input.ts index cbb5a808..1d43c413 100644 --- a/tests/e2e/orm/schemas/delegate/input.ts +++ b/tests/e2e/orm/schemas/delegate/input.ts @@ -5,197 +5,146 @@ /* 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 { - 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> = $SimplifiedModelResult< - $Schema, - 'User', - Args ->; -export type CommentFindManyArgs = $FindManyArgs<$Schema, 'Comment'>; -export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, 'Comment'>; -export type CommentFindFirstArgs = $FindFirstArgs<$Schema, 'Comment'>; -export type CommentCreateArgs = $CreateArgs<$Schema, 'Comment'>; -export type CommentCreateManyArgs = $CreateManyArgs<$Schema, 'Comment'>; -export type CommentCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Comment'>; -export type CommentUpdateArgs = $UpdateArgs<$Schema, 'Comment'>; -export type CommentUpdateManyArgs = $UpdateManyArgs<$Schema, 'Comment'>; -export type CommentUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Comment'>; -export type CommentUpsertArgs = $UpsertArgs<$Schema, 'Comment'>; -export type CommentDeleteArgs = $DeleteArgs<$Schema, 'Comment'>; -export type CommentDeleteManyArgs = $DeleteManyArgs<$Schema, 'Comment'>; -export type CommentCountArgs = $CountArgs<$Schema, 'Comment'>; -export type CommentAggregateArgs = $AggregateArgs<$Schema, 'Comment'>; -export type CommentGroupByArgs = $GroupByArgs<$Schema, 'Comment'>; -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 AssetFindManyArgs = $FindManyArgs<$Schema, 'Asset'>; -export type AssetFindUniqueArgs = $FindUniqueArgs<$Schema, 'Asset'>; -export type AssetFindFirstArgs = $FindFirstArgs<$Schema, 'Asset'>; -export type AssetCreateArgs = $CreateArgs<$Schema, 'Asset'>; -export type AssetCreateManyArgs = $CreateManyArgs<$Schema, 'Asset'>; -export type AssetCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Asset'>; -export type AssetUpdateArgs = $UpdateArgs<$Schema, 'Asset'>; -export type AssetUpdateManyArgs = $UpdateManyArgs<$Schema, 'Asset'>; -export type AssetUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Asset'>; -export type AssetUpsertArgs = $UpsertArgs<$Schema, 'Asset'>; -export type AssetDeleteArgs = $DeleteArgs<$Schema, 'Asset'>; -export type AssetDeleteManyArgs = $DeleteManyArgs<$Schema, 'Asset'>; -export type AssetCountArgs = $CountArgs<$Schema, 'Asset'>; -export type AssetAggregateArgs = $AggregateArgs<$Schema, 'Asset'>; -export type AssetGroupByArgs = $GroupByArgs<$Schema, 'Asset'>; -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 VideoFindManyArgs = $FindManyArgs<$Schema, 'Video'>; -export type VideoFindUniqueArgs = $FindUniqueArgs<$Schema, 'Video'>; -export type VideoFindFirstArgs = $FindFirstArgs<$Schema, 'Video'>; -export type VideoCreateArgs = $CreateArgs<$Schema, 'Video'>; -export type VideoCreateManyArgs = $CreateManyArgs<$Schema, 'Video'>; -export type VideoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Video'>; -export type VideoUpdateArgs = $UpdateArgs<$Schema, 'Video'>; -export type VideoUpdateManyArgs = $UpdateManyArgs<$Schema, 'Video'>; -export type VideoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Video'>; -export type VideoUpsertArgs = $UpsertArgs<$Schema, 'Video'>; -export type VideoDeleteArgs = $DeleteArgs<$Schema, 'Video'>; -export type VideoDeleteManyArgs = $DeleteManyArgs<$Schema, 'Video'>; -export type VideoCountArgs = $CountArgs<$Schema, 'Video'>; -export type VideoAggregateArgs = $AggregateArgs<$Schema, 'Video'>; -export type VideoGroupByArgs = $GroupByArgs<$Schema, 'Video'>; -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 RatedVideoFindManyArgs = $FindManyArgs<$Schema, 'RatedVideo'>; -export type RatedVideoFindUniqueArgs = $FindUniqueArgs<$Schema, 'RatedVideo'>; -export type RatedVideoFindFirstArgs = $FindFirstArgs<$Schema, 'RatedVideo'>; -export type RatedVideoCreateArgs = $CreateArgs<$Schema, 'RatedVideo'>; -export type RatedVideoCreateManyArgs = $CreateManyArgs<$Schema, 'RatedVideo'>; -export type RatedVideoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'RatedVideo'>; -export type RatedVideoUpdateArgs = $UpdateArgs<$Schema, 'RatedVideo'>; -export type RatedVideoUpdateManyArgs = $UpdateManyArgs<$Schema, 'RatedVideo'>; -export type RatedVideoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'RatedVideo'>; -export type RatedVideoUpsertArgs = $UpsertArgs<$Schema, 'RatedVideo'>; -export type RatedVideoDeleteArgs = $DeleteArgs<$Schema, 'RatedVideo'>; -export type RatedVideoDeleteManyArgs = $DeleteManyArgs<$Schema, 'RatedVideo'>; -export type RatedVideoCountArgs = $CountArgs<$Schema, 'RatedVideo'>; -export type RatedVideoAggregateArgs = $AggregateArgs<$Schema, 'RatedVideo'>; -export type RatedVideoGroupByArgs = $GroupByArgs<$Schema, 'RatedVideo'>; -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 ImageFindManyArgs = $FindManyArgs<$Schema, 'Image'>; -export type ImageFindUniqueArgs = $FindUniqueArgs<$Schema, 'Image'>; -export type ImageFindFirstArgs = $FindFirstArgs<$Schema, 'Image'>; -export type ImageCreateArgs = $CreateArgs<$Schema, 'Image'>; -export type ImageCreateManyArgs = $CreateManyArgs<$Schema, 'Image'>; -export type ImageCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Image'>; -export type ImageUpdateArgs = $UpdateArgs<$Schema, 'Image'>; -export type ImageUpdateManyArgs = $UpdateManyArgs<$Schema, 'Image'>; -export type ImageUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Image'>; -export type ImageUpsertArgs = $UpsertArgs<$Schema, 'Image'>; -export type ImageDeleteArgs = $DeleteArgs<$Schema, 'Image'>; -export type ImageDeleteManyArgs = $DeleteManyArgs<$Schema, 'Image'>; -export type ImageCountArgs = $CountArgs<$Schema, 'Image'>; -export type ImageAggregateArgs = $AggregateArgs<$Schema, 'Image'>; -export type ImageGroupByArgs = $GroupByArgs<$Schema, 'Image'>; -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 GalleryFindManyArgs = $FindManyArgs<$Schema, 'Gallery'>; -export type GalleryFindUniqueArgs = $FindUniqueArgs<$Schema, 'Gallery'>; -export type GalleryFindFirstArgs = $FindFirstArgs<$Schema, 'Gallery'>; -export type GalleryCreateArgs = $CreateArgs<$Schema, 'Gallery'>; -export type GalleryCreateManyArgs = $CreateManyArgs<$Schema, 'Gallery'>; -export type GalleryCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Gallery'>; -export type GalleryUpdateArgs = $UpdateArgs<$Schema, 'Gallery'>; -export type GalleryUpdateManyArgs = $UpdateManyArgs<$Schema, 'Gallery'>; -export type GalleryUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Gallery'>; -export type GalleryUpsertArgs = $UpsertArgs<$Schema, 'Gallery'>; -export type GalleryDeleteArgs = $DeleteArgs<$Schema, 'Gallery'>; -export type GalleryDeleteManyArgs = $DeleteManyArgs<$Schema, 'Gallery'>; -export type GalleryCountArgs = $CountArgs<$Schema, 'Gallery'>; -export type GalleryAggregateArgs = $AggregateArgs<$Schema, 'Gallery'>; -export type GalleryGroupByArgs = $GroupByArgs<$Schema, 'Gallery'>; -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 ->; +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 { 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> = $SimplifiedModelResult<$Schema, "User", Args>; +export type CommentFindManyArgs = $FindManyArgs<$Schema, "Comment">; +export type CommentFindUniqueArgs = $FindUniqueArgs<$Schema, "Comment">; +export type CommentFindFirstArgs = $FindFirstArgs<$Schema, "Comment">; +export type CommentCreateArgs = $CreateArgs<$Schema, "Comment">; +export type CommentCreateManyArgs = $CreateManyArgs<$Schema, "Comment">; +export type CommentCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Comment">; +export type CommentUpdateArgs = $UpdateArgs<$Schema, "Comment">; +export type CommentUpdateManyArgs = $UpdateManyArgs<$Schema, "Comment">; +export type CommentUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Comment">; +export type CommentUpsertArgs = $UpsertArgs<$Schema, "Comment">; +export type CommentDeleteArgs = $DeleteArgs<$Schema, "Comment">; +export type CommentDeleteManyArgs = $DeleteManyArgs<$Schema, "Comment">; +export type CommentCountArgs = $CountArgs<$Schema, "Comment">; +export type CommentAggregateArgs = $AggregateArgs<$Schema, "Comment">; +export type CommentGroupByArgs = $GroupByArgs<$Schema, "Comment">; +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 AssetFindManyArgs = $FindManyArgs<$Schema, "Asset">; +export type AssetFindUniqueArgs = $FindUniqueArgs<$Schema, "Asset">; +export type AssetFindFirstArgs = $FindFirstArgs<$Schema, "Asset">; +export type AssetCreateArgs = $CreateArgs<$Schema, "Asset">; +export type AssetCreateManyArgs = $CreateManyArgs<$Schema, "Asset">; +export type AssetCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Asset">; +export type AssetUpdateArgs = $UpdateArgs<$Schema, "Asset">; +export type AssetUpdateManyArgs = $UpdateManyArgs<$Schema, "Asset">; +export type AssetUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Asset">; +export type AssetUpsertArgs = $UpsertArgs<$Schema, "Asset">; +export type AssetDeleteArgs = $DeleteArgs<$Schema, "Asset">; +export type AssetDeleteManyArgs = $DeleteManyArgs<$Schema, "Asset">; +export type AssetCountArgs = $CountArgs<$Schema, "Asset">; +export type AssetAggregateArgs = $AggregateArgs<$Schema, "Asset">; +export type AssetGroupByArgs = $GroupByArgs<$Schema, "Asset">; +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 VideoFindManyArgs = $FindManyArgs<$Schema, "Video">; +export type VideoFindUniqueArgs = $FindUniqueArgs<$Schema, "Video">; +export type VideoFindFirstArgs = $FindFirstArgs<$Schema, "Video">; +export type VideoCreateArgs = $CreateArgs<$Schema, "Video">; +export type VideoCreateManyArgs = $CreateManyArgs<$Schema, "Video">; +export type VideoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Video">; +export type VideoUpdateArgs = $UpdateArgs<$Schema, "Video">; +export type VideoUpdateManyArgs = $UpdateManyArgs<$Schema, "Video">; +export type VideoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Video">; +export type VideoUpsertArgs = $UpsertArgs<$Schema, "Video">; +export type VideoDeleteArgs = $DeleteArgs<$Schema, "Video">; +export type VideoDeleteManyArgs = $DeleteManyArgs<$Schema, "Video">; +export type VideoCountArgs = $CountArgs<$Schema, "Video">; +export type VideoAggregateArgs = $AggregateArgs<$Schema, "Video">; +export type VideoGroupByArgs = $GroupByArgs<$Schema, "Video">; +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 RatedVideoFindManyArgs = $FindManyArgs<$Schema, "RatedVideo">; +export type RatedVideoFindUniqueArgs = $FindUniqueArgs<$Schema, "RatedVideo">; +export type RatedVideoFindFirstArgs = $FindFirstArgs<$Schema, "RatedVideo">; +export type RatedVideoCreateArgs = $CreateArgs<$Schema, "RatedVideo">; +export type RatedVideoCreateManyArgs = $CreateManyArgs<$Schema, "RatedVideo">; +export type RatedVideoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "RatedVideo">; +export type RatedVideoUpdateArgs = $UpdateArgs<$Schema, "RatedVideo">; +export type RatedVideoUpdateManyArgs = $UpdateManyArgs<$Schema, "RatedVideo">; +export type RatedVideoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "RatedVideo">; +export type RatedVideoUpsertArgs = $UpsertArgs<$Schema, "RatedVideo">; +export type RatedVideoDeleteArgs = $DeleteArgs<$Schema, "RatedVideo">; +export type RatedVideoDeleteManyArgs = $DeleteManyArgs<$Schema, "RatedVideo">; +export type RatedVideoCountArgs = $CountArgs<$Schema, "RatedVideo">; +export type RatedVideoAggregateArgs = $AggregateArgs<$Schema, "RatedVideo">; +export type RatedVideoGroupByArgs = $GroupByArgs<$Schema, "RatedVideo">; +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 ImageFindManyArgs = $FindManyArgs<$Schema, "Image">; +export type ImageFindUniqueArgs = $FindUniqueArgs<$Schema, "Image">; +export type ImageFindFirstArgs = $FindFirstArgs<$Schema, "Image">; +export type ImageCreateArgs = $CreateArgs<$Schema, "Image">; +export type ImageCreateManyArgs = $CreateManyArgs<$Schema, "Image">; +export type ImageCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Image">; +export type ImageUpdateArgs = $UpdateArgs<$Schema, "Image">; +export type ImageUpdateManyArgs = $UpdateManyArgs<$Schema, "Image">; +export type ImageUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Image">; +export type ImageUpsertArgs = $UpsertArgs<$Schema, "Image">; +export type ImageDeleteArgs = $DeleteArgs<$Schema, "Image">; +export type ImageDeleteManyArgs = $DeleteManyArgs<$Schema, "Image">; +export type ImageCountArgs = $CountArgs<$Schema, "Image">; +export type ImageAggregateArgs = $AggregateArgs<$Schema, "Image">; +export type ImageGroupByArgs = $GroupByArgs<$Schema, "Image">; +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 GalleryFindManyArgs = $FindManyArgs<$Schema, "Gallery">; +export type GalleryFindUniqueArgs = $FindUniqueArgs<$Schema, "Gallery">; +export type GalleryFindFirstArgs = $FindFirstArgs<$Schema, "Gallery">; +export type GalleryCreateArgs = $CreateArgs<$Schema, "Gallery">; +export type GalleryCreateManyArgs = $CreateManyArgs<$Schema, "Gallery">; +export type GalleryCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Gallery">; +export type GalleryUpdateArgs = $UpdateArgs<$Schema, "Gallery">; +export type GalleryUpdateManyArgs = $UpdateManyArgs<$Schema, "Gallery">; +export type GalleryUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Gallery">; +export type GalleryUpsertArgs = $UpsertArgs<$Schema, "Gallery">; +export type GalleryDeleteArgs = $DeleteArgs<$Schema, "Gallery">; +export type GalleryDeleteManyArgs = $DeleteManyArgs<$Schema, "Gallery">; +export type GalleryCountArgs = $CountArgs<$Schema, "Gallery">; +export type GalleryAggregateArgs = $AggregateArgs<$Schema, "Gallery">; +export type GalleryGroupByArgs = $GroupByArgs<$Schema, "Gallery">; +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>; diff --git a/tests/e2e/orm/schemas/delegate/models.ts b/tests/e2e/orm/schemas/delegate/models.ts index 9d37be96..0a4350d2 100644 --- a/tests/e2e/orm/schemas/delegate/models.ts +++ b/tests/e2e/orm/schemas/delegate/models.ts @@ -5,12 +5,12 @@ /* 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 Comment = $ModelResult<$Schema, 'Comment'>; -export type Asset = $ModelResult<$Schema, 'Asset'>; -export type Video = $ModelResult<$Schema, 'Video'>; -export type RatedVideo = $ModelResult<$Schema, 'RatedVideo'>; -export type Image = $ModelResult<$Schema, 'Image'>; -export type Gallery = $ModelResult<$Schema, 'Gallery'>; +import { type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Comment = $ModelResult<$Schema, "Comment">; +export type Asset = $ModelResult<$Schema, "Asset">; +export type Video = $ModelResult<$Schema, "Video">; +export type RatedVideo = $ModelResult<$Schema, "RatedVideo">; +export type Image = $ModelResult<$Schema, "Image">; +export type Gallery = $ModelResult<$Schema, "Gallery">; diff --git a/tests/e2e/orm/schemas/delegate/schema.ts b/tests/e2e/orm/schemas/delegate/schema.ts index e085404c..8767b8e1 100644 --- a/tests/e2e/orm/schemas/delegate/schema.ts +++ b/tests/e2e/orm/schemas/delegate/schema.ts @@ -5,540 +5,461 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'sqlite', + type: "sqlite" }, models: { User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, optional: true, - attributes: [{ name: '@unique' }], + attributes: [{ name: "@unique" }] }, level: { - name: 'level', - type: 'Int', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, + name: "level", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 }, assets: { - name: 'assets', - type: 'Asset', + name: "assets", + type: "Asset", array: true, - relation: { opposite: 'owner' }, + relation: { opposite: "owner" } }, ratedVideos: { - name: 'ratedVideos', - type: 'RatedVideo', + name: "ratedVideos", + type: "RatedVideo", array: true, - attributes: [ - { name: '@relation', args: [{ name: 'name', value: ExpressionUtils.literal('direct') }] }, - ], - relation: { opposite: 'user', name: 'direct' }, - }, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("direct") }] }], + relation: { opposite: "user", name: "direct" } + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - email: { type: 'String' }, - }, + id: { type: "Int" }, + email: { type: "String" } + } }, Comment: { - name: 'Comment', + name: "Comment", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, content: { - name: 'content', - type: 'String', + name: "content", + type: "String" }, asset: { - name: 'asset', - type: 'Asset', + name: "asset", + type: "Asset", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('assetId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'comments', fields: ['assetId'], references: ['id'], onDelete: 'Cascade' }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("assetId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "comments", fields: ["assetId"], references: ["id"], onDelete: "Cascade" } }, assetId: { - name: 'assetId', - type: 'Int', + name: "assetId", + type: "Int", optional: true, - foreignKeyFor: ['asset'], - }, + foreignKeyFor: [ + "asset" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, + id: { type: "Int" } + } }, Asset: { - name: 'Asset', + name: "Asset", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, viewCount: { - name: 'viewCount', - type: 'Int', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, + name: "viewCount", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 }, owner: { - name: 'owner', - type: 'User', + name: "owner", + type: "User", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'assets', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "assets", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'Int', + name: "ownerId", + type: "Int", optional: true, - foreignKeyFor: ['owner'], + foreignKeyFor: [ + "owner" + ] }, comments: { - name: 'comments', - type: 'Comment', + name: "comments", + type: "Comment", array: true, - relation: { opposite: 'asset' }, + relation: { opposite: "asset" } }, assetType: { - name: 'assetType', - type: 'String', - isDiscriminator: true, - }, + name: "assetType", + type: "String", + isDiscriminator: true + } }, attributes: [ - { name: '@@delegate', args: [{ name: 'discriminator', value: ExpressionUtils.field('assetType') }] }, + { name: "@@delegate", args: [{ name: "discriminator", value: ExpressionUtils.field("assetType") }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, + id: { type: "Int" } }, isDelegate: true, - subModels: ['Video', 'Image'], + subModels: ["Video", "Image"] }, Video: { - name: 'Video', - baseModel: 'Asset', + name: "Video", + baseModel: "Asset", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - originModel: 'Asset', - attributes: [{ name: '@updatedAt' }], + originModel: "Asset", + attributes: [{ name: "@updatedAt" }] }, viewCount: { - name: 'viewCount', - type: 'Int', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, + name: "viewCount", + type: "Int", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 }, owner: { - name: 'owner', - type: 'User', + name: "owner", + type: "User", optional: true, - originModel: 'Asset', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'assets', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + originModel: "Asset", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "assets", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'Int', + name: "ownerId", + type: "Int", optional: true, - originModel: 'Asset', - foreignKeyFor: ['owner'], + originModel: "Asset", + foreignKeyFor: [ + "owner" + ] }, comments: { - name: 'comments', - type: 'Comment', + name: "comments", + type: "Comment", array: true, - originModel: 'Asset', - relation: { opposite: 'asset' }, + originModel: "Asset", + relation: { opposite: "asset" } }, assetType: { - name: 'assetType', - type: 'String', - originModel: 'Asset', - isDiscriminator: true, + name: "assetType", + type: "String", + originModel: "Asset", + isDiscriminator: true }, duration: { - name: 'duration', - type: 'Int', + name: "duration", + type: "Int" }, url: { - name: 'url', - type: 'String', + name: "url", + type: "String", unique: true, - attributes: [{ name: '@unique' }], + attributes: [{ name: "@unique" }] }, videoType: { - name: 'videoType', - type: 'String', - isDiscriminator: true, - }, + name: "videoType", + type: "String", + isDiscriminator: true + } }, attributes: [ - { name: '@@delegate', args: [{ name: 'discriminator', value: ExpressionUtils.field('videoType') }] }, + { name: "@@delegate", args: [{ name: "discriminator", value: ExpressionUtils.field("videoType") }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - url: { type: 'String' }, + id: { type: "Int" }, + url: { type: "String" } }, isDelegate: true, - subModels: ['RatedVideo'], + subModels: ["RatedVideo"] }, RatedVideo: { - name: 'RatedVideo', - baseModel: 'Video', + name: "RatedVideo", + baseModel: "Video", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - originModel: 'Asset', - attributes: [{ name: '@updatedAt' }], + originModel: "Asset", + attributes: [{ name: "@updatedAt" }] }, viewCount: { - name: 'viewCount', - type: 'Int', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, + name: "viewCount", + type: "Int", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 }, owner: { - name: 'owner', - type: 'User', + name: "owner", + type: "User", optional: true, - originModel: 'Asset', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'assets', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + originModel: "Asset", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "assets", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'Int', + name: "ownerId", + type: "Int", optional: true, - originModel: 'Asset', - foreignKeyFor: ['owner'], + originModel: "Asset", + foreignKeyFor: [ + "owner" + ] }, comments: { - name: 'comments', - type: 'Comment', + name: "comments", + type: "Comment", array: true, - originModel: 'Asset', - relation: { opposite: 'asset' }, + originModel: "Asset", + relation: { opposite: "asset" } }, assetType: { - name: 'assetType', - type: 'String', - originModel: 'Asset', - isDiscriminator: true, + name: "assetType", + type: "String", + originModel: "Asset", + isDiscriminator: true }, duration: { - name: 'duration', - type: 'Int', - originModel: 'Video', + name: "duration", + type: "Int", + originModel: "Video" }, url: { - name: 'url', - type: 'String', + name: "url", + type: "String", unique: true, - originModel: 'Video', - attributes: [{ name: '@unique' }], + originModel: "Video", + attributes: [{ name: "@unique" }] }, videoType: { - name: 'videoType', - type: 'String', - originModel: 'Video', - isDiscriminator: true, + name: "videoType", + type: "String", + originModel: "Video", + isDiscriminator: true }, rating: { - name: 'rating', - type: 'Int', + name: "rating", + type: "Int" }, user: { - name: 'user', - type: 'User', + name: "user", + type: "User", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'name', value: ExpressionUtils.literal('direct') }, - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('userId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { - opposite: 'ratedVideos', - name: 'direct', - fields: ['userId'], - references: ['id'], - onDelete: 'Cascade', - }, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("direct") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "ratedVideos", name: "direct", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { - name: 'userId', - type: 'Int', + name: "userId", + type: "Int", optional: true, - foreignKeyFor: ['user'], - }, + foreignKeyFor: [ + "user" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - url: { type: 'String' }, - }, + id: { type: "Int" }, + url: { type: "String" } + } }, Image: { - name: 'Image', - baseModel: 'Asset', + name: "Image", + baseModel: "Asset", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - originModel: 'Asset', - attributes: [{ name: '@updatedAt' }], + originModel: "Asset", + attributes: [{ name: "@updatedAt" }] }, viewCount: { - name: 'viewCount', - type: 'Int', - originModel: 'Asset', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, + name: "viewCount", + type: "Int", + originModel: "Asset", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 }, owner: { - name: 'owner', - type: 'User', + name: "owner", + type: "User", optional: true, - originModel: 'Asset', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'assets', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + originModel: "Asset", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "assets", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'Int', + name: "ownerId", + type: "Int", optional: true, - originModel: 'Asset', - foreignKeyFor: ['owner'], + originModel: "Asset", + foreignKeyFor: [ + "owner" + ] }, comments: { - name: 'comments', - type: 'Comment', + name: "comments", + type: "Comment", array: true, - originModel: 'Asset', - relation: { opposite: 'asset' }, + originModel: "Asset", + relation: { opposite: "asset" } }, assetType: { - name: 'assetType', - type: 'String', - originModel: 'Asset', - isDiscriminator: true, + name: "assetType", + type: "String", + originModel: "Asset", + isDiscriminator: true }, format: { - name: 'format', - type: 'String', + name: "format", + type: "String" }, gallery: { - name: 'gallery', - type: 'Gallery', + name: "gallery", + type: "Gallery", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('galleryId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'images', fields: ['galleryId'], references: ['id'], onDelete: 'Cascade' }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("galleryId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "images", fields: ["galleryId"], references: ["id"], onDelete: "Cascade" } }, galleryId: { - name: 'galleryId', - type: 'Int', + name: "galleryId", + type: "Int", optional: true, - foreignKeyFor: ['gallery'], - }, + foreignKeyFor: [ + "gallery" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, + id: { type: "Int" } + } }, Gallery: { - name: 'Gallery', + name: "Gallery", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, images: { - name: 'images', - type: 'Image', + name: "images", + type: "Image", array: true, - relation: { opposite: 'gallery' }, - }, + relation: { opposite: "gallery" } + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, - }, + id: { type: "Int" } + } + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema; diff --git a/tests/e2e/orm/schemas/name-mapping/input.ts b/tests/e2e/orm/schemas/name-mapping/input.ts index 63aa490a..6c876632 100644 --- a/tests/e2e/orm/schemas/name-mapping/input.ts +++ b/tests/e2e/orm/schemas/name-mapping/input.ts @@ -5,77 +5,46 @@ /* 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 { - 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> = $SimplifiedModelResult< - $Schema, - 'User', - 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> = $SimplifiedModelResult< - $Schema, - 'Post', - Args ->; +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 { 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> = $SimplifiedModelResult<$Schema, "User", 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> = $SimplifiedModelResult<$Schema, "Post", Args>; diff --git a/tests/e2e/orm/schemas/name-mapping/models.ts b/tests/e2e/orm/schemas/name-mapping/models.ts index 1d56e435..72654e58 100644 --- a/tests/e2e/orm/schemas/name-mapping/models.ts +++ b/tests/e2e/orm/schemas/name-mapping/models.ts @@ -5,7 +5,7 @@ /* 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'>; +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">; diff --git a/tests/e2e/orm/schemas/name-mapping/schema.ts b/tests/e2e/orm/schemas/name-mapping/schema.ts index cd26b74d..5c27728b 100644 --- a/tests/e2e/orm/schemas/name-mapping/schema.ts +++ b/tests/e2e/orm/schemas/name-mapping/schema.ts @@ -5,99 +5,84 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'sqlite', + type: "sqlite" }, models: { User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, - attributes: [ - { name: '@map', args: [{ name: 'name', value: ExpressionUtils.literal('user_email') }] }, - { name: '@unique' }, - ], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_email") }] }, { name: "@unique" }] }, posts: { - name: 'posts', - type: 'Post', + name: "posts", + type: "Post", array: true, - relation: { opposite: 'author' }, - }, + relation: { opposite: "author" } + } }, - attributes: [{ name: '@@map', args: [{ name: 'name', value: ExpressionUtils.literal('users') }] }], - idFields: ['id'], + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("users") }] } + ], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - email: { type: 'String' }, - }, + id: { type: "Int" }, + email: { type: "String" } + } }, Post: { - name: 'Post', + name: "Post", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, title: { - name: 'title', - type: 'String', - attributes: [ - { name: '@map', args: [{ name: 'name', value: ExpressionUtils.literal('post_title') }] }, - ], + name: "title", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("post_title") }] }] }, 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')]) }, - ], - }, - ], - relation: { opposite: 'posts', fields: ['authorId'], references: ['id'] }, + name: "author", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "posts", fields: ["authorId"], references: ["id"] } }, authorId: { - name: 'authorId', - type: 'Int', - attributes: [ - { name: '@map', args: [{ name: 'name', value: ExpressionUtils.literal('author_id') }] }, - ], - foreignKeyFor: ['author'], - }, + name: "authorId", + type: "Int", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("author_id") }] }], + foreignKeyFor: [ + "author" + ] + } }, - attributes: [{ name: '@@map', args: [{ name: 'name', value: ExpressionUtils.literal('posts') }] }], - idFields: ['id'], + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("posts") }] } + ], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, - }, + id: { type: "Int" } + } + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema; diff --git a/tests/e2e/orm/schemas/petstore/input.ts b/tests/e2e/orm/schemas/petstore/input.ts index e6cf9c14..690d1d90 100644 --- a/tests/e2e/orm/schemas/petstore/input.ts +++ b/tests/e2e/orm/schemas/petstore/input.ts @@ -5,101 +5,66 @@ /* 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 { - 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> = $SimplifiedModelResult< - $Schema, - 'User', - Args ->; -export type PetFindManyArgs = $FindManyArgs<$Schema, 'Pet'>; -export type PetFindUniqueArgs = $FindUniqueArgs<$Schema, 'Pet'>; -export type PetFindFirstArgs = $FindFirstArgs<$Schema, 'Pet'>; -export type PetCreateArgs = $CreateArgs<$Schema, 'Pet'>; -export type PetCreateManyArgs = $CreateManyArgs<$Schema, 'Pet'>; -export type PetCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Pet'>; -export type PetUpdateArgs = $UpdateArgs<$Schema, 'Pet'>; -export type PetUpdateManyArgs = $UpdateManyArgs<$Schema, 'Pet'>; -export type PetUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Pet'>; -export type PetUpsertArgs = $UpsertArgs<$Schema, 'Pet'>; -export type PetDeleteArgs = $DeleteArgs<$Schema, 'Pet'>; -export type PetDeleteManyArgs = $DeleteManyArgs<$Schema, 'Pet'>; -export type PetCountArgs = $CountArgs<$Schema, 'Pet'>; -export type PetAggregateArgs = $AggregateArgs<$Schema, 'Pet'>; -export type PetGroupByArgs = $GroupByArgs<$Schema, 'Pet'>; -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 OrderFindManyArgs = $FindManyArgs<$Schema, 'Order'>; -export type OrderFindUniqueArgs = $FindUniqueArgs<$Schema, 'Order'>; -export type OrderFindFirstArgs = $FindFirstArgs<$Schema, 'Order'>; -export type OrderCreateArgs = $CreateArgs<$Schema, 'Order'>; -export type OrderCreateManyArgs = $CreateManyArgs<$Schema, 'Order'>; -export type OrderCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Order'>; -export type OrderUpdateArgs = $UpdateArgs<$Schema, 'Order'>; -export type OrderUpdateManyArgs = $UpdateManyArgs<$Schema, 'Order'>; -export type OrderUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Order'>; -export type OrderUpsertArgs = $UpsertArgs<$Schema, 'Order'>; -export type OrderDeleteArgs = $DeleteArgs<$Schema, 'Order'>; -export type OrderDeleteManyArgs = $DeleteManyArgs<$Schema, 'Order'>; -export type OrderCountArgs = $CountArgs<$Schema, 'Order'>; -export type OrderAggregateArgs = $AggregateArgs<$Schema, 'Order'>; -export type OrderGroupByArgs = $GroupByArgs<$Schema, 'Order'>; -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 ->; +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 { 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> = $SimplifiedModelResult<$Schema, "User", Args>; +export type PetFindManyArgs = $FindManyArgs<$Schema, "Pet">; +export type PetFindUniqueArgs = $FindUniqueArgs<$Schema, "Pet">; +export type PetFindFirstArgs = $FindFirstArgs<$Schema, "Pet">; +export type PetCreateArgs = $CreateArgs<$Schema, "Pet">; +export type PetCreateManyArgs = $CreateManyArgs<$Schema, "Pet">; +export type PetCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Pet">; +export type PetUpdateArgs = $UpdateArgs<$Schema, "Pet">; +export type PetUpdateManyArgs = $UpdateManyArgs<$Schema, "Pet">; +export type PetUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Pet">; +export type PetUpsertArgs = $UpsertArgs<$Schema, "Pet">; +export type PetDeleteArgs = $DeleteArgs<$Schema, "Pet">; +export type PetDeleteManyArgs = $DeleteManyArgs<$Schema, "Pet">; +export type PetCountArgs = $CountArgs<$Schema, "Pet">; +export type PetAggregateArgs = $AggregateArgs<$Schema, "Pet">; +export type PetGroupByArgs = $GroupByArgs<$Schema, "Pet">; +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 OrderFindManyArgs = $FindManyArgs<$Schema, "Order">; +export type OrderFindUniqueArgs = $FindUniqueArgs<$Schema, "Order">; +export type OrderFindFirstArgs = $FindFirstArgs<$Schema, "Order">; +export type OrderCreateArgs = $CreateArgs<$Schema, "Order">; +export type OrderCreateManyArgs = $CreateManyArgs<$Schema, "Order">; +export type OrderCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Order">; +export type OrderUpdateArgs = $UpdateArgs<$Schema, "Order">; +export type OrderUpdateManyArgs = $UpdateManyArgs<$Schema, "Order">; +export type OrderUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Order">; +export type OrderUpsertArgs = $UpsertArgs<$Schema, "Order">; +export type OrderDeleteArgs = $DeleteArgs<$Schema, "Order">; +export type OrderDeleteManyArgs = $DeleteManyArgs<$Schema, "Order">; +export type OrderCountArgs = $CountArgs<$Schema, "Order">; +export type OrderAggregateArgs = $AggregateArgs<$Schema, "Order">; +export type OrderGroupByArgs = $GroupByArgs<$Schema, "Order">; +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>; diff --git a/tests/e2e/orm/schemas/petstore/models.ts b/tests/e2e/orm/schemas/petstore/models.ts index 840f39bb..dfa5b23e 100644 --- a/tests/e2e/orm/schemas/petstore/models.ts +++ b/tests/e2e/orm/schemas/petstore/models.ts @@ -5,8 +5,8 @@ /* 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 Pet = $ModelResult<$Schema, 'Pet'>; -export type Order = $ModelResult<$Schema, 'Order'>; +import { type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Pet = $ModelResult<$Schema, "Pet">; +export type Order = $ModelResult<$Schema, "Order">; diff --git a/tests/e2e/orm/schemas/petstore/schema.ts b/tests/e2e/orm/schemas/petstore/schema.ts index 0db944f1..747372a7 100644 --- a/tests/e2e/orm/schemas/petstore/schema.ts +++ b/tests/e2e/orm/schemas/petstore/schema.ts @@ -5,254 +5,153 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'sqlite', + type: "sqlite" }, models: { User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, - attributes: [{ name: '@unique' }], + attributes: [{ name: "@unique" }] }, orders: { - name: 'orders', - type: 'Order', + name: "orders", + type: "Order", array: true, - relation: { opposite: 'user' }, - }, + relation: { opposite: "user" } + } }, attributes: [ - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('create') }, - { name: 'condition', value: ExpressionUtils.literal(true) }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { name: 'condition', value: ExpressionUtils.literal(true) }, - ], - }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("create") }, { name: "condition", value: ExpressionUtils.literal(true) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.literal(true) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - email: { type: 'String' }, - }, + id: { type: "String" }, + email: { type: "String" } + } }, Pet: { - name: 'Pet', + name: "Pet", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, name: { - name: 'name', - type: 'String', + name: "name", + type: "String" }, category: { - name: 'category', - type: 'String', + name: "category", + type: "String" }, order: { - name: 'order', - type: 'Order', + name: "order", + type: "Order", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('orderId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - ], - }, - ], - relation: { opposite: 'pets', fields: ['orderId'], references: ['id'] }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("orderId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "pets", fields: ["orderId"], references: ["id"] } }, orderId: { - name: 'orderId', - type: 'String', + name: "orderId", + type: "String", optional: true, - foreignKeyFor: ['order'], - }, + foreignKeyFor: [ + "order" + ] + } }, attributes: [ - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary(ExpressionUtils.field('orderId'), '==', ExpressionUtils._null()), - '||', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('order'), ['user']), - '==', - ExpressionUtils.call('auth'), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('update') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '!=', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('post-update') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('before'), ['name']), - '==', - ExpressionUtils.field('name'), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('before'), ['category']), - '==', - ExpressionUtils.field('category'), - ), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('before'), ['orderId']), - '==', - ExpressionUtils._null(), - ), - ), - }, - ], - }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("orderId"), "==", ExpressionUtils._null()), "||", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("order"), ["user"]), "==", ExpressionUtils.call("auth"))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("update") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "!=", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("post-update") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("before"), ["name"]), "==", ExpressionUtils.field("name")), "&&", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("before"), ["category"]), "==", ExpressionUtils.field("category"))), "&&", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("before"), ["orderId"]), "==", ExpressionUtils._null())) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, + id: { type: "String" } + } }, Order: { - name: 'Order', + name: "Order", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('cuid') }] }, - ], - default: ExpressionUtils.call('cuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, pets: { - name: 'pets', - type: 'Pet', + name: "pets", + type: "Pet", array: true, - relation: { opposite: 'order' }, + relation: { opposite: "order" } }, user: { - name: 'user', - type: 'User', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('userId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - ], - }, - ], - relation: { opposite: 'orders', fields: ['userId'], references: ['id'] }, + name: "user", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "orders", fields: ["userId"], references: ["id"] } }, userId: { - name: 'userId', - type: 'String', - foreignKeyFor: ['user'], - }, + name: "userId", + type: "String", + foreignKeyFor: [ + "user" + ] + } }, attributes: [ - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read,create') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.call('auth'), - '==', - ExpressionUtils.field('user'), - ), - }, - ], - }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read,create") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils.field("user")) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, - }, + id: { type: "String" } + } + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema; diff --git a/tests/e2e/orm/schemas/todo/input.ts b/tests/e2e/orm/schemas/todo/input.ts index ac856b06..22fd5a19 100644 --- a/tests/e2e/orm/schemas/todo/input.ts +++ b/tests/e2e/orm/schemas/todo/input.ts @@ -5,149 +5,106 @@ /* 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 { - SimplifiedModelResult as $SimplifiedModelResult, - SelectIncludeOmit as $SelectIncludeOmit, -} from '@zenstackhq/orm'; -export type SpaceFindManyArgs = $FindManyArgs<$Schema, 'Space'>; -export type SpaceFindUniqueArgs = $FindUniqueArgs<$Schema, 'Space'>; -export type SpaceFindFirstArgs = $FindFirstArgs<$Schema, 'Space'>; -export type SpaceCreateArgs = $CreateArgs<$Schema, 'Space'>; -export type SpaceCreateManyArgs = $CreateManyArgs<$Schema, 'Space'>; -export type SpaceCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Space'>; -export type SpaceUpdateArgs = $UpdateArgs<$Schema, 'Space'>; -export type SpaceUpdateManyArgs = $UpdateManyArgs<$Schema, 'Space'>; -export type SpaceUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Space'>; -export type SpaceUpsertArgs = $UpsertArgs<$Schema, 'Space'>; -export type SpaceDeleteArgs = $DeleteArgs<$Schema, 'Space'>; -export type SpaceDeleteManyArgs = $DeleteManyArgs<$Schema, 'Space'>; -export type SpaceCountArgs = $CountArgs<$Schema, 'Space'>; -export type SpaceAggregateArgs = $AggregateArgs<$Schema, 'Space'>; -export type SpaceGroupByArgs = $GroupByArgs<$Schema, 'Space'>; -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 SpaceUserFindManyArgs = $FindManyArgs<$Schema, 'SpaceUser'>; -export type SpaceUserFindUniqueArgs = $FindUniqueArgs<$Schema, 'SpaceUser'>; -export type SpaceUserFindFirstArgs = $FindFirstArgs<$Schema, 'SpaceUser'>; -export type SpaceUserCreateArgs = $CreateArgs<$Schema, 'SpaceUser'>; -export type SpaceUserCreateManyArgs = $CreateManyArgs<$Schema, 'SpaceUser'>; -export type SpaceUserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'SpaceUser'>; -export type SpaceUserUpdateArgs = $UpdateArgs<$Schema, 'SpaceUser'>; -export type SpaceUserUpdateManyArgs = $UpdateManyArgs<$Schema, 'SpaceUser'>; -export type SpaceUserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'SpaceUser'>; -export type SpaceUserUpsertArgs = $UpsertArgs<$Schema, 'SpaceUser'>; -export type SpaceUserDeleteArgs = $DeleteArgs<$Schema, 'SpaceUser'>; -export type SpaceUserDeleteManyArgs = $DeleteManyArgs<$Schema, 'SpaceUser'>; -export type SpaceUserCountArgs = $CountArgs<$Schema, 'SpaceUser'>; -export type SpaceUserAggregateArgs = $AggregateArgs<$Schema, 'SpaceUser'>; -export type SpaceUserGroupByArgs = $GroupByArgs<$Schema, 'SpaceUser'>; -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 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> = $SimplifiedModelResult< - $Schema, - 'User', - Args ->; -export type ListFindManyArgs = $FindManyArgs<$Schema, 'List'>; -export type ListFindUniqueArgs = $FindUniqueArgs<$Schema, 'List'>; -export type ListFindFirstArgs = $FindFirstArgs<$Schema, 'List'>; -export type ListCreateArgs = $CreateArgs<$Schema, 'List'>; -export type ListCreateManyArgs = $CreateManyArgs<$Schema, 'List'>; -export type ListCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'List'>; -export type ListUpdateArgs = $UpdateArgs<$Schema, 'List'>; -export type ListUpdateManyArgs = $UpdateManyArgs<$Schema, 'List'>; -export type ListUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'List'>; -export type ListUpsertArgs = $UpsertArgs<$Schema, 'List'>; -export type ListDeleteArgs = $DeleteArgs<$Schema, 'List'>; -export type ListDeleteManyArgs = $DeleteManyArgs<$Schema, 'List'>; -export type ListCountArgs = $CountArgs<$Schema, 'List'>; -export type ListAggregateArgs = $AggregateArgs<$Schema, 'List'>; -export type ListGroupByArgs = $GroupByArgs<$Schema, 'List'>; -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 TodoFindManyArgs = $FindManyArgs<$Schema, 'Todo'>; -export type TodoFindUniqueArgs = $FindUniqueArgs<$Schema, 'Todo'>; -export type TodoFindFirstArgs = $FindFirstArgs<$Schema, 'Todo'>; -export type TodoCreateArgs = $CreateArgs<$Schema, 'Todo'>; -export type TodoCreateManyArgs = $CreateManyArgs<$Schema, 'Todo'>; -export type TodoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Todo'>; -export type TodoUpdateArgs = $UpdateArgs<$Schema, 'Todo'>; -export type TodoUpdateManyArgs = $UpdateManyArgs<$Schema, 'Todo'>; -export type TodoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Todo'>; -export type TodoUpsertArgs = $UpsertArgs<$Schema, 'Todo'>; -export type TodoDeleteArgs = $DeleteArgs<$Schema, 'Todo'>; -export type TodoDeleteManyArgs = $DeleteManyArgs<$Schema, 'Todo'>; -export type TodoCountArgs = $CountArgs<$Schema, 'Todo'>; -export type TodoAggregateArgs = $AggregateArgs<$Schema, 'Todo'>; -export type TodoGroupByArgs = $GroupByArgs<$Schema, 'Todo'>; -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 ->; +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 { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; +export type SpaceFindManyArgs = $FindManyArgs<$Schema, "Space">; +export type SpaceFindUniqueArgs = $FindUniqueArgs<$Schema, "Space">; +export type SpaceFindFirstArgs = $FindFirstArgs<$Schema, "Space">; +export type SpaceCreateArgs = $CreateArgs<$Schema, "Space">; +export type SpaceCreateManyArgs = $CreateManyArgs<$Schema, "Space">; +export type SpaceCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Space">; +export type SpaceUpdateArgs = $UpdateArgs<$Schema, "Space">; +export type SpaceUpdateManyArgs = $UpdateManyArgs<$Schema, "Space">; +export type SpaceUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Space">; +export type SpaceUpsertArgs = $UpsertArgs<$Schema, "Space">; +export type SpaceDeleteArgs = $DeleteArgs<$Schema, "Space">; +export type SpaceDeleteManyArgs = $DeleteManyArgs<$Schema, "Space">; +export type SpaceCountArgs = $CountArgs<$Schema, "Space">; +export type SpaceAggregateArgs = $AggregateArgs<$Schema, "Space">; +export type SpaceGroupByArgs = $GroupByArgs<$Schema, "Space">; +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 SpaceUserFindManyArgs = $FindManyArgs<$Schema, "SpaceUser">; +export type SpaceUserFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceUser">; +export type SpaceUserFindFirstArgs = $FindFirstArgs<$Schema, "SpaceUser">; +export type SpaceUserCreateArgs = $CreateArgs<$Schema, "SpaceUser">; +export type SpaceUserCreateManyArgs = $CreateManyArgs<$Schema, "SpaceUser">; +export type SpaceUserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "SpaceUser">; +export type SpaceUserUpdateArgs = $UpdateArgs<$Schema, "SpaceUser">; +export type SpaceUserUpdateManyArgs = $UpdateManyArgs<$Schema, "SpaceUser">; +export type SpaceUserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "SpaceUser">; +export type SpaceUserUpsertArgs = $UpsertArgs<$Schema, "SpaceUser">; +export type SpaceUserDeleteArgs = $DeleteArgs<$Schema, "SpaceUser">; +export type SpaceUserDeleteManyArgs = $DeleteManyArgs<$Schema, "SpaceUser">; +export type SpaceUserCountArgs = $CountArgs<$Schema, "SpaceUser">; +export type SpaceUserAggregateArgs = $AggregateArgs<$Schema, "SpaceUser">; +export type SpaceUserGroupByArgs = $GroupByArgs<$Schema, "SpaceUser">; +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 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> = $SimplifiedModelResult<$Schema, "User", Args>; +export type ListFindManyArgs = $FindManyArgs<$Schema, "List">; +export type ListFindUniqueArgs = $FindUniqueArgs<$Schema, "List">; +export type ListFindFirstArgs = $FindFirstArgs<$Schema, "List">; +export type ListCreateArgs = $CreateArgs<$Schema, "List">; +export type ListCreateManyArgs = $CreateManyArgs<$Schema, "List">; +export type ListCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "List">; +export type ListUpdateArgs = $UpdateArgs<$Schema, "List">; +export type ListUpdateManyArgs = $UpdateManyArgs<$Schema, "List">; +export type ListUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "List">; +export type ListUpsertArgs = $UpsertArgs<$Schema, "List">; +export type ListDeleteArgs = $DeleteArgs<$Schema, "List">; +export type ListDeleteManyArgs = $DeleteManyArgs<$Schema, "List">; +export type ListCountArgs = $CountArgs<$Schema, "List">; +export type ListAggregateArgs = $AggregateArgs<$Schema, "List">; +export type ListGroupByArgs = $GroupByArgs<$Schema, "List">; +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 TodoFindManyArgs = $FindManyArgs<$Schema, "Todo">; +export type TodoFindUniqueArgs = $FindUniqueArgs<$Schema, "Todo">; +export type TodoFindFirstArgs = $FindFirstArgs<$Schema, "Todo">; +export type TodoCreateArgs = $CreateArgs<$Schema, "Todo">; +export type TodoCreateManyArgs = $CreateManyArgs<$Schema, "Todo">; +export type TodoCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Todo">; +export type TodoUpdateArgs = $UpdateArgs<$Schema, "Todo">; +export type TodoUpdateManyArgs = $UpdateManyArgs<$Schema, "Todo">; +export type TodoUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Todo">; +export type TodoUpsertArgs = $UpsertArgs<$Schema, "Todo">; +export type TodoDeleteArgs = $DeleteArgs<$Schema, "Todo">; +export type TodoDeleteManyArgs = $DeleteManyArgs<$Schema, "Todo">; +export type TodoCountArgs = $CountArgs<$Schema, "Todo">; +export type TodoAggregateArgs = $AggregateArgs<$Schema, "Todo">; +export type TodoGroupByArgs = $GroupByArgs<$Schema, "Todo">; +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>; diff --git a/tests/e2e/orm/schemas/todo/models.ts b/tests/e2e/orm/schemas/todo/models.ts index 0d8ecda6..635b68de 100644 --- a/tests/e2e/orm/schemas/todo/models.ts +++ b/tests/e2e/orm/schemas/todo/models.ts @@ -5,10 +5,10 @@ /* eslint-disable */ -import { type SchemaType as $Schema } from './schema'; -import { type ModelResult as $ModelResult } from '@zenstackhq/orm'; -export type Space = $ModelResult<$Schema, 'Space'>; -export type SpaceUser = $ModelResult<$Schema, 'SpaceUser'>; -export type User = $ModelResult<$Schema, 'User'>; -export type List = $ModelResult<$Schema, 'List'>; -export type Todo = $ModelResult<$Schema, 'Todo'>; +import { type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult } from "@zenstackhq/orm"; +export type Space = $ModelResult<$Schema, "Space">; +export type SpaceUser = $ModelResult<$Schema, "SpaceUser">; +export type User = $ModelResult<$Schema, "User">; +export type List = $ModelResult<$Schema, "List">; +export type Todo = $ModelResult<$Schema, "Todo">; diff --git a/tests/e2e/orm/schemas/todo/schema.ts b/tests/e2e/orm/schemas/todo/schema.ts index 58f9ecfa..4a8f811c 100644 --- a/tests/e2e/orm/schemas/todo/schema.ts +++ b/tests/e2e/orm/schemas/todo/schema.ts @@ -5,831 +5,392 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'sqlite', + type: "sqlite" }, models: { Space: { - name: 'Space', + name: "Space", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('uuid') }] }, - ], - default: ExpressionUtils.call('uuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, name: { - name: 'name', - type: 'String', - attributes: [ - { - name: '@length', - args: [ - { name: 'min', value: ExpressionUtils.literal(4) }, - { name: 'max', value: ExpressionUtils.literal(50) }, - ], - }, - ], + name: "name", + type: "String", + attributes: [{ name: "@length", args: [{ name: "min", value: ExpressionUtils.literal(4) }, { name: "max", value: ExpressionUtils.literal(50) }] }] }, slug: { - name: 'slug', - type: 'String', + name: "slug", + type: "String", unique: true, - attributes: [ - { name: '@unique' }, - { - name: '@length', - args: [ - { name: 'min', value: ExpressionUtils.literal(4) }, - { name: 'max', value: ExpressionUtils.literal(16) }, - ], - }, - ], + attributes: [{ name: "@unique" }, { name: "@length", args: [{ name: "min", value: ExpressionUtils.literal(4) }, { name: "max", value: ExpressionUtils.literal(16) }] }] }, owner: { - name: 'owner', - type: 'User', + name: "owner", + type: "User", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'ownedSpaces', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "ownedSpaces", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'String', + name: "ownerId", + type: "String", optional: true, - foreignKeyFor: ['owner'], + foreignKeyFor: [ + "owner" + ] }, members: { - name: 'members', - type: 'SpaceUser', + name: "members", + type: "SpaceUser", array: true, - relation: { opposite: 'space' }, + relation: { opposite: "space" } }, lists: { - name: 'lists', - type: 'List', + name: "lists", + type: "List", array: true, - relation: { opposite: 'space' }, - }, + relation: { opposite: "space" } + } }, attributes: [ - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '==', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('create') }, - { name: 'condition', value: ExpressionUtils.literal(true) }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.field('members'), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('update,delete') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.field('members'), - '?', - ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.field('role'), - '==', - ExpressionUtils.literal('ADMIN'), - ), - ), - ), - }, - ], - }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("create") }, { name: "condition", value: ExpressionUtils.literal(true) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.field("members"), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("update,delete") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.field("members"), "?", ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "&&", ExpressionUtils.binary(ExpressionUtils.field("role"), "==", ExpressionUtils.literal("ADMIN")))) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - slug: { type: 'String' }, - }, + id: { type: "String" }, + slug: { type: "String" } + } }, SpaceUser: { - name: 'SpaceUser', + name: "SpaceUser", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('uuid') }] }, - ], - default: ExpressionUtils.call('uuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, space: { - name: 'space', - type: 'Space', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('spaceId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'members', fields: ['spaceId'], references: ['id'], onDelete: 'Cascade' }, + name: "space", + type: "Space", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "members", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } }, spaceId: { - name: 'spaceId', - type: 'String', - foreignKeyFor: ['space'], + name: "spaceId", + type: "String", + foreignKeyFor: [ + "space" + ] }, user: { - name: 'user', - type: 'User', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('userId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'spaces', fields: ['userId'], references: ['id'], onDelete: 'Cascade' }, + name: "user", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "spaces", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { - name: 'userId', - type: 'String', - foreignKeyFor: ['user'], + name: "userId", + type: "String", + foreignKeyFor: [ + "user" + ] }, role: { - name: 'role', - type: 'String', - }, + name: "role", + type: "String" + } }, attributes: [ - { - name: '@@unique', - args: [ - { - name: 'fields', - value: ExpressionUtils.array([ - ExpressionUtils.field('userId'), - ExpressionUtils.field('spaceId'), - ]), - }, - ], - }, - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '==', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('create,update,delete') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['ownerId']), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '||', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.field('role'), - '==', - ExpressionUtils.literal('ADMIN'), - ), - ), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - }, - ], - }, + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId"), ExpressionUtils.field("spaceId")]) }] }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("create,update,delete") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["ownerId"]), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "||", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "&&", ExpressionUtils.binary(ExpressionUtils.field("role"), "==", ExpressionUtils.literal("ADMIN"))))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]))) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - userId_spaceId: { userId: { type: 'String' }, spaceId: { type: 'String' } }, - }, + id: { type: "String" }, + userId_spaceId: { userId: { type: "String" }, spaceId: { type: "String" } } + } }, User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('uuid') }] }, - ], - default: ExpressionUtils.call('uuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, - attributes: [{ name: '@unique' }, { name: '@email' }], + attributes: [{ name: "@unique" }, { name: "@email" }] }, password: { - name: 'password', - type: 'String', - optional: true, + name: "password", + type: "String", + optional: true }, emailVerified: { - name: 'emailVerified', - type: 'DateTime', - optional: true, + name: "emailVerified", + type: "DateTime", + optional: true }, name: { - name: 'name', - type: 'String', - optional: true, + name: "name", + type: "String", + optional: true }, ownedSpaces: { - name: 'ownedSpaces', - type: 'Space', + name: "ownedSpaces", + type: "Space", array: true, - relation: { opposite: 'owner' }, + relation: { opposite: "owner" } }, spaces: { - name: 'spaces', - type: 'SpaceUser', + name: "spaces", + type: "SpaceUser", array: true, - relation: { opposite: 'user' }, + relation: { opposite: "user" } }, image: { - name: 'image', - type: 'String', + name: "image", + type: "String", optional: true, - attributes: [{ name: '@url' }], + attributes: [{ name: "@url" }] }, lists: { - name: 'lists', - type: 'List', + name: "lists", + type: "List", array: true, - relation: { opposite: 'owner' }, + relation: { opposite: "owner" } }, todos: { - name: 'todos', - type: 'Todo', + name: "todos", + type: "Todo", array: true, - relation: { opposite: 'owner' }, - }, + relation: { opposite: "owner" } + } }, attributes: [ - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('create') }, - { name: 'condition', value: ExpressionUtils.literal(true) }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.field('spaces'), - '?', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - '==', - ExpressionUtils.field('id'), - ), - }, - ], - }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("create") }, { name: "condition", value: ExpressionUtils.literal(true) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.field("spaces"), "?", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]), "==", ExpressionUtils.field("id")) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - email: { type: 'String' }, - }, + id: { type: "String" }, + email: { type: "String" } + } }, List: { - name: 'List', + name: "List", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('uuid') }] }, - ], - default: ExpressionUtils.call('uuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, space: { - name: 'space', - type: 'Space', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('spaceId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'lists', fields: ['spaceId'], references: ['id'], onDelete: 'Cascade' }, + name: "space", + type: "Space", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "lists", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } }, spaceId: { - name: 'spaceId', - type: 'String', - foreignKeyFor: ['space'], + name: "spaceId", + type: "String", + foreignKeyFor: [ + "space" + ] }, owner: { - name: 'owner', - type: 'User', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'lists', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + name: "owner", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "lists", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'String', - foreignKeyFor: ['owner'], + name: "ownerId", + type: "String", + foreignKeyFor: [ + "owner" + ] }, title: { - name: 'title', - type: 'String', - attributes: [ - { - name: '@length', - args: [ - { name: 'min', value: ExpressionUtils.literal(1) }, - { name: 'max', value: ExpressionUtils.literal(100) }, - ], - }, - ], + name: "title", + type: "String", + attributes: [{ name: "@length", args: [{ name: "min", value: ExpressionUtils.literal(1) }, { name: "max", value: ExpressionUtils.literal(100) }] }] }, private: { - name: 'private', - type: 'Boolean', - attributes: [ - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(false) }] }, - ], - default: false, + name: "private", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false }, todos: { - name: 'todos', - type: 'Todo', + name: "todos", + type: "Todo", array: true, - relation: { opposite: 'list' }, + relation: { opposite: "list" } }, revision: { - name: 'revision', - type: 'Int', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal(0) }] }], - default: 0, - }, + name: "revision", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 + } }, attributes: [ - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '==', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('read') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.field('ownerId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '||', - ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - '&&', - ExpressionUtils.unary('!', ExpressionUtils.field('private')), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('create') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.field('ownerId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('update') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.field('ownerId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - '&&', - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('space'), ['members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - ), - }, - ], - }, - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('post-update') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('before'), ['ownerId']), - '!=', - ExpressionUtils.field('ownerId'), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('delete') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.field('ownerId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - }, - ], - }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("ownerId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "||", ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]))), "&&", ExpressionUtils.unary("!", ExpressionUtils.field("private")))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("create") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("ownerId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "&&", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])))) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("update") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.field("ownerId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])), "&&", ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("space"), ["members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])))) }] }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("post-update") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("before"), ["ownerId"]), "!=", ExpressionUtils.field("ownerId")) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("delete") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.field("ownerId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, + id: { type: "String" } + } }, Todo: { - name: 'Todo', + name: "Todo", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('uuid') }] }, - ], - default: ExpressionUtils.call('uuid'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, owner: { - name: 'owner', - type: 'User', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('ownerId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'todos', fields: ['ownerId'], references: ['id'], onDelete: 'Cascade' }, + name: "owner", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "todos", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, ownerId: { - name: 'ownerId', - type: 'String', - foreignKeyFor: ['owner'], + name: "ownerId", + type: "String", + foreignKeyFor: [ + "owner" + ] }, list: { - name: 'list', - type: 'List', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('listId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - { name: 'onDelete', value: ExpressionUtils.literal('Cascade') }, - ], - }, - ], - relation: { opposite: 'todos', fields: ['listId'], references: ['id'], onDelete: 'Cascade' }, + name: "list", + type: "List", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("listId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "todos", fields: ["listId"], references: ["id"], onDelete: "Cascade" } }, listId: { - name: 'listId', - type: 'String', - foreignKeyFor: ['list'], + name: "listId", + type: "String", + foreignKeyFor: [ + "list" + ] }, title: { - name: 'title', - type: 'String', - attributes: [ - { - name: '@length', - args: [ - { name: 'min', value: ExpressionUtils.literal(1) }, - { name: 'max', value: ExpressionUtils.literal(100) }, - ], - }, - ], + name: "title", + type: "String", + attributes: [{ name: "@length", args: [{ name: "min", value: ExpressionUtils.literal(1) }, { name: "max", value: ExpressionUtils.literal(100) }] }] }, completedAt: { - name: 'completedAt', - type: 'DateTime', - optional: true, - }, + name: "completedAt", + type: "DateTime", + optional: true + } }, attributes: [ - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary(ExpressionUtils.call('auth'), '==', ExpressionUtils._null()), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('list'), ['ownerId']), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - }, - ], - }, - { - name: '@@allow', - args: [ - { name: 'operation', value: ExpressionUtils.literal('all') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.field('list'), ['space', 'members']), - '?', - ExpressionUtils.binary( - ExpressionUtils.field('userId'), - '==', - ExpressionUtils.member(ExpressionUtils.call('auth'), ['id']), - ), - ), - '&&', - ExpressionUtils.unary( - '!', - ExpressionUtils.member(ExpressionUtils.field('list'), ['private']), - ), - ), - }, - ], - }, - { - name: '@@deny', - args: [ - { name: 'operation', value: ExpressionUtils.literal('post-update') }, - { - name: 'condition', - value: ExpressionUtils.binary( - ExpressionUtils.member(ExpressionUtils.call('before'), ['ownerId']), - '!=', - ExpressionUtils.field('ownerId'), - ), - }, - ], - }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("list"), ["ownerId"]), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.field("list"), ["space", "members"]), "?", ExpressionUtils.binary(ExpressionUtils.field("userId"), "==", ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]))), "&&", ExpressionUtils.unary("!", ExpressionUtils.member(ExpressionUtils.field("list"), ["private"]))) }] }, + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("post-update") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("before"), ["ownerId"]), "!=", ExpressionUtils.field("ownerId")) }] } ], - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'String' }, - }, - }, + id: { type: "String" } + } + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema; diff --git a/tests/e2e/orm/schemas/typing/input.ts b/tests/e2e/orm/schemas/typing/input.ts index c7de2e40..13d7d458 100644 --- a/tests/e2e/orm/schemas/typing/input.ts +++ b/tests/e2e/orm/schemas/typing/input.ts @@ -5,173 +5,126 @@ /* 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 { - 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> = $SimplifiedModelResult< - $Schema, - 'User', - 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> = $SimplifiedModelResult< - $Schema, - 'Post', - Args ->; -export type ProfileFindManyArgs = $FindManyArgs<$Schema, 'Profile'>; -export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, 'Profile'>; -export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, 'Profile'>; -export type ProfileCreateArgs = $CreateArgs<$Schema, 'Profile'>; -export type ProfileCreateManyArgs = $CreateManyArgs<$Schema, 'Profile'>; -export type ProfileCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Profile'>; -export type ProfileUpdateArgs = $UpdateArgs<$Schema, 'Profile'>; -export type ProfileUpdateManyArgs = $UpdateManyArgs<$Schema, 'Profile'>; -export type ProfileUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Profile'>; -export type ProfileUpsertArgs = $UpsertArgs<$Schema, 'Profile'>; -export type ProfileDeleteArgs = $DeleteArgs<$Schema, 'Profile'>; -export type ProfileDeleteManyArgs = $DeleteManyArgs<$Schema, 'Profile'>; -export type ProfileCountArgs = $CountArgs<$Schema, 'Profile'>; -export type ProfileAggregateArgs = $AggregateArgs<$Schema, 'Profile'>; -export type ProfileGroupByArgs = $GroupByArgs<$Schema, 'Profile'>; -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 TagFindManyArgs = $FindManyArgs<$Schema, 'Tag'>; -export type TagFindUniqueArgs = $FindUniqueArgs<$Schema, 'Tag'>; -export type TagFindFirstArgs = $FindFirstArgs<$Schema, 'Tag'>; -export type TagCreateArgs = $CreateArgs<$Schema, 'Tag'>; -export type TagCreateManyArgs = $CreateManyArgs<$Schema, 'Tag'>; -export type TagCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Tag'>; -export type TagUpdateArgs = $UpdateArgs<$Schema, 'Tag'>; -export type TagUpdateManyArgs = $UpdateManyArgs<$Schema, 'Tag'>; -export type TagUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Tag'>; -export type TagUpsertArgs = $UpsertArgs<$Schema, 'Tag'>; -export type TagDeleteArgs = $DeleteArgs<$Schema, 'Tag'>; -export type TagDeleteManyArgs = $DeleteManyArgs<$Schema, 'Tag'>; -export type TagCountArgs = $CountArgs<$Schema, 'Tag'>; -export type TagAggregateArgs = $AggregateArgs<$Schema, 'Tag'>; -export type TagGroupByArgs = $GroupByArgs<$Schema, 'Tag'>; -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 RegionFindManyArgs = $FindManyArgs<$Schema, 'Region'>; -export type RegionFindUniqueArgs = $FindUniqueArgs<$Schema, 'Region'>; -export type RegionFindFirstArgs = $FindFirstArgs<$Schema, 'Region'>; -export type RegionCreateArgs = $CreateArgs<$Schema, 'Region'>; -export type RegionCreateManyArgs = $CreateManyArgs<$Schema, 'Region'>; -export type RegionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Region'>; -export type RegionUpdateArgs = $UpdateArgs<$Schema, 'Region'>; -export type RegionUpdateManyArgs = $UpdateManyArgs<$Schema, 'Region'>; -export type RegionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Region'>; -export type RegionUpsertArgs = $UpsertArgs<$Schema, 'Region'>; -export type RegionDeleteArgs = $DeleteArgs<$Schema, 'Region'>; -export type RegionDeleteManyArgs = $DeleteManyArgs<$Schema, 'Region'>; -export type RegionCountArgs = $CountArgs<$Schema, 'Region'>; -export type RegionAggregateArgs = $AggregateArgs<$Schema, 'Region'>; -export type RegionGroupByArgs = $GroupByArgs<$Schema, 'Region'>; -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 MetaFindManyArgs = $FindManyArgs<$Schema, 'Meta'>; -export type MetaFindUniqueArgs = $FindUniqueArgs<$Schema, 'Meta'>; -export type MetaFindFirstArgs = $FindFirstArgs<$Schema, 'Meta'>; -export type MetaCreateArgs = $CreateArgs<$Schema, 'Meta'>; -export type MetaCreateManyArgs = $CreateManyArgs<$Schema, 'Meta'>; -export type MetaCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, 'Meta'>; -export type MetaUpdateArgs = $UpdateArgs<$Schema, 'Meta'>; -export type MetaUpdateManyArgs = $UpdateManyArgs<$Schema, 'Meta'>; -export type MetaUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, 'Meta'>; -export type MetaUpsertArgs = $UpsertArgs<$Schema, 'Meta'>; -export type MetaDeleteArgs = $DeleteArgs<$Schema, 'Meta'>; -export type MetaDeleteManyArgs = $DeleteManyArgs<$Schema, 'Meta'>; -export type MetaCountArgs = $CountArgs<$Schema, 'Meta'>; -export type MetaAggregateArgs = $AggregateArgs<$Schema, 'Meta'>; -export type MetaGroupByArgs = $GroupByArgs<$Schema, 'Meta'>; -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 ->; +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 { 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> = $SimplifiedModelResult<$Schema, "User", 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> = $SimplifiedModelResult<$Schema, "Post", Args>; +export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; +export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; +export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; +export type ProfileCreateArgs = $CreateArgs<$Schema, "Profile">; +export type ProfileCreateManyArgs = $CreateManyArgs<$Schema, "Profile">; +export type ProfileCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Profile">; +export type ProfileUpdateArgs = $UpdateArgs<$Schema, "Profile">; +export type ProfileUpdateManyArgs = $UpdateManyArgs<$Schema, "Profile">; +export type ProfileUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Profile">; +export type ProfileUpsertArgs = $UpsertArgs<$Schema, "Profile">; +export type ProfileDeleteArgs = $DeleteArgs<$Schema, "Profile">; +export type ProfileDeleteManyArgs = $DeleteManyArgs<$Schema, "Profile">; +export type ProfileCountArgs = $CountArgs<$Schema, "Profile">; +export type ProfileAggregateArgs = $AggregateArgs<$Schema, "Profile">; +export type ProfileGroupByArgs = $GroupByArgs<$Schema, "Profile">; +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 TagFindManyArgs = $FindManyArgs<$Schema, "Tag">; +export type TagFindUniqueArgs = $FindUniqueArgs<$Schema, "Tag">; +export type TagFindFirstArgs = $FindFirstArgs<$Schema, "Tag">; +export type TagCreateArgs = $CreateArgs<$Schema, "Tag">; +export type TagCreateManyArgs = $CreateManyArgs<$Schema, "Tag">; +export type TagCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Tag">; +export type TagUpdateArgs = $UpdateArgs<$Schema, "Tag">; +export type TagUpdateManyArgs = $UpdateManyArgs<$Schema, "Tag">; +export type TagUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Tag">; +export type TagUpsertArgs = $UpsertArgs<$Schema, "Tag">; +export type TagDeleteArgs = $DeleteArgs<$Schema, "Tag">; +export type TagDeleteManyArgs = $DeleteManyArgs<$Schema, "Tag">; +export type TagCountArgs = $CountArgs<$Schema, "Tag">; +export type TagAggregateArgs = $AggregateArgs<$Schema, "Tag">; +export type TagGroupByArgs = $GroupByArgs<$Schema, "Tag">; +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 RegionFindManyArgs = $FindManyArgs<$Schema, "Region">; +export type RegionFindUniqueArgs = $FindUniqueArgs<$Schema, "Region">; +export type RegionFindFirstArgs = $FindFirstArgs<$Schema, "Region">; +export type RegionCreateArgs = $CreateArgs<$Schema, "Region">; +export type RegionCreateManyArgs = $CreateManyArgs<$Schema, "Region">; +export type RegionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Region">; +export type RegionUpdateArgs = $UpdateArgs<$Schema, "Region">; +export type RegionUpdateManyArgs = $UpdateManyArgs<$Schema, "Region">; +export type RegionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Region">; +export type RegionUpsertArgs = $UpsertArgs<$Schema, "Region">; +export type RegionDeleteArgs = $DeleteArgs<$Schema, "Region">; +export type RegionDeleteManyArgs = $DeleteManyArgs<$Schema, "Region">; +export type RegionCountArgs = $CountArgs<$Schema, "Region">; +export type RegionAggregateArgs = $AggregateArgs<$Schema, "Region">; +export type RegionGroupByArgs = $GroupByArgs<$Schema, "Region">; +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 MetaFindManyArgs = $FindManyArgs<$Schema, "Meta">; +export type MetaFindUniqueArgs = $FindUniqueArgs<$Schema, "Meta">; +export type MetaFindFirstArgs = $FindFirstArgs<$Schema, "Meta">; +export type MetaCreateArgs = $CreateArgs<$Schema, "Meta">; +export type MetaCreateManyArgs = $CreateManyArgs<$Schema, "Meta">; +export type MetaCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Meta">; +export type MetaUpdateArgs = $UpdateArgs<$Schema, "Meta">; +export type MetaUpdateManyArgs = $UpdateManyArgs<$Schema, "Meta">; +export type MetaUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Meta">; +export type MetaUpsertArgs = $UpsertArgs<$Schema, "Meta">; +export type MetaDeleteArgs = $DeleteArgs<$Schema, "Meta">; +export type MetaDeleteManyArgs = $DeleteManyArgs<$Schema, "Meta">; +export type MetaCountArgs = $CountArgs<$Schema, "Meta">; +export type MetaAggregateArgs = $AggregateArgs<$Schema, "Meta">; +export type MetaGroupByArgs = $GroupByArgs<$Schema, "Meta">; +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>; diff --git a/tests/e2e/orm/schemas/typing/models.ts b/tests/e2e/orm/schemas/typing/models.ts index 06d9a3c9..b2fa673f 100644 --- a/tests/e2e/orm/schemas/typing/models.ts +++ b/tests/e2e/orm/schemas/typing/models.ts @@ -5,16 +5,16 @@ /* eslint-disable */ -import { schema as $schema, type SchemaType as $Schema } from './schema'; -import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from '@zenstackhq/orm'; -export type User = $ModelResult<$Schema, 'User'>; -export type Post = $ModelResult<$Schema, 'Post'>; -export type Profile = $ModelResult<$Schema, 'Profile'>; -export type Tag = $ModelResult<$Schema, 'Tag'>; -export type Region = $ModelResult<$Schema, 'Region'>; -export type Meta = $ModelResult<$Schema, 'Meta'>; -export type Identity = $TypeDefResult<$Schema, 'Identity'>; -export type IdentityProvider = $TypeDefResult<$Schema, 'IdentityProvider'>; +import { schema as $schema, type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Post = $ModelResult<$Schema, "Post">; +export type Profile = $ModelResult<$Schema, "Profile">; +export type Tag = $ModelResult<$Schema, "Tag">; +export type Region = $ModelResult<$Schema, "Region">; +export type Meta = $ModelResult<$Schema, "Meta">; +export type Identity = $TypeDefResult<$Schema, "Identity">; +export type IdentityProvider = $TypeDefResult<$Schema, "IdentityProvider">; export const Role = $schema.enums.Role; export type Role = (typeof Role)[keyof typeof Role]; export const Status = $schema.enums.Status; diff --git a/tests/e2e/orm/schemas/typing/schema.ts b/tests/e2e/orm/schemas/typing/schema.ts index ab27ac19..10c4daa7 100644 --- a/tests/e2e/orm/schemas/typing/schema.ts +++ b/tests/e2e/orm/schemas/typing/schema.ts @@ -5,403 +5,339 @@ /* eslint-disable */ -import { type SchemaDef, type OperandExpression, ExpressionUtils } from '@zenstackhq/orm/schema'; +import { type SchemaDef, type OperandExpression, ExpressionUtils } from "@zenstackhq/orm/schema"; export const schema = { provider: { - type: 'postgresql', + type: "postgresql" }, models: { User: { - name: 'User', + name: "User", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, createdAt: { - name: 'createdAt', - type: 'DateTime', - attributes: [{ name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('now') }] }], - default: ExpressionUtils.call('now'), + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") }, updatedAt: { - name: 'updatedAt', - type: 'DateTime', + name: "updatedAt", + type: "DateTime", updatedAt: true, - attributes: [{ name: '@updatedAt' }], + attributes: [{ name: "@updatedAt" }] }, name: { - name: 'name', - type: 'String', + name: "name", + type: "String" }, email: { - name: 'email', - type: 'String', + name: "email", + type: "String", unique: true, - attributes: [{ name: '@unique' }], + attributes: [{ name: "@unique" }] }, role: { - name: 'role', - type: 'Role', - attributes: [ - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.literal('USER') }] }, - ], - default: 'USER', + name: "role", + type: "Role", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }], + default: "USER" }, status: { - name: 'status', - type: 'Status', - array: true, + name: "status", + type: "Status", + array: true }, posts: { - name: 'posts', - type: 'Post', + name: "posts", + type: "Post", array: true, - relation: { opposite: 'author' }, + relation: { opposite: "author" } }, profile: { - name: 'profile', - type: 'Profile', + name: "profile", + type: "Profile", optional: true, - relation: { opposite: 'user' }, + relation: { opposite: "user" } }, postCount: { - name: 'postCount', - type: 'Int', - attributes: [{ name: '@computed' }], - computed: true, + name: "postCount", + type: "Int", + attributes: [{ name: "@computed" }], + computed: true }, identity: { - name: 'identity', - type: 'Identity', + name: "identity", + type: "Identity", optional: true, - attributes: [{ name: '@json' }], - }, + attributes: [{ name: "@json" }] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - email: { type: 'String' }, + id: { type: "Int" }, + email: { type: "String" } }, computedFields: { - postCount(_context: { modelAlias: string }): OperandExpression { - throw new Error('This is a stub for computed field'); - }, - }, + postCount(_context: { + modelAlias: string; + }): OperandExpression { + throw new Error("This is a stub for computed field"); + } + } }, Post: { - name: 'Post', + name: "Post", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, title: { - name: 'title', - type: 'String', + name: "title", + type: "String" }, content: { - name: 'content', - type: 'String', + name: "content", + 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')]) }, - ], - }, - ], - relation: { opposite: 'posts', fields: ['authorId'], references: ['id'] }, + name: "author", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "posts", fields: ["authorId"], references: ["id"] } }, authorId: { - name: 'authorId', - type: 'Int', - foreignKeyFor: ['author'], + name: "authorId", + type: "Int", + foreignKeyFor: [ + "author" + ] }, tags: { - name: 'tags', - type: 'Tag', + name: "tags", + type: "Tag", array: true, - relation: { opposite: 'posts' }, + relation: { opposite: "posts" } }, meta: { - name: 'meta', - type: 'Meta', + name: "meta", + type: "Meta", optional: true, - relation: { opposite: 'post' }, - }, + relation: { opposite: "post" } + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, + id: { type: "Int" } + } }, Profile: { - name: 'Profile', + name: "Profile", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, age: { - name: 'age', - type: 'Int', + name: "age", + type: "Int" }, region: { - name: 'region', - type: 'Region', + name: "region", + type: "Region", optional: true, - attributes: [ - { - name: '@relation', - args: [ - { - name: 'fields', - value: ExpressionUtils.array([ - ExpressionUtils.field('regionCountry'), - ExpressionUtils.field('regionCity'), - ]), - }, - { - name: 'references', - value: ExpressionUtils.array([ - ExpressionUtils.field('country'), - ExpressionUtils.field('city'), - ]), - }, - ], - }, - ], - relation: { - opposite: 'profiles', - fields: ['regionCountry', 'regionCity'], - references: ['country', 'city'], - }, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("regionCountry"), ExpressionUtils.field("regionCity")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("country"), ExpressionUtils.field("city")]) }] }], + relation: { opposite: "profiles", fields: ["regionCountry", "regionCity"], references: ["country", "city"] } }, regionCountry: { - name: 'regionCountry', - type: 'String', + name: "regionCountry", + type: "String", optional: true, - foreignKeyFor: ['region'], + foreignKeyFor: [ + "region" + ] }, regionCity: { - name: 'regionCity', - type: 'String', + name: "regionCity", + type: "String", optional: true, - foreignKeyFor: ['region'], + foreignKeyFor: [ + "region" + ] }, user: { - name: 'user', - type: 'User', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('userId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - ], - }, - ], - relation: { opposite: 'profile', fields: ['userId'], references: ['id'] }, + name: "user", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "profile", fields: ["userId"], references: ["id"] } }, userId: { - name: 'userId', - type: 'Int', + name: "userId", + type: "Int", unique: true, - attributes: [{ name: '@unique' }], - foreignKeyFor: ['user'], - }, + attributes: [{ name: "@unique" }], + foreignKeyFor: [ + "user" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - userId: { type: 'Int' }, - }, + id: { type: "Int" }, + userId: { type: "Int" } + } }, Tag: { - name: 'Tag', + name: "Tag", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, name: { - name: 'name', - type: 'String', + name: "name", + type: "String" }, posts: { - name: 'posts', - type: 'Post', + name: "posts", + type: "Post", array: true, - relation: { opposite: 'tags' }, - }, + relation: { opposite: "tags" } + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - }, + id: { type: "Int" } + } }, Region: { - name: 'Region', + name: "Region", fields: { country: { - name: 'country', - type: 'String', - id: true, + name: "country", + type: "String", + id: true }, city: { - name: 'city', - type: 'String', - id: true, + name: "city", + type: "String", + id: true }, zip: { - name: 'zip', - type: 'String', - optional: true, + name: "zip", + type: "String", + optional: true }, profiles: { - name: 'profiles', - type: 'Profile', + name: "profiles", + type: "Profile", array: true, - relation: { opposite: 'region' }, - }, + relation: { opposite: "region" } + } }, attributes: [ - { - name: '@@id', - args: [ - { - name: 'fields', - value: ExpressionUtils.array([ - ExpressionUtils.field('country'), - ExpressionUtils.field('city'), - ]), - }, - ], - }, + { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("country"), ExpressionUtils.field("city")]) }] } ], - idFields: ['country', 'city'], + idFields: ["country", "city"], uniqueFields: { - country_city: { country: { type: 'String' }, city: { type: 'String' } }, - }, + country_city: { country: { type: "String" }, city: { type: "String" } } + } }, Meta: { - name: 'Meta', + name: "Meta", fields: { id: { - name: 'id', - type: 'Int', + name: "id", + type: "Int", id: true, - attributes: [ - { name: '@id' }, - { name: '@default', args: [{ name: 'value', value: ExpressionUtils.call('autoincrement') }] }, - ], - default: ExpressionUtils.call('autoincrement'), + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") }, reviewed: { - name: 'reviewed', - type: 'Boolean', + name: "reviewed", + type: "Boolean" }, published: { - name: 'published', - type: 'Boolean', + name: "published", + type: "Boolean" }, post: { - name: 'post', - type: 'Post', - attributes: [ - { - name: '@relation', - args: [ - { name: 'fields', value: ExpressionUtils.array([ExpressionUtils.field('postId')]) }, - { name: 'references', value: ExpressionUtils.array([ExpressionUtils.field('id')]) }, - ], - }, - ], - relation: { opposite: 'meta', fields: ['postId'], references: ['id'] }, + name: "post", + type: "Post", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("postId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "meta", fields: ["postId"], references: ["id"] } }, postId: { - name: 'postId', - type: 'Int', + name: "postId", + type: "Int", unique: true, - attributes: [{ name: '@unique' }], - foreignKeyFor: ['post'], - }, + attributes: [{ name: "@unique" }], + foreignKeyFor: [ + "post" + ] + } }, - idFields: ['id'], + idFields: ["id"], uniqueFields: { - id: { type: 'Int' }, - postId: { type: 'Int' }, - }, - }, + id: { type: "Int" }, + postId: { type: "Int" } + } + } }, typeDefs: { Identity: { - name: 'Identity', + name: "Identity", fields: { providers: { - name: 'providers', - type: 'IdentityProvider', - array: true, - }, - }, + name: "providers", + type: "IdentityProvider", + array: true + } + } }, IdentityProvider: { - name: 'IdentityProvider', + name: "IdentityProvider", fields: { id: { - name: 'id', - type: 'String', + name: "id", + type: "String" }, name: { - name: 'name', - type: 'String', - optional: true, - }, - }, - }, + name: "name", + type: "String", + optional: true + } + } + } }, enums: { Role: { - ADMIN: 'ADMIN', - USER: 'USER', + ADMIN: "ADMIN", + USER: "USER" }, Status: { - ACTIVE: 'ACTIVE', - INACTIVE: 'INACTIVE', - BANNED: 'BANNED', - }, + ACTIVE: "ACTIVE", + INACTIVE: "INACTIVE", + BANNED: "BANNED" + } }, - authType: 'User', - plugins: {}, + authType: "User", + plugins: {} } as const satisfies SchemaDef; export type SchemaType = typeof schema;