diff --git a/packages/orm/src/client/executor/name-mapper.ts b/packages/orm/src/client/executor/name-mapper.ts index 2ad522f5..68a10490 100644 --- a/packages/orm/src/client/executor/name-mapper.ts +++ b/packages/orm/src/client/executor/name-mapper.ts @@ -77,8 +77,11 @@ export class QueryNameMapper extends OperationNodeTransformer { // process "from" clauses const processedFroms = node.from.froms.map((from) => this.processSelectTable(from)); - // process "join" clauses - const processedJoins = (node.joins ?? []).map((join) => this.processSelectTable(join.table)); + // process "join" clauses, note that "from" needs to be added as scopes since join conditions + // can refer to "from" tables + const processedJoins = this.withScopes([...processedFroms.map(({ scope }) => scope)], () => + (node.joins ?? []).map((join) => this.processSelectTable(join.table)), + ); // merge the scopes of froms and joins since they're all visible in the query body const scopes = [...processedFroms.map(({ scope }) => scope), ...processedJoins.map(({ scope }) => scope)]; diff --git a/packages/sdk/src/prisma/prisma-schema-generator.ts b/packages/sdk/src/prisma/prisma-schema-generator.ts index 45ffed3c..2d31ba4a 100644 --- a/packages/sdk/src/prisma/prisma-schema-generator.ts +++ b/packages/sdk/src/prisma/prisma-schema-generator.ts @@ -20,6 +20,7 @@ import { isArrayExpr, isDataModel, isDataSource, + isGeneratorDecl, isInvocationExpr, isLiteralExpr, isNullExpr, @@ -106,6 +107,10 @@ export class PrismaSchemaGenerator { } } + if (!this.zmodel.declarations.some(isGeneratorDecl)) { + this.generateDefaultGenerator(prisma); + } + return this.PRELUDE + prisma.toString(); } @@ -169,6 +174,15 @@ export class PrismaSchemaGenerator { ); } + private generateDefaultGenerator(prisma: PrismaModel) { + const gen = prisma.addGenerator('client', [{ name: 'provider', text: '"prisma-client-js"' }]); + const dataSource = this.zmodel.declarations.find(isDataSource); + if (dataSource?.fields.some((f) => f.name === 'extensions')) { + // enable "postgresqlExtensions" preview feature + gen.fields.push({ name: 'previewFeatures', text: '["postgresqlExtensions"]' }); + } + } + private generateModel(prisma: PrismaModel, decl: DataModel) { const model = decl.isView ? prisma.addView(decl.name) : prisma.addModel(decl.name); const allFields = getAllFields(decl, true); diff --git a/packages/testtools/src/client.ts b/packages/testtools/src/client.ts index 569a67ab..b00c38ae 100644 --- a/packages/testtools/src/client.ts +++ b/packages/testtools/src/client.ts @@ -5,6 +5,7 @@ import type { SchemaDef } from '@zenstackhq/orm/schema'; import { PolicyPlugin } from '@zenstackhq/plugin-policy'; import { PrismaSchemaGenerator } from '@zenstackhq/sdk'; import SQLite from 'better-sqlite3'; +import { glob } from 'glob'; import { PostgresDialect, SqliteDialect, type LogEvent } from 'kysely'; import { execSync } from 'node:child_process'; import { createHash } from 'node:crypto'; @@ -32,14 +33,55 @@ const TEST_PG_CONFIG = { }; export type CreateTestClientOptions = Omit, 'dialect'> & { + /** + * Database provider + */ provider?: 'sqlite' | 'postgresql'; + + /** + * The main ZModel file. Only used when `usePrismaPush` is true and `schema` is an object. + */ schemaFile?: string; + + /** + * Database name. If not provided, a name will be generated based on the test name. + */ dbName?: string; + + /** + * Use `prisma db push` instead of ZenStack's `$pushSchema` for database initialization. + */ usePrismaPush?: boolean; + + /** + * Extra source files to create and compile. + */ extraSourceFiles?: Record; + + /** + * Working directory for the test client. If not provided, a temporary directory will be created. + */ workDir?: string; + + /** + * Debug mode. + */ debug?: boolean; + + /** + * A sqlite database file to be used for the test. Only supported for sqlite provider. + */ dbFile?: string; + + /** + * PostgreSQL extensions to be added to the datasource. Only supported for postgresql provider. + */ + dataSourceExtensions?: string[]; + + /** + * Additional files to be copied to the working directory. The glob pattern is relative to the test file. + */ + copyFiles?: { globPattern: string; destination: string }[]; }; export async function createTestClient( @@ -95,16 +137,24 @@ export async function createTestClient( `datasource db { provider = '${provider}' url = '${dbUrl}' + ${options.dataSourceExtensions ? `extensions = [${options.dataSourceExtensions.join(', ')}]` : ''} }`, ); } - fs.writeFileSync(path.join(workDir, 'schema.zmodel'), schemaContent); + fs.writeFileSync(path.join(workDir!, 'schema.zmodel'), schemaContent); } } invariant(workDir); + + const { plugins, ...rest } = options ?? {}; + const _options: ClientOptions = { + ...rest, + } as ClientOptions; + if (options?.debug) { console.log(`Work directory: ${workDir}`); + _options.log = testLogger; } // copy db file to workDir if specified @@ -115,10 +165,23 @@ export async function createTestClient( fs.copyFileSync(options.dbFile, path.join(workDir, dbName)); } - const { plugins, ...rest } = options ?? {}; - const _options: ClientOptions = { - ...rest, - } as ClientOptions; + // copy additional files if specified + if (options?.copyFiles) { + const state = expect.getState(); + const currentTestPath = state.testPath; + if (!currentTestPath) { + throw new Error('Unable to determine current test file path'); + } + for (const { globPattern, destination } of options.copyFiles) { + const files = glob.sync(globPattern, { cwd: path.dirname(currentTestPath) }); + for (const file of files) { + const src = path.resolve(path.dirname(currentTestPath), file); + const dest = path.resolve(workDir, destination, path.basename(file)); + fs.mkdirSync(path.dirname(dest), { recursive: true }); + fs.copyFileSync(src, dest); + } + } + } if (!options?.dbFile) { if (options?.usePrismaPush) { diff --git a/tests/e2e/apps/rally/rally.test.ts b/tests/e2e/apps/rally/rally.test.ts new file mode 100644 index 00000000..e14b8798 --- /dev/null +++ b/tests/e2e/apps/rally/rally.test.ts @@ -0,0 +1,49 @@ +import type { ClientContract } from '@zenstackhq/orm'; +import { createTestClient } from '@zenstackhq/testtools'; +import path from 'path'; +import { beforeEach, describe, expect, it } from 'vitest'; +import { schema, type SchemaType } from './zenstack/schema'; + +describe('Rally app tests', () => { + let db: ClientContract; + + beforeEach(async () => { + db = await createTestClient(schema, { + provider: 'postgresql', + schemaFile: path.join(__dirname, 'zenstack/schema.zmodel'), + copyFiles: [ + { + globPattern: 'zenstack/models/*', + destination: 'models', + }, + ], + debug: true, + dataSourceExtensions: ['citext'], + usePrismaPush: true, + }); + }); + + it('works with queries', async () => { + await expect( + db.spaceMember.findMany({ + where: { + userId: '1', + }, + orderBy: { + lastSelectedAt: 'desc', + }, + include: { + space: { + select: { + id: true, + ownerId: true, + name: true, + tier: true, + image: true, + }, + }, + }, + }), + ).toResolveTruthy(); + }); +}); diff --git a/tests/e2e/apps/rally/zenstack/input.ts b/tests/e2e/apps/rally/zenstack/input.ts new file mode 100644 index 00000000..65715c19 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/input.ts @@ -0,0 +1,550 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; +export type AccountFindManyArgs = $FindManyArgs<$Schema, "Account">; +export type AccountFindUniqueArgs = $FindUniqueArgs<$Schema, "Account">; +export type AccountFindFirstArgs = $FindFirstArgs<$Schema, "Account">; +export type AccountCreateArgs = $CreateArgs<$Schema, "Account">; +export type AccountCreateManyArgs = $CreateManyArgs<$Schema, "Account">; +export type AccountCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Account">; +export type AccountUpdateArgs = $UpdateArgs<$Schema, "Account">; +export type AccountUpdateManyArgs = $UpdateManyArgs<$Schema, "Account">; +export type AccountUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Account">; +export type AccountUpsertArgs = $UpsertArgs<$Schema, "Account">; +export type AccountDeleteArgs = $DeleteArgs<$Schema, "Account">; +export type AccountDeleteManyArgs = $DeleteManyArgs<$Schema, "Account">; +export type AccountCountArgs = $CountArgs<$Schema, "Account">; +export type AccountAggregateArgs = $AggregateArgs<$Schema, "Account">; +export type AccountGroupByArgs = $GroupByArgs<$Schema, "Account">; +export type AccountWhereInput = $WhereInput<$Schema, "Account">; +export type AccountSelect = $SelectInput<$Schema, "Account">; +export type AccountInclude = $IncludeInput<$Schema, "Account">; +export type AccountOmit = $OmitInput<$Schema, "Account">; +export type AccountGetPayload> = $SimplifiedModelResult<$Schema, "Account", Args>; +export type 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 VerificationTokenFindManyArgs = $FindManyArgs<$Schema, "VerificationToken">; +export type VerificationTokenFindUniqueArgs = $FindUniqueArgs<$Schema, "VerificationToken">; +export type VerificationTokenFindFirstArgs = $FindFirstArgs<$Schema, "VerificationToken">; +export type VerificationTokenCreateArgs = $CreateArgs<$Schema, "VerificationToken">; +export type VerificationTokenCreateManyArgs = $CreateManyArgs<$Schema, "VerificationToken">; +export type VerificationTokenCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "VerificationToken">; +export type VerificationTokenUpdateArgs = $UpdateArgs<$Schema, "VerificationToken">; +export type VerificationTokenUpdateManyArgs = $UpdateManyArgs<$Schema, "VerificationToken">; +export type VerificationTokenUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "VerificationToken">; +export type VerificationTokenUpsertArgs = $UpsertArgs<$Schema, "VerificationToken">; +export type VerificationTokenDeleteArgs = $DeleteArgs<$Schema, "VerificationToken">; +export type VerificationTokenDeleteManyArgs = $DeleteManyArgs<$Schema, "VerificationToken">; +export type VerificationTokenCountArgs = $CountArgs<$Schema, "VerificationToken">; +export type VerificationTokenAggregateArgs = $AggregateArgs<$Schema, "VerificationToken">; +export type VerificationTokenGroupByArgs = $GroupByArgs<$Schema, "VerificationToken">; +export type VerificationTokenWhereInput = $WhereInput<$Schema, "VerificationToken">; +export type VerificationTokenSelect = $SelectInput<$Schema, "VerificationToken">; +export type VerificationTokenInclude = $IncludeInput<$Schema, "VerificationToken">; +export type VerificationTokenOmit = $OmitInput<$Schema, "VerificationToken">; +export type VerificationTokenGetPayload> = $SimplifiedModelResult<$Schema, "VerificationToken", Args>; +export type SessionFindManyArgs = $FindManyArgs<$Schema, "Session">; +export type SessionFindUniqueArgs = $FindUniqueArgs<$Schema, "Session">; +export type SessionFindFirstArgs = $FindFirstArgs<$Schema, "Session">; +export type SessionCreateArgs = $CreateArgs<$Schema, "Session">; +export type SessionCreateManyArgs = $CreateManyArgs<$Schema, "Session">; +export type SessionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Session">; +export type SessionUpdateArgs = $UpdateArgs<$Schema, "Session">; +export type SessionUpdateManyArgs = $UpdateManyArgs<$Schema, "Session">; +export type SessionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Session">; +export type SessionUpsertArgs = $UpsertArgs<$Schema, "Session">; +export type SessionDeleteArgs = $DeleteArgs<$Schema, "Session">; +export type SessionDeleteManyArgs = $DeleteManyArgs<$Schema, "Session">; +export type SessionCountArgs = $CountArgs<$Schema, "Session">; +export type SessionAggregateArgs = $AggregateArgs<$Schema, "Session">; +export type SessionGroupByArgs = $GroupByArgs<$Schema, "Session">; +export type SessionWhereInput = $WhereInput<$Schema, "Session">; +export type SessionSelect = $SelectInput<$Schema, "Session">; +export type SessionInclude = $IncludeInput<$Schema, "Session">; +export type SessionOmit = $OmitInput<$Schema, "Session">; +export type SessionGetPayload> = $SimplifiedModelResult<$Schema, "Session", Args>; +export type VerificationFindManyArgs = $FindManyArgs<$Schema, "Verification">; +export type VerificationFindUniqueArgs = $FindUniqueArgs<$Schema, "Verification">; +export type VerificationFindFirstArgs = $FindFirstArgs<$Schema, "Verification">; +export type VerificationCreateArgs = $CreateArgs<$Schema, "Verification">; +export type VerificationCreateManyArgs = $CreateManyArgs<$Schema, "Verification">; +export type VerificationCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Verification">; +export type VerificationUpdateArgs = $UpdateArgs<$Schema, "Verification">; +export type VerificationUpdateManyArgs = $UpdateManyArgs<$Schema, "Verification">; +export type VerificationUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Verification">; +export type VerificationUpsertArgs = $UpsertArgs<$Schema, "Verification">; +export type VerificationDeleteArgs = $DeleteArgs<$Schema, "Verification">; +export type VerificationDeleteManyArgs = $DeleteManyArgs<$Schema, "Verification">; +export type VerificationCountArgs = $CountArgs<$Schema, "Verification">; +export type VerificationAggregateArgs = $AggregateArgs<$Schema, "Verification">; +export type VerificationGroupByArgs = $GroupByArgs<$Schema, "Verification">; +export type VerificationWhereInput = $WhereInput<$Schema, "Verification">; +export type VerificationSelect = $SelectInput<$Schema, "Verification">; +export type VerificationInclude = $IncludeInput<$Schema, "Verification">; +export type VerificationOmit = $OmitInput<$Schema, "Verification">; +export type VerificationGetPayload> = $SimplifiedModelResult<$Schema, "Verification", Args>; +export type PollFindManyArgs = $FindManyArgs<$Schema, "Poll">; +export type PollFindUniqueArgs = $FindUniqueArgs<$Schema, "Poll">; +export type PollFindFirstArgs = $FindFirstArgs<$Schema, "Poll">; +export type PollCreateArgs = $CreateArgs<$Schema, "Poll">; +export type PollCreateManyArgs = $CreateManyArgs<$Schema, "Poll">; +export type PollCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Poll">; +export type PollUpdateArgs = $UpdateArgs<$Schema, "Poll">; +export type PollUpdateManyArgs = $UpdateManyArgs<$Schema, "Poll">; +export type PollUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Poll">; +export type PollUpsertArgs = $UpsertArgs<$Schema, "Poll">; +export type PollDeleteArgs = $DeleteArgs<$Schema, "Poll">; +export type PollDeleteManyArgs = $DeleteManyArgs<$Schema, "Poll">; +export type PollCountArgs = $CountArgs<$Schema, "Poll">; +export type PollAggregateArgs = $AggregateArgs<$Schema, "Poll">; +export type PollGroupByArgs = $GroupByArgs<$Schema, "Poll">; +export type PollWhereInput = $WhereInput<$Schema, "Poll">; +export type PollSelect = $SelectInput<$Schema, "Poll">; +export type PollInclude = $IncludeInput<$Schema, "Poll">; +export type PollOmit = $OmitInput<$Schema, "Poll">; +export type PollGetPayload> = $SimplifiedModelResult<$Schema, "Poll", Args>; +export type WatcherFindManyArgs = $FindManyArgs<$Schema, "Watcher">; +export type WatcherFindUniqueArgs = $FindUniqueArgs<$Schema, "Watcher">; +export type WatcherFindFirstArgs = $FindFirstArgs<$Schema, "Watcher">; +export type WatcherCreateArgs = $CreateArgs<$Schema, "Watcher">; +export type WatcherCreateManyArgs = $CreateManyArgs<$Schema, "Watcher">; +export type WatcherCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Watcher">; +export type WatcherUpdateArgs = $UpdateArgs<$Schema, "Watcher">; +export type WatcherUpdateManyArgs = $UpdateManyArgs<$Schema, "Watcher">; +export type WatcherUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Watcher">; +export type WatcherUpsertArgs = $UpsertArgs<$Schema, "Watcher">; +export type WatcherDeleteArgs = $DeleteArgs<$Schema, "Watcher">; +export type WatcherDeleteManyArgs = $DeleteManyArgs<$Schema, "Watcher">; +export type WatcherCountArgs = $CountArgs<$Schema, "Watcher">; +export type WatcherAggregateArgs = $AggregateArgs<$Schema, "Watcher">; +export type WatcherGroupByArgs = $GroupByArgs<$Schema, "Watcher">; +export type WatcherWhereInput = $WhereInput<$Schema, "Watcher">; +export type WatcherSelect = $SelectInput<$Schema, "Watcher">; +export type WatcherInclude = $IncludeInput<$Schema, "Watcher">; +export type WatcherOmit = $OmitInput<$Schema, "Watcher">; +export type WatcherGetPayload> = $SimplifiedModelResult<$Schema, "Watcher", Args>; +export type ParticipantFindManyArgs = $FindManyArgs<$Schema, "Participant">; +export type ParticipantFindUniqueArgs = $FindUniqueArgs<$Schema, "Participant">; +export type ParticipantFindFirstArgs = $FindFirstArgs<$Schema, "Participant">; +export type ParticipantCreateArgs = $CreateArgs<$Schema, "Participant">; +export type ParticipantCreateManyArgs = $CreateManyArgs<$Schema, "Participant">; +export type ParticipantCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Participant">; +export type ParticipantUpdateArgs = $UpdateArgs<$Schema, "Participant">; +export type ParticipantUpdateManyArgs = $UpdateManyArgs<$Schema, "Participant">; +export type ParticipantUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Participant">; +export type ParticipantUpsertArgs = $UpsertArgs<$Schema, "Participant">; +export type ParticipantDeleteArgs = $DeleteArgs<$Schema, "Participant">; +export type ParticipantDeleteManyArgs = $DeleteManyArgs<$Schema, "Participant">; +export type ParticipantCountArgs = $CountArgs<$Schema, "Participant">; +export type ParticipantAggregateArgs = $AggregateArgs<$Schema, "Participant">; +export type ParticipantGroupByArgs = $GroupByArgs<$Schema, "Participant">; +export type ParticipantWhereInput = $WhereInput<$Schema, "Participant">; +export type ParticipantSelect = $SelectInput<$Schema, "Participant">; +export type ParticipantInclude = $IncludeInput<$Schema, "Participant">; +export type ParticipantOmit = $OmitInput<$Schema, "Participant">; +export type ParticipantGetPayload> = $SimplifiedModelResult<$Schema, "Participant", Args>; +export type OptionFindManyArgs = $FindManyArgs<$Schema, "Option">; +export type OptionFindUniqueArgs = $FindUniqueArgs<$Schema, "Option">; +export type OptionFindFirstArgs = $FindFirstArgs<$Schema, "Option">; +export type OptionCreateArgs = $CreateArgs<$Schema, "Option">; +export type OptionCreateManyArgs = $CreateManyArgs<$Schema, "Option">; +export type OptionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Option">; +export type OptionUpdateArgs = $UpdateArgs<$Schema, "Option">; +export type OptionUpdateManyArgs = $UpdateManyArgs<$Schema, "Option">; +export type OptionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Option">; +export type OptionUpsertArgs = $UpsertArgs<$Schema, "Option">; +export type OptionDeleteArgs = $DeleteArgs<$Schema, "Option">; +export type OptionDeleteManyArgs = $DeleteManyArgs<$Schema, "Option">; +export type OptionCountArgs = $CountArgs<$Schema, "Option">; +export type OptionAggregateArgs = $AggregateArgs<$Schema, "Option">; +export type OptionGroupByArgs = $GroupByArgs<$Schema, "Option">; +export type OptionWhereInput = $WhereInput<$Schema, "Option">; +export type OptionSelect = $SelectInput<$Schema, "Option">; +export type OptionInclude = $IncludeInput<$Schema, "Option">; +export type OptionOmit = $OmitInput<$Schema, "Option">; +export type OptionGetPayload> = $SimplifiedModelResult<$Schema, "Option", Args>; +export type VoteFindManyArgs = $FindManyArgs<$Schema, "Vote">; +export type VoteFindUniqueArgs = $FindUniqueArgs<$Schema, "Vote">; +export type VoteFindFirstArgs = $FindFirstArgs<$Schema, "Vote">; +export type VoteCreateArgs = $CreateArgs<$Schema, "Vote">; +export type VoteCreateManyArgs = $CreateManyArgs<$Schema, "Vote">; +export type VoteCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Vote">; +export type VoteUpdateArgs = $UpdateArgs<$Schema, "Vote">; +export type VoteUpdateManyArgs = $UpdateManyArgs<$Schema, "Vote">; +export type VoteUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Vote">; +export type VoteUpsertArgs = $UpsertArgs<$Schema, "Vote">; +export type VoteDeleteArgs = $DeleteArgs<$Schema, "Vote">; +export type VoteDeleteManyArgs = $DeleteManyArgs<$Schema, "Vote">; +export type VoteCountArgs = $CountArgs<$Schema, "Vote">; +export type VoteAggregateArgs = $AggregateArgs<$Schema, "Vote">; +export type VoteGroupByArgs = $GroupByArgs<$Schema, "Vote">; +export type VoteWhereInput = $WhereInput<$Schema, "Vote">; +export type VoteSelect = $SelectInput<$Schema, "Vote">; +export type VoteInclude = $IncludeInput<$Schema, "Vote">; +export type VoteOmit = $OmitInput<$Schema, "Vote">; +export type VoteGetPayload> = $SimplifiedModelResult<$Schema, "Vote", Args>; +export type 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 PollViewFindManyArgs = $FindManyArgs<$Schema, "PollView">; +export type PollViewFindUniqueArgs = $FindUniqueArgs<$Schema, "PollView">; +export type PollViewFindFirstArgs = $FindFirstArgs<$Schema, "PollView">; +export type PollViewCreateArgs = $CreateArgs<$Schema, "PollView">; +export type PollViewCreateManyArgs = $CreateManyArgs<$Schema, "PollView">; +export type PollViewCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "PollView">; +export type PollViewUpdateArgs = $UpdateArgs<$Schema, "PollView">; +export type PollViewUpdateManyArgs = $UpdateManyArgs<$Schema, "PollView">; +export type PollViewUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "PollView">; +export type PollViewUpsertArgs = $UpsertArgs<$Schema, "PollView">; +export type PollViewDeleteArgs = $DeleteArgs<$Schema, "PollView">; +export type PollViewDeleteManyArgs = $DeleteManyArgs<$Schema, "PollView">; +export type PollViewCountArgs = $CountArgs<$Schema, "PollView">; +export type PollViewAggregateArgs = $AggregateArgs<$Schema, "PollView">; +export type PollViewGroupByArgs = $GroupByArgs<$Schema, "PollView">; +export type PollViewWhereInput = $WhereInput<$Schema, "PollView">; +export type PollViewSelect = $SelectInput<$Schema, "PollView">; +export type PollViewInclude = $IncludeInput<$Schema, "PollView">; +export type PollViewOmit = $OmitInput<$Schema, "PollView">; +export type PollViewGetPayload> = $SimplifiedModelResult<$Schema, "PollView", Args>; +export type 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 SpaceMemberFindManyArgs = $FindManyArgs<$Schema, "SpaceMember">; +export type SpaceMemberFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceMember">; +export type SpaceMemberFindFirstArgs = $FindFirstArgs<$Schema, "SpaceMember">; +export type SpaceMemberCreateArgs = $CreateArgs<$Schema, "SpaceMember">; +export type SpaceMemberCreateManyArgs = $CreateManyArgs<$Schema, "SpaceMember">; +export type SpaceMemberCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "SpaceMember">; +export type SpaceMemberUpdateArgs = $UpdateArgs<$Schema, "SpaceMember">; +export type SpaceMemberUpdateManyArgs = $UpdateManyArgs<$Schema, "SpaceMember">; +export type SpaceMemberUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "SpaceMember">; +export type SpaceMemberUpsertArgs = $UpsertArgs<$Schema, "SpaceMember">; +export type SpaceMemberDeleteArgs = $DeleteArgs<$Schema, "SpaceMember">; +export type SpaceMemberDeleteManyArgs = $DeleteManyArgs<$Schema, "SpaceMember">; +export type SpaceMemberCountArgs = $CountArgs<$Schema, "SpaceMember">; +export type SpaceMemberAggregateArgs = $AggregateArgs<$Schema, "SpaceMember">; +export type SpaceMemberGroupByArgs = $GroupByArgs<$Schema, "SpaceMember">; +export type SpaceMemberWhereInput = $WhereInput<$Schema, "SpaceMember">; +export type SpaceMemberSelect = $SelectInput<$Schema, "SpaceMember">; +export type SpaceMemberInclude = $IncludeInput<$Schema, "SpaceMember">; +export type SpaceMemberOmit = $OmitInput<$Schema, "SpaceMember">; +export type SpaceMemberGetPayload> = $SimplifiedModelResult<$Schema, "SpaceMember", Args>; +export type SpaceMemberInviteFindManyArgs = $FindManyArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteFindUniqueArgs = $FindUniqueArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteFindFirstArgs = $FindFirstArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteCreateArgs = $CreateArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteCreateManyArgs = $CreateManyArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteUpdateArgs = $UpdateArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteUpdateManyArgs = $UpdateManyArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteUpsertArgs = $UpsertArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteDeleteArgs = $DeleteArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteDeleteManyArgs = $DeleteManyArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteCountArgs = $CountArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteAggregateArgs = $AggregateArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteGroupByArgs = $GroupByArgs<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteWhereInput = $WhereInput<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteSelect = $SelectInput<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteInclude = $IncludeInput<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteOmit = $OmitInput<$Schema, "SpaceMemberInvite">; +export type SpaceMemberInviteGetPayload> = $SimplifiedModelResult<$Schema, "SpaceMemberInvite", Args>; +export type SubscriptionFindManyArgs = $FindManyArgs<$Schema, "Subscription">; +export type SubscriptionFindUniqueArgs = $FindUniqueArgs<$Schema, "Subscription">; +export type SubscriptionFindFirstArgs = $FindFirstArgs<$Schema, "Subscription">; +export type SubscriptionCreateArgs = $CreateArgs<$Schema, "Subscription">; +export type SubscriptionCreateManyArgs = $CreateManyArgs<$Schema, "Subscription">; +export type SubscriptionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Subscription">; +export type SubscriptionUpdateArgs = $UpdateArgs<$Schema, "Subscription">; +export type SubscriptionUpdateManyArgs = $UpdateManyArgs<$Schema, "Subscription">; +export type SubscriptionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Subscription">; +export type SubscriptionUpsertArgs = $UpsertArgs<$Schema, "Subscription">; +export type SubscriptionDeleteArgs = $DeleteArgs<$Schema, "Subscription">; +export type SubscriptionDeleteManyArgs = $DeleteManyArgs<$Schema, "Subscription">; +export type SubscriptionCountArgs = $CountArgs<$Schema, "Subscription">; +export type SubscriptionAggregateArgs = $AggregateArgs<$Schema, "Subscription">; +export type SubscriptionGroupByArgs = $GroupByArgs<$Schema, "Subscription">; +export type SubscriptionWhereInput = $WhereInput<$Schema, "Subscription">; +export type SubscriptionSelect = $SelectInput<$Schema, "Subscription">; +export type SubscriptionInclude = $IncludeInput<$Schema, "Subscription">; +export type SubscriptionOmit = $OmitInput<$Schema, "Subscription">; +export type SubscriptionGetPayload> = $SimplifiedModelResult<$Schema, "Subscription", Args>; +export type PaymentMethodFindManyArgs = $FindManyArgs<$Schema, "PaymentMethod">; +export type PaymentMethodFindUniqueArgs = $FindUniqueArgs<$Schema, "PaymentMethod">; +export type PaymentMethodFindFirstArgs = $FindFirstArgs<$Schema, "PaymentMethod">; +export type PaymentMethodCreateArgs = $CreateArgs<$Schema, "PaymentMethod">; +export type PaymentMethodCreateManyArgs = $CreateManyArgs<$Schema, "PaymentMethod">; +export type PaymentMethodCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "PaymentMethod">; +export type PaymentMethodUpdateArgs = $UpdateArgs<$Schema, "PaymentMethod">; +export type PaymentMethodUpdateManyArgs = $UpdateManyArgs<$Schema, "PaymentMethod">; +export type PaymentMethodUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "PaymentMethod">; +export type PaymentMethodUpsertArgs = $UpsertArgs<$Schema, "PaymentMethod">; +export type PaymentMethodDeleteArgs = $DeleteArgs<$Schema, "PaymentMethod">; +export type PaymentMethodDeleteManyArgs = $DeleteManyArgs<$Schema, "PaymentMethod">; +export type PaymentMethodCountArgs = $CountArgs<$Schema, "PaymentMethod">; +export type PaymentMethodAggregateArgs = $AggregateArgs<$Schema, "PaymentMethod">; +export type PaymentMethodGroupByArgs = $GroupByArgs<$Schema, "PaymentMethod">; +export type PaymentMethodWhereInput = $WhereInput<$Schema, "PaymentMethod">; +export type PaymentMethodSelect = $SelectInput<$Schema, "PaymentMethod">; +export type PaymentMethodInclude = $IncludeInput<$Schema, "PaymentMethod">; +export type PaymentMethodOmit = $OmitInput<$Schema, "PaymentMethod">; +export type PaymentMethodGetPayload> = $SimplifiedModelResult<$Schema, "PaymentMethod", Args>; +export type ScheduledEventFindManyArgs = $FindManyArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventFindUniqueArgs = $FindUniqueArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventFindFirstArgs = $FindFirstArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventCreateArgs = $CreateArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventCreateManyArgs = $CreateManyArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventUpdateArgs = $UpdateArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventUpdateManyArgs = $UpdateManyArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventUpsertArgs = $UpsertArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventDeleteArgs = $DeleteArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventDeleteManyArgs = $DeleteManyArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventCountArgs = $CountArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventAggregateArgs = $AggregateArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventGroupByArgs = $GroupByArgs<$Schema, "ScheduledEvent">; +export type ScheduledEventWhereInput = $WhereInput<$Schema, "ScheduledEvent">; +export type ScheduledEventSelect = $SelectInput<$Schema, "ScheduledEvent">; +export type ScheduledEventInclude = $IncludeInput<$Schema, "ScheduledEvent">; +export type ScheduledEventOmit = $OmitInput<$Schema, "ScheduledEvent">; +export type ScheduledEventGetPayload> = $SimplifiedModelResult<$Schema, "ScheduledEvent", Args>; +export type RescheduledEventDateFindManyArgs = $FindManyArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateFindUniqueArgs = $FindUniqueArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateFindFirstArgs = $FindFirstArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateCreateArgs = $CreateArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateCreateManyArgs = $CreateManyArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateUpdateArgs = $UpdateArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateUpdateManyArgs = $UpdateManyArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateUpsertArgs = $UpsertArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateDeleteArgs = $DeleteArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateDeleteManyArgs = $DeleteManyArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateCountArgs = $CountArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateAggregateArgs = $AggregateArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateGroupByArgs = $GroupByArgs<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateWhereInput = $WhereInput<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateSelect = $SelectInput<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateInclude = $IncludeInput<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateOmit = $OmitInput<$Schema, "RescheduledEventDate">; +export type RescheduledEventDateGetPayload> = $SimplifiedModelResult<$Schema, "RescheduledEventDate", Args>; +export type ScheduledEventInviteFindManyArgs = $FindManyArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteFindUniqueArgs = $FindUniqueArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteFindFirstArgs = $FindFirstArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteCreateArgs = $CreateArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteCreateManyArgs = $CreateManyArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteUpdateArgs = $UpdateArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteUpdateManyArgs = $UpdateManyArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteUpsertArgs = $UpsertArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteDeleteArgs = $DeleteArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteDeleteManyArgs = $DeleteManyArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteCountArgs = $CountArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteAggregateArgs = $AggregateArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteGroupByArgs = $GroupByArgs<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteWhereInput = $WhereInput<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteSelect = $SelectInput<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteInclude = $IncludeInput<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteOmit = $OmitInput<$Schema, "ScheduledEventInvite">; +export type ScheduledEventInviteGetPayload> = $SimplifiedModelResult<$Schema, "ScheduledEventInvite", Args>; +export type CredentialFindManyArgs = $FindManyArgs<$Schema, "Credential">; +export type CredentialFindUniqueArgs = $FindUniqueArgs<$Schema, "Credential">; +export type CredentialFindFirstArgs = $FindFirstArgs<$Schema, "Credential">; +export type CredentialCreateArgs = $CreateArgs<$Schema, "Credential">; +export type CredentialCreateManyArgs = $CreateManyArgs<$Schema, "Credential">; +export type CredentialCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Credential">; +export type CredentialUpdateArgs = $UpdateArgs<$Schema, "Credential">; +export type CredentialUpdateManyArgs = $UpdateManyArgs<$Schema, "Credential">; +export type CredentialUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Credential">; +export type CredentialUpsertArgs = $UpsertArgs<$Schema, "Credential">; +export type CredentialDeleteArgs = $DeleteArgs<$Schema, "Credential">; +export type CredentialDeleteManyArgs = $DeleteManyArgs<$Schema, "Credential">; +export type CredentialCountArgs = $CountArgs<$Schema, "Credential">; +export type CredentialAggregateArgs = $AggregateArgs<$Schema, "Credential">; +export type CredentialGroupByArgs = $GroupByArgs<$Schema, "Credential">; +export type CredentialWhereInput = $WhereInput<$Schema, "Credential">; +export type CredentialSelect = $SelectInput<$Schema, "Credential">; +export type CredentialInclude = $IncludeInput<$Schema, "Credential">; +export type CredentialOmit = $OmitInput<$Schema, "Credential">; +export type CredentialGetPayload> = $SimplifiedModelResult<$Schema, "Credential", Args>; +export type CalendarConnectionFindManyArgs = $FindManyArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionFindUniqueArgs = $FindUniqueArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionFindFirstArgs = $FindFirstArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionCreateArgs = $CreateArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionCreateManyArgs = $CreateManyArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionUpdateArgs = $UpdateArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionUpdateManyArgs = $UpdateManyArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionUpsertArgs = $UpsertArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionDeleteArgs = $DeleteArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionDeleteManyArgs = $DeleteManyArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionCountArgs = $CountArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionAggregateArgs = $AggregateArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionGroupByArgs = $GroupByArgs<$Schema, "CalendarConnection">; +export type CalendarConnectionWhereInput = $WhereInput<$Schema, "CalendarConnection">; +export type CalendarConnectionSelect = $SelectInput<$Schema, "CalendarConnection">; +export type CalendarConnectionInclude = $IncludeInput<$Schema, "CalendarConnection">; +export type CalendarConnectionOmit = $OmitInput<$Schema, "CalendarConnection">; +export type CalendarConnectionGetPayload> = $SimplifiedModelResult<$Schema, "CalendarConnection", Args>; +export type ProviderCalendarFindManyArgs = $FindManyArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarFindUniqueArgs = $FindUniqueArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarFindFirstArgs = $FindFirstArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarCreateArgs = $CreateArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarCreateManyArgs = $CreateManyArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarUpdateArgs = $UpdateArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarUpdateManyArgs = $UpdateManyArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarUpsertArgs = $UpsertArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarDeleteArgs = $DeleteArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarDeleteManyArgs = $DeleteManyArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarCountArgs = $CountArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarAggregateArgs = $AggregateArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarGroupByArgs = $GroupByArgs<$Schema, "ProviderCalendar">; +export type ProviderCalendarWhereInput = $WhereInput<$Schema, "ProviderCalendar">; +export type ProviderCalendarSelect = $SelectInput<$Schema, "ProviderCalendar">; +export type ProviderCalendarInclude = $IncludeInput<$Schema, "ProviderCalendar">; +export type ProviderCalendarOmit = $OmitInput<$Schema, "ProviderCalendar">; +export type ProviderCalendarGetPayload> = $SimplifiedModelResult<$Schema, "ProviderCalendar", Args>; +export type InstanceSettingsFindManyArgs = $FindManyArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsFindUniqueArgs = $FindUniqueArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsFindFirstArgs = $FindFirstArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsCreateArgs = $CreateArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsCreateManyArgs = $CreateManyArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsUpdateArgs = $UpdateArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsUpdateManyArgs = $UpdateManyArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsUpsertArgs = $UpsertArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsDeleteArgs = $DeleteArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsDeleteManyArgs = $DeleteManyArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsCountArgs = $CountArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsAggregateArgs = $AggregateArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsGroupByArgs = $GroupByArgs<$Schema, "InstanceSettings">; +export type InstanceSettingsWhereInput = $WhereInput<$Schema, "InstanceSettings">; +export type InstanceSettingsSelect = $SelectInput<$Schema, "InstanceSettings">; +export type InstanceSettingsInclude = $IncludeInput<$Schema, "InstanceSettings">; +export type InstanceSettingsOmit = $OmitInput<$Schema, "InstanceSettings">; +export type InstanceSettingsGetPayload> = $SimplifiedModelResult<$Schema, "InstanceSettings", Args>; +export type LicenseFindManyArgs = $FindManyArgs<$Schema, "License">; +export type LicenseFindUniqueArgs = $FindUniqueArgs<$Schema, "License">; +export type LicenseFindFirstArgs = $FindFirstArgs<$Schema, "License">; +export type LicenseCreateArgs = $CreateArgs<$Schema, "License">; +export type LicenseCreateManyArgs = $CreateManyArgs<$Schema, "License">; +export type LicenseCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "License">; +export type LicenseUpdateArgs = $UpdateArgs<$Schema, "License">; +export type LicenseUpdateManyArgs = $UpdateManyArgs<$Schema, "License">; +export type LicenseUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "License">; +export type LicenseUpsertArgs = $UpsertArgs<$Schema, "License">; +export type LicenseDeleteArgs = $DeleteArgs<$Schema, "License">; +export type LicenseDeleteManyArgs = $DeleteManyArgs<$Schema, "License">; +export type LicenseCountArgs = $CountArgs<$Schema, "License">; +export type LicenseAggregateArgs = $AggregateArgs<$Schema, "License">; +export type LicenseGroupByArgs = $GroupByArgs<$Schema, "License">; +export type LicenseWhereInput = $WhereInput<$Schema, "License">; +export type LicenseSelect = $SelectInput<$Schema, "License">; +export type LicenseInclude = $IncludeInput<$Schema, "License">; +export type LicenseOmit = $OmitInput<$Schema, "License">; +export type LicenseGetPayload> = $SimplifiedModelResult<$Schema, "License", Args>; +export type LicenseValidationFindManyArgs = $FindManyArgs<$Schema, "LicenseValidation">; +export type LicenseValidationFindUniqueArgs = $FindUniqueArgs<$Schema, "LicenseValidation">; +export type LicenseValidationFindFirstArgs = $FindFirstArgs<$Schema, "LicenseValidation">; +export type LicenseValidationCreateArgs = $CreateArgs<$Schema, "LicenseValidation">; +export type LicenseValidationCreateManyArgs = $CreateManyArgs<$Schema, "LicenseValidation">; +export type LicenseValidationCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "LicenseValidation">; +export type LicenseValidationUpdateArgs = $UpdateArgs<$Schema, "LicenseValidation">; +export type LicenseValidationUpdateManyArgs = $UpdateManyArgs<$Schema, "LicenseValidation">; +export type LicenseValidationUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "LicenseValidation">; +export type LicenseValidationUpsertArgs = $UpsertArgs<$Schema, "LicenseValidation">; +export type LicenseValidationDeleteArgs = $DeleteArgs<$Schema, "LicenseValidation">; +export type LicenseValidationDeleteManyArgs = $DeleteManyArgs<$Schema, "LicenseValidation">; +export type LicenseValidationCountArgs = $CountArgs<$Schema, "LicenseValidation">; +export type LicenseValidationAggregateArgs = $AggregateArgs<$Schema, "LicenseValidation">; +export type LicenseValidationGroupByArgs = $GroupByArgs<$Schema, "LicenseValidation">; +export type LicenseValidationWhereInput = $WhereInput<$Schema, "LicenseValidation">; +export type LicenseValidationSelect = $SelectInput<$Schema, "LicenseValidation">; +export type LicenseValidationInclude = $IncludeInput<$Schema, "LicenseValidation">; +export type LicenseValidationOmit = $OmitInput<$Schema, "LicenseValidation">; +export type LicenseValidationGetPayload> = $SimplifiedModelResult<$Schema, "LicenseValidation", Args>; +export type InstanceLicenseFindManyArgs = $FindManyArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseFindUniqueArgs = $FindUniqueArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseFindFirstArgs = $FindFirstArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseCreateArgs = $CreateArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseCreateManyArgs = $CreateManyArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseUpdateArgs = $UpdateArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseUpdateManyArgs = $UpdateManyArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseUpsertArgs = $UpsertArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseDeleteArgs = $DeleteArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseDeleteManyArgs = $DeleteManyArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseCountArgs = $CountArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseAggregateArgs = $AggregateArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseGroupByArgs = $GroupByArgs<$Schema, "InstanceLicense">; +export type InstanceLicenseWhereInput = $WhereInput<$Schema, "InstanceLicense">; +export type InstanceLicenseSelect = $SelectInput<$Schema, "InstanceLicense">; +export type InstanceLicenseInclude = $IncludeInput<$Schema, "InstanceLicense">; +export type InstanceLicenseOmit = $OmitInput<$Schema, "InstanceLicense">; +export type InstanceLicenseGetPayload> = $SimplifiedModelResult<$Schema, "InstanceLicense", Args>; diff --git a/tests/e2e/apps/rally/zenstack/models.ts b/tests/e2e/apps/rally/zenstack/models.ts new file mode 100644 index 00000000..e30e340b --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models.ts @@ -0,0 +1,64 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { schema as $schema, type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult } from "@zenstackhq/orm"; +export type Account = $ModelResult<$Schema, "Account">; +export type User = $ModelResult<$Schema, "User">; +export type VerificationToken = $ModelResult<$Schema, "VerificationToken">; +export type Session = $ModelResult<$Schema, "Session">; +export type Verification = $ModelResult<$Schema, "Verification">; +export type Poll = $ModelResult<$Schema, "Poll">; +export type Watcher = $ModelResult<$Schema, "Watcher">; +export type Participant = $ModelResult<$Schema, "Participant">; +export type Option = $ModelResult<$Schema, "Option">; +export type Vote = $ModelResult<$Schema, "Vote">; +export type Comment = $ModelResult<$Schema, "Comment">; +export type PollView = $ModelResult<$Schema, "PollView">; +export type Space = $ModelResult<$Schema, "Space">; +export type SpaceMember = $ModelResult<$Schema, "SpaceMember">; +export type SpaceMemberInvite = $ModelResult<$Schema, "SpaceMemberInvite">; +export type Subscription = $ModelResult<$Schema, "Subscription">; +export type PaymentMethod = $ModelResult<$Schema, "PaymentMethod">; +export type ScheduledEvent = $ModelResult<$Schema, "ScheduledEvent">; +export type RescheduledEventDate = $ModelResult<$Schema, "RescheduledEventDate">; +export type ScheduledEventInvite = $ModelResult<$Schema, "ScheduledEventInvite">; +export type Credential = $ModelResult<$Schema, "Credential">; +export type CalendarConnection = $ModelResult<$Schema, "CalendarConnection">; +export type ProviderCalendar = $ModelResult<$Schema, "ProviderCalendar">; +export type InstanceSettings = $ModelResult<$Schema, "InstanceSettings">; +export type License = $ModelResult<$Schema, "License">; +export type LicenseValidation = $ModelResult<$Schema, "LicenseValidation">; +export type InstanceLicense = $ModelResult<$Schema, "InstanceLicense">; +export const TimeFormat = $schema.enums.TimeFormat.values; +export type TimeFormat = (typeof TimeFormat)[keyof typeof TimeFormat]; +export const UserRole = $schema.enums.UserRole.values; +export type UserRole = (typeof UserRole)[keyof typeof UserRole]; +export const ParticipantVisibility = $schema.enums.ParticipantVisibility.values; +export type ParticipantVisibility = (typeof ParticipantVisibility)[keyof typeof ParticipantVisibility]; +export const PollStatus = $schema.enums.PollStatus.values; +export type PollStatus = (typeof PollStatus)[keyof typeof PollStatus]; +export const VoteType = $schema.enums.VoteType.values; +export type VoteType = (typeof VoteType)[keyof typeof VoteType]; +export const SpaceMemberRole = $schema.enums.SpaceMemberRole.values; +export type SpaceMemberRole = (typeof SpaceMemberRole)[keyof typeof SpaceMemberRole]; +export const SpaceTier = $schema.enums.SpaceTier.values; +export type SpaceTier = (typeof SpaceTier)[keyof typeof SpaceTier]; +export const SubscriptionStatus = $schema.enums.SubscriptionStatus.values; +export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus]; +export const SubscriptionInterval = $schema.enums.SubscriptionInterval.values; +export type SubscriptionInterval = (typeof SubscriptionInterval)[keyof typeof SubscriptionInterval]; +export const ScheduledEventStatus = $schema.enums.ScheduledEventStatus.values; +export type ScheduledEventStatus = (typeof ScheduledEventStatus)[keyof typeof ScheduledEventStatus]; +export const ScheduledEventInviteStatus = $schema.enums.ScheduledEventInviteStatus.values; +export type ScheduledEventInviteStatus = (typeof ScheduledEventInviteStatus)[keyof typeof ScheduledEventInviteStatus]; +export const CredentialType = $schema.enums.CredentialType.values; +export type CredentialType = (typeof CredentialType)[keyof typeof CredentialType]; +export const LicenseType = $schema.enums.LicenseType.values; +export type LicenseType = (typeof LicenseType)[keyof typeof LicenseType]; +export const LicenseStatus = $schema.enums.LicenseStatus.values; +export type LicenseStatus = (typeof LicenseStatus)[keyof typeof LicenseStatus]; diff --git a/tests/e2e/apps/rally/zenstack/models/billing.zmodel b/tests/e2e/apps/rally/zenstack/models/billing.zmodel new file mode 100644 index 00000000..7d0694c2 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/billing.zmodel @@ -0,0 +1,60 @@ +import 'user' +import 'space' + +model Subscription { + id String @id + priceId String @map("price_id") + quantity Int @default(1) + subscriptionItemId String @map("subscription_item_id") + amount Int + status SubscriptionStatus + active Boolean + currency String + interval SubscriptionInterval + createdAt DateTime @default(now()) @map("created_at") + periodStart DateTime @map("period_start") + periodEnd DateTime @map("period_end") + cancelAtPeriodEnd Boolean @default(false) @map("cancel_at_period_end") + userId String @map("user_id") + spaceId String @map("space_id") + + user User @relation("UserToSubscription", fields: [userId], references: [id], onDelete: Cascade) + space Space @relation("SpaceToSubscription", fields: [spaceId], references: [id], onDelete: Cascade) + + @@index([userId], type: Hash) + @@index([spaceId], type: Hash) + @@map("subscriptions") +} + +enum SubscriptionStatus { + incomplete + incomplete_expired + active + paused + trialing + past_due + canceled + unpaid + + @@map("subscription_status") +} + +enum SubscriptionInterval { + month + year + + @@map("subscription_interval") +} + +model PaymentMethod { + id String @id + userId String @map("user_id") + type String + data Json + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@map("payment_methods") +} diff --git a/tests/e2e/apps/rally/zenstack/models/event.zmodel b/tests/e2e/apps/rally/zenstack/models/event.zmodel new file mode 100644 index 00000000..cfb3dec8 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/event.zmodel @@ -0,0 +1,83 @@ +import 'user' +import 'space' +import 'poll' + +enum ScheduledEventStatus { + confirmed + canceled + unconfirmed + + @@map("scheduled_event_status") +} + +enum ScheduledEventInviteStatus { + pending + accepted + declined + tentative + + @@map("scheduled_event_invite_status") +} + +model ScheduledEvent { + id String @id @default(cuid()) + userId String @map("user_id") + spaceId String @map("space_id") + title String + description String? + location String? + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + status ScheduledEventStatus @default(confirmed) + timeZone String? @map("time_zone") + start DateTime + end DateTime + allDay Boolean @default(false) @map("all_day") + deletedAt DateTime? @map("deleted_at") + sequence Int @default(0) + uid String @unique + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade) + rescheduledDates RescheduledEventDate[] + invites ScheduledEventInvite[] + polls Poll[] + + @@index([spaceId], type: Hash) + @@index([userId], type: Hash) + @@map("scheduled_events") +} + +model RescheduledEventDate { + id String @id @default(cuid()) + scheduledEventId String @map("scheduled_event_id") + start DateTime @map("start") + end DateTime @map("end") + allDay Boolean @default(false) @map("all_day") + createdAt DateTime @default(now()) @map("created_at") + + scheduledEvent ScheduledEvent @relation(fields: [scheduledEventId], references: [id], onDelete: Cascade) + + @@index([scheduledEventId]) + @@map("rescheduled_event_dates") +} + +model ScheduledEventInvite { + id String @id @default(cuid()) + scheduledEventId String @map("scheduled_event_id") + inviteeName String @map("invitee_name") + inviteeEmail String @map("invitee_email") + inviteeId String? @map("invitee_id") + inviteeTimeZone String? @map("invitee_time_zone") + status ScheduledEventInviteStatus @default(pending) + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + scheduledEvent ScheduledEvent @relation(fields: [scheduledEventId], references: [id], onDelete: Cascade) + user User? @relation(fields: [inviteeId], references: [id], onDelete: SetNull) // Optional relation to User model + + @@index([scheduledEventId]) + @@index([inviteeId]) + @@index([inviteeEmail]) + @@map("scheduled_event_invites") +} diff --git a/tests/e2e/apps/rally/zenstack/models/instance-settings.zmodel b/tests/e2e/apps/rally/zenstack/models/instance-settings.zmodel new file mode 100644 index 00000000..fabf7a56 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/instance-settings.zmodel @@ -0,0 +1,10 @@ +model InstanceSettings { + id Int @id @default(1) + // Authentication & Security + disableUserRegistration Boolean @default(false) @map("disable_user_registration") + + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @default(now()) @updatedAt @map("updated_at") + + @@map("instance_settings") +} diff --git a/tests/e2e/apps/rally/zenstack/models/integrations.zmodel b/tests/e2e/apps/rally/zenstack/models/integrations.zmodel new file mode 100644 index 00000000..29fa45c1 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/integrations.zmodel @@ -0,0 +1,87 @@ +import 'user' + +enum CredentialType { + OAUTH +} + +model Credential { + id String @id @default(cuid()) + userId String @map("user_id") + provider String + providerAccountId String @map("provider_account_id") + type CredentialType + secret String @map("secret") + scopes String[] + expiresAt DateTime? @map("expires_at") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + // Relationships + calendarConnections CalendarConnection[] + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + // Constraints and indexes + @@unique([userId, provider, providerAccountId], name: "user_provider_account_unique") + @@index([expiresAt], name: "credential_expiry_idx") + @@map("credentials") +} + +model CalendarConnection { + id String @id @default(cuid()) + userId String @map("user_id") + provider String + integrationId String @map("integration_id") + providerAccountId String @map("provider_account_id") + email String + displayName String? @map("display_name") + + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + // Relationships + credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade) + credentialId String @map("credential_id") + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + providerCalendars ProviderCalendar[] + + // Constraints and indexes + @@unique([userId, provider, providerAccountId], name: "user_provider_account_unique") + @@map("calendar_connections") +} + +model ProviderCalendar { + id String @id @default(cuid()) + calendarConnectionId String @map("calendar_connection_id") + + // Provider's calendar data - common fields across all providers + providerCalendarId String @map("provider_calendar_id") + name String + isPrimary Boolean @default(false) @map("primary") + timeZone String? @map("time_zone") + + // Selection and sync preferences + isSelected Boolean @default(false) @map("selected") + + // Provider state tracking + isDeleted Boolean @default(false) @map("deleted") + isWritable Boolean @default(false) @map("writable") + + // Provider-specific metadata stored as JSON + providerData Json? @map("provider_data") + + // Timestamps + lastSyncedAt DateTime @default(now()) @map("last_synced_at") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + // Relationships + calendarConnection CalendarConnection @relation(fields: [calendarConnectionId], references: [id], onDelete: Cascade) + userDefaultDestination User[] @relation("UserDefaultDestinationCalendar") + + // Indexes and constraints + @@unique([calendarConnectionId, providerCalendarId], name: "connection_calendar_unique") + @@index([calendarConnectionId, isSelected], name: "connection_selected_idx") + @@index([isPrimary], name: "primary_calendar_idx") + @@index([lastSyncedAt], name: "sync_time_idx") + @@map("provider_calendars") +} diff --git a/tests/e2e/apps/rally/zenstack/models/licensing.zmodel b/tests/e2e/apps/rally/zenstack/models/licensing.zmodel new file mode 100644 index 00000000..5b813217 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/licensing.zmodel @@ -0,0 +1,54 @@ +enum LicenseType { + PLUS + ORGANIZATION + ENTERPRISE +} + +enum LicenseStatus { + ACTIVE + REVOKED +} + +model License { + id String @id @default(cuid()) + licenseKey String @unique @map("license_key") + version Int? @map("version") + type LicenseType + seats Int? @map("seats") + issuedAt DateTime @default(now()) @map("issued_at") + expiresAt DateTime? @map("expires_at") + licenseeEmail String? @map("licensee_email") + licenseeName String? @map("licensee_name") + status LicenseStatus @default(ACTIVE) @map("status") + + validations LicenseValidation[] + + @@map("licenses") +} + +model LicenseValidation { + id String @id @default(cuid()) + licenseId String @map("license_id") + license License @relation(fields: [licenseId], references: [id], onDelete: Cascade) + ipAddress String? @map("ip_address") + fingerprint String? @map("fingerprint") + validatedAt DateTime @default(now()) @map("validated_at") + userAgent String? @map("user_agent") + + @@map("license_validations") +} + +model InstanceLicense { + id String @id @default(cuid()) + licenseKey String @unique @map("license_key") + version Int? @map("version") + type LicenseType + seats Int? @map("seats") + issuedAt DateTime @default(now()) @map("issued_at") + expiresAt DateTime? @map("expires_at") + licenseeEmail String? @map("licensee_email") + licenseeName String? @map("licensee_name") + status LicenseStatus @default(ACTIVE) @map("status") + + @@map("instance_licenses") +} diff --git a/tests/e2e/apps/rally/zenstack/models/poll.zmodel b/tests/e2e/apps/rally/zenstack/models/poll.zmodel new file mode 100644 index 00000000..ed1c783a --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/poll.zmodel @@ -0,0 +1,172 @@ +import 'user' +import 'space' +import 'event' + +enum ParticipantVisibility { + full + scoresOnly + limited + + @@map("participant_visibility") +} + +enum PollStatus { + live + paused + finalized + + @@map("poll_status") +} + +model Poll { + id String @id @unique @map("id") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + deadline DateTime? + title String + description String? + location String? + userId String? @map("user_id") + guestId String? @map("guest_id") + timeZone String? @map("time_zone") + status PollStatus @default(live) + deleted Boolean @default(false) + deletedAt DateTime? @map("deleted_at") + touchedAt DateTime @default(now()) @map("touched_at") // @deprecated + participantUrlId String @unique @map("participant_url_id") + adminUrlId String @unique @map("admin_url_id") + eventId String? @unique @map("event_id") + scheduledEventId String? @map("scheduled_event_id") + hideParticipants Boolean @default(false) @map("hide_participants") + hideScores Boolean @default(false) @map("hide_scores") + disableComments Boolean @default(false) @map("disable_comments") + requireParticipantEmail Boolean @default(false) @map("require_participant_email") + + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + scheduledEvent ScheduledEvent? @relation(fields: [scheduledEventId], references: [id], onDelete: SetNull) + options Option[] + participants Participant[] + watchers Watcher[] + comments Comment[] + votes Vote[] + views PollView[] + space Space? @relation(fields: [spaceId], references: [id], onDelete: SetNull) + spaceId String? @map("space_id") + + @@index([guestId], type: Hash) + @@index([spaceId], type: Hash) + @@index([userId], type: Hash) + @@map("polls") +} + +model Watcher { + id Int @id @default(autoincrement()) + userId String @map("user_id") + pollId String @map("poll_id") + createdAt DateTime @default(now()) @map("created_at") + + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([pollId], type: Hash) + @@map("watchers") +} + +model Participant { + id String @id @default(cuid()) + name String + email String? + userId String? @map("user_id") + guestId String? @map("guest_id") + pollId String @map("poll_id") + locale String? + timeZone String? @map("time_zone") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime? @updatedAt @map("updated_at") + deleted Boolean @default(false) + deletedAt DateTime? @map("deleted_at") + + votes Vote[] + + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + user User? @relation(fields: [userId], references: [id], onDelete: SetNull) + + @@index([pollId], type: Hash) + @@map("participants") +} + +model Option { + id String @id @default(cuid()) + startTime DateTime @map("start_time") @db.Timestamp(0) + duration Int @default(0) @map("duration_minutes") + pollId String @map("poll_id") + createdAt DateTime @default(now()) @map("created_at") + + votes Vote[] + + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + + @@index([pollId], type: Hash) + @@map("options") +} + +enum VoteType { + yes + no + ifNeedBe + + @@map("vote_type") +} + +model Vote { + id String @id @default(cuid()) + participantId String @map("participant_id") + optionId String @map("option_id") + pollId String @map("poll_id") + type VoteType @default(yes) + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime? @updatedAt @map("updated_at") + + participant Participant @relation(fields: [participantId], references: [id], onDelete: Cascade) + option Option @relation(fields: [optionId], references: [id], onDelete: Cascade) + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + + @@index([pollId], type: Hash) + @@index([participantId], type: Hash) + @@index([optionId], type: Hash) + @@map("votes") +} + +model Comment { + id String @id @default(cuid()) + content String + pollId String @map("poll_id") + authorName String @map("author_name") + userId String? @map("user_id") + guestId String? @map("guest_id") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime? @updatedAt @map("updated_at") + + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([pollId], type: Hash) + @@map("comments") +} + +model PollView { + id String @id @default(cuid()) + pollId String @map("poll_id") + ipAddress String? @map("ip_address") + userId String? @map("user_id") + userAgent String? @map("user_agent") + viewedAt DateTime @default(now()) @map("viewed_at") + + poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade) + user User? @relation(fields: [userId], references: [id], onDelete: SetNull) + + @@index([pollId], type: Hash) + @@index([userId], type: Hash) + @@index([viewedAt]) + @@map("poll_views") +} diff --git a/tests/e2e/apps/rally/zenstack/models/space.zmodel b/tests/e2e/apps/rally/zenstack/models/space.zmodel new file mode 100644 index 00000000..3335dd27 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/space.zmodel @@ -0,0 +1,73 @@ +import 'user' +import 'poll' +import 'billing' +import 'event' + +model Space { + id String @id @default(uuid()) + name String + image String? + ownerId String @map("owner_id") + tier SpaceTier @default(hobby) + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + owner User @relation("UserSpaces", fields: [ownerId], references: [id], onDelete: Cascade) + polls Poll[] + scheduledEvents ScheduledEvent[] + subscriptions Subscription[] @relation("SpaceToSubscription") + + members SpaceMember[] + + memberInvites SpaceMemberInvite[] + + @@index([ownerId], type: Hash) + @@map("spaces") +} + +enum SpaceMemberRole { + ADMIN + MEMBER +} + +enum SpaceTier { + hobby + pro + + @@map("space_tiers") +} + +model SpaceMember { + id String @id @default(uuid()) + spaceId String @map("space_id") + userId String @map("user_id") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + role SpaceMemberRole @default(MEMBER) + lastSelectedAt DateTime @default(now()) @map("last_selected_at") + + space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@unique([spaceId, userId]) + @@index([spaceId], type: Hash, map: "space_members_space_id_idx") + @@index([userId], type: Hash, map: "space_members_user_id_idx") + @@map("space_members") +} + +model SpaceMemberInvite { + id String @id @default(uuid()) + spaceId String @map("space_id") + email String + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + role SpaceMemberRole @default(MEMBER) + inviterId String @map("inviter_id") + + invitedBy User @relation(fields: [inviterId], references: [id], onDelete: Cascade) + space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade) + + @@unique([spaceId, email]) + @@index([spaceId], type: Hash, map: "space_member_invites_space_id_idx") + @@map("space_member_invites") +} diff --git a/tests/e2e/apps/rally/zenstack/models/user.zmodel b/tests/e2e/apps/rally/zenstack/models/user.zmodel new file mode 100644 index 00000000..9e83ed88 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/models/user.zmodel @@ -0,0 +1,130 @@ +import 'poll' +import 'billing' +import 'space' +import 'event' +import 'integrations' + +enum TimeFormat { + hours12 + hours24 + + @@map("time_format") +} + +model Account { + id String @id @default(cuid()) + userId String @map("user_id") + provider String + providerAccountId String @map("provider_account_id") + refresh_token String? @db.Text + access_token String? @db.Text + expires_at Int? + scope String? + id_token String? @db.Text + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + accessTokenExpiresAt DateTime? @map("access_token_expires_at") + refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at") + password String? @map("password") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + @@unique([provider, providerAccountId]) + @@map("accounts") +} + +enum UserRole { + admin + user + + @@map("user_role") +} + +model User { + id String @id @default(cuid()) + name String + email String @unique @db.Citext + emailVerified Boolean? @map("email_verified") + image String? + timeZone String? @map("time_zone") + weekStart Int? @map("week_start") + timeFormat TimeFormat? @map("time_format") + locale String? + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime? @updatedAt @map("updated_at") + customerId String? @map("customer_id") + banned Boolean @default(false) + bannedAt DateTime? @map("banned_at") + banReason String? @map("ban_reason") + banExpires DateTime? @map("ban_expires") + role UserRole @default(user) + lastLoginMethod String? @map("last_login_method") + isAnonymous Boolean @default(false) @map("anonymous") + + comments Comment[] + polls Poll[] + watcher Watcher[] + accounts Account[] + participants Participant[] + paymentMethods PaymentMethod[] + spaceMemberInvites SpaceMemberInvite[] + + subscriptions Subscription[] @relation("UserToSubscription") + spaces Space[] @relation("UserSpaces") + memberOf SpaceMember[] + + pollViews PollView[] + scheduledEvents ScheduledEvent[] + scheduledEventInvites ScheduledEventInvite[] + + calendarConnections CalendarConnection[] + credentials Credential[] + + // Default destination calendar for new events + defaultDestinationCalendarId String? @map("default_destination_calendar_id") + defaultDestinationCalendar ProviderCalendar? @relation("UserDefaultDestinationCalendar", fields: [defaultDestinationCalendarId], references: [id], onDelete: SetNull) + + sessions Session[] + impersonatedSessions Session[] @relation("ImpersonatedSessions") + + @@map("users") +} + +model VerificationToken { + identifier String @db.Citext + token String @unique + expires DateTime + + @@unique([identifier, token]) + @@map("verification_tokens") +} + +model Session { + id String @id + expiresAt DateTime @map("expires_at") + token String + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + ipAddress String? @map("ip_address") + userAgent String? @map("user_agent") + userId String @map("user_id") + impersonatedBy String? @map("impersonated_by") + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + impersonatedByUser User? @relation("ImpersonatedSessions", fields: [impersonatedBy], references: [id]) + + @@unique([token]) + @@map("sessions") +} + +model Verification { + id String @id + identifier String + value String + expiresAt DateTime @map("expires_at") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @default(now()) @updatedAt @map("updated_at") + + @@map("verifications") +} diff --git a/tests/e2e/apps/rally/zenstack/schema.ts b/tests/e2e/apps/rally/zenstack/schema.ts new file mode 100644 index 00000000..1684a553 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/schema.ts @@ -0,0 +1,2523 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; +export const schema = { + provider: { + type: "postgresql" + }, + models: { + Account: { + name: "Account", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + provider: { + name: "provider", + type: "String" + }, + providerAccountId: { + name: "providerAccountId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + }, + refresh_token: { + name: "refresh_token", + type: "String", + optional: true, + attributes: [{ name: "@db.Text" }] + }, + access_token: { + name: "access_token", + type: "String", + optional: true, + attributes: [{ name: "@db.Text" }] + }, + expires_at: { + name: "expires_at", + type: "Int", + optional: true + }, + scope: { + name: "scope", + type: "String", + optional: true + }, + id_token: { + name: "id_token", + type: "String", + optional: true, + attributes: [{ name: "@db.Text" }] + }, + 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: "accounts", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + accessTokenExpiresAt: { + name: "accessTokenExpiresAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("access_token_expires_at") }] }] + }, + refreshTokenExpiresAt: { + name: "refreshTokenExpiresAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("refresh_token_expires_at") }] }] + }, + password: { + name: "password", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("password") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("accounts") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + provider_providerAccountId: { provider: { type: "String" }, providerAccountId: { type: "String" } } + } + }, + User: { + name: "User", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + name: { + name: "name", + type: "String" + }, + email: { + name: "email", + type: "String", + unique: true, + attributes: [{ name: "@unique" }, { name: "@db.Citext" }] + }, + emailVerified: { + name: "emailVerified", + type: "Boolean", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("email_verified") }] }] + }, + image: { + name: "image", + type: "String", + optional: true + }, + timeZone: { + name: "timeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + }, + weekStart: { + name: "weekStart", + type: "Int", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("week_start") }] }] + }, + timeFormat: { + name: "timeFormat", + type: "TimeFormat", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_format") }] }] + }, + locale: { + name: "locale", + type: "String", + optional: true + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + optional: true, + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + customerId: { + name: "customerId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("customer_id") }] }] + }, + banned: { + name: "banned", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false + }, + bannedAt: { + name: "bannedAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("banned_at") }] }] + }, + banReason: { + name: "banReason", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_reason") }] }] + }, + banExpires: { + name: "banExpires", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_expires") }] }] + }, + role: { + name: "role", + type: "UserRole", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("user") }] }], + default: "user" + }, + lastLoginMethod: { + name: "lastLoginMethod", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_login_method") }] }] + }, + isAnonymous: { + name: "isAnonymous", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("anonymous") }] }], + default: false + }, + comments: { + name: "comments", + type: "Comment", + array: true, + relation: { opposite: "user" } + }, + polls: { + name: "polls", + type: "Poll", + array: true, + relation: { opposite: "user" } + }, + watcher: { + name: "watcher", + type: "Watcher", + array: true, + relation: { opposite: "user" } + }, + accounts: { + name: "accounts", + type: "Account", + array: true, + relation: { opposite: "user" } + }, + participants: { + name: "participants", + type: "Participant", + array: true, + relation: { opposite: "user" } + }, + paymentMethods: { + name: "paymentMethods", + type: "PaymentMethod", + array: true, + relation: { opposite: "user" } + }, + spaceMemberInvites: { + name: "spaceMemberInvites", + type: "SpaceMemberInvite", + array: true, + relation: { opposite: "invitedBy" } + }, + subscriptions: { + name: "subscriptions", + type: "Subscription", + array: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }] }], + relation: { opposite: "user", name: "UserToSubscription" } + }, + spaces: { + name: "spaces", + type: "Space", + array: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }] }], + relation: { opposite: "owner", name: "UserSpaces" } + }, + memberOf: { + name: "memberOf", + type: "SpaceMember", + array: true, + relation: { opposite: "user" } + }, + pollViews: { + name: "pollViews", + type: "PollView", + array: true, + relation: { opposite: "user" } + }, + scheduledEvents: { + name: "scheduledEvents", + type: "ScheduledEvent", + array: true, + relation: { opposite: "user" } + }, + scheduledEventInvites: { + name: "scheduledEventInvites", + type: "ScheduledEventInvite", + array: true, + relation: { opposite: "user" } + }, + calendarConnections: { + name: "calendarConnections", + type: "CalendarConnection", + array: true, + relation: { opposite: "user" } + }, + credentials: { + name: "credentials", + type: "Credential", + array: true, + relation: { opposite: "user" } + }, + defaultDestinationCalendarId: { + name: "defaultDestinationCalendarId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("default_destination_calendar_id") }] }], + foreignKeyFor: [ + "defaultDestinationCalendar" + ] + }, + defaultDestinationCalendar: { + name: "defaultDestinationCalendar", + type: "ProviderCalendar", + optional: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserDefaultDestinationCalendar") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("defaultDestinationCalendarId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + relation: { opposite: "userDefaultDestination", name: "UserDefaultDestinationCalendar", fields: ["defaultDestinationCalendarId"], references: ["id"], onDelete: "SetNull" } + }, + sessions: { + name: "sessions", + type: "Session", + array: true, + relation: { opposite: "user" } + }, + impersonatedSessions: { + name: "impersonatedSessions", + type: "Session", + array: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ImpersonatedSessions") }] }], + relation: { opposite: "impersonatedByUser", name: "ImpersonatedSessions" } + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("users") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + email: { type: "String" } + } + }, + VerificationToken: { + name: "VerificationToken", + fields: { + identifier: { + name: "identifier", + type: "String", + attributes: [{ name: "@db.Citext" }] + }, + token: { + name: "token", + type: "String", + id: true, + unique: true, + attributes: [{ name: "@unique" }] + }, + expires: { + name: "expires", + type: "DateTime" + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("identifier"), ExpressionUtils.field("token")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("verification_tokens") }] } + ], + idFields: ["token"], + uniqueFields: { + token: { type: "String" }, + identifier_token: { identifier: { type: "String" }, token: { type: "String" } } + } + }, + Session: { + name: "Session", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }] + }, + expiresAt: { + name: "expiresAt", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + }, + token: { + name: "token", + type: "String" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + ipAddress: { + name: "ipAddress", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] + }, + userAgent: { + name: "userAgent", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_agent") }] }] + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + impersonatedBy: { + name: "impersonatedBy", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by") }] }], + foreignKeyFor: [ + "impersonatedByUser" + ] + }, + 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: "sessions", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + impersonatedByUser: { + name: "impersonatedByUser", + type: "User", + optional: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ImpersonatedSessions") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("impersonatedBy")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }] }], + relation: { opposite: "impersonatedSessions", name: "ImpersonatedSessions", fields: ["impersonatedBy"], references: ["id"] } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("token")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("sessions") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + token: { type: "String" } + } + }, + Verification: { + name: "Verification", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }] + }, + identifier: { + name: "identifier", + type: "String" + }, + value: { + name: "value", + type: "String" + }, + expiresAt: { + name: "expiresAt", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }], + default: ExpressionUtils.call("now") + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("verifications") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Poll: { + name: "Poll", + fields: { + id: { + name: "id", + type: "String", + id: true, + unique: true, + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("id") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + deadline: { + name: "deadline", + type: "DateTime", + optional: true + }, + title: { + name: "title", + type: "String" + }, + description: { + name: "description", + type: "String", + optional: true + }, + location: { + name: "location", + type: "String", + optional: true + }, + userId: { + name: "userId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + guestId: { + name: "guestId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + }, + timeZone: { + name: "timeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + }, + status: { + name: "status", + type: "PollStatus", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("live") }] }], + default: "live" + }, + deleted: { + name: "deleted", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false + }, + deletedAt: { + name: "deletedAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + }, + touchedAt: { + name: "touchedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("touched_at") }] }], + default: ExpressionUtils.call("now") + }, + participantUrlId: { + name: "participantUrlId", + type: "String", + unique: true, + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_url_id") }] }] + }, + adminUrlId: { + name: "adminUrlId", + type: "String", + unique: true, + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("admin_url_id") }] }] + }, + eventId: { + name: "eventId", + type: "String", + unique: true, + optional: true, + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("event_id") }] }] + }, + scheduledEventId: { + name: "scheduledEventId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + foreignKeyFor: [ + "scheduledEvent" + ] + }, + hideParticipants: { + name: "hideParticipants", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("hide_participants") }] }], + default: false + }, + hideScores: { + name: "hideScores", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("hide_scores") }] }], + default: false + }, + disableComments: { + name: "disableComments", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("disable_comments") }] }], + default: false + }, + requireParticipantEmail: { + name: "requireParticipantEmail", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("require_participant_email") }] }], + default: false + }, + 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: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "polls", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + scheduledEvent: { + name: "scheduledEvent", + type: "ScheduledEvent", + optional: true, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + relation: { opposite: "polls", fields: ["scheduledEventId"], references: ["id"], onDelete: "SetNull" } + }, + options: { + name: "options", + type: "Option", + array: true, + relation: { opposite: "poll" } + }, + participants: { + name: "participants", + type: "Participant", + array: true, + relation: { opposite: "poll" } + }, + watchers: { + name: "watchers", + type: "Watcher", + array: true, + relation: { opposite: "poll" } + }, + comments: { + name: "comments", + type: "Comment", + array: true, + relation: { opposite: "poll" } + }, + votes: { + name: "votes", + type: "Vote", + array: true, + relation: { opposite: "poll" } + }, + views: { + name: "views", + type: "PollView", + array: true, + relation: { opposite: "poll" } + }, + space: { + name: "space", + type: "Space", + optional: true, + 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("SetNull") }] }], + relation: { opposite: "polls", fields: ["spaceId"], references: ["id"], onDelete: "SetNull" } + }, + spaceId: { + name: "spaceId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + foreignKeyFor: [ + "space" + ] + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("guestId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("polls") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + participantUrlId: { type: "String" }, + adminUrlId: { type: "String" }, + eventId: { type: "String" } + } + }, + Watcher: { + name: "Watcher", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + default: ExpressionUtils.call("autoincrement") + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "watchers", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "watcher", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("watchers") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + }, + Participant: { + name: "Participant", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + name: { + name: "name", + type: "String" + }, + email: { + name: "email", + type: "String", + optional: true + }, + userId: { + name: "userId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + guestId: { + name: "guestId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + locale: { + name: "locale", + type: "String", + optional: true + }, + timeZone: { + name: "timeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + optional: true, + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + deleted: { + name: "deleted", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false + }, + deletedAt: { + name: "deletedAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + }, + votes: { + name: "votes", + type: "Vote", + array: true, + relation: { opposite: "participant" } + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "participants", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + relation: { opposite: "participants", fields: ["userId"], references: ["id"], onDelete: "SetNull" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("participants") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Option: { + name: "Option", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + startTime: { + name: "startTime", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("start_time") }] }, { name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(0) }] }] + }, + duration: { + name: "duration", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("duration_minutes") }] }], + default: 0 + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + votes: { + name: "votes", + type: "Vote", + array: true, + relation: { opposite: "option" } + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "options", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("options") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Vote: { + name: "Vote", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + participantId: { + name: "participantId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_id") }] }], + foreignKeyFor: [ + "participant" + ] + }, + optionId: { + name: "optionId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("option_id") }] }], + foreignKeyFor: [ + "option" + ] + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + type: { + name: "type", + type: "VoteType", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("yes") }] }], + default: "yes" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + optional: true, + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + participant: { + name: "participant", + type: "Participant", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("participantId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "votes", fields: ["participantId"], references: ["id"], onDelete: "Cascade" } + }, + option: { + name: "option", + type: "Option", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("optionId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "votes", fields: ["optionId"], references: ["id"], onDelete: "Cascade" } + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "votes", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("participantId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("optionId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("votes") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Comment: { + name: "Comment", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + content: { + name: "content", + type: "String" + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + authorName: { + name: "authorName", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("author_name") }] }] + }, + userId: { + name: "userId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + guestId: { + name: "guestId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + optional: true, + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "comments", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "comments", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("comments") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + PollView: { + name: "PollView", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + pollId: { + name: "pollId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + foreignKeyFor: [ + "poll" + ] + }, + ipAddress: { + name: "ipAddress", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] + }, + userId: { + name: "userId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + userAgent: { + name: "userAgent", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_agent") }] }] + }, + viewedAt: { + name: "viewedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("viewed_at") }] }], + default: ExpressionUtils.call("now") + }, + poll: { + name: "poll", + type: "Poll", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "views", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + relation: { opposite: "pollViews", fields: ["userId"], references: ["id"], onDelete: "SetNull" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("viewedAt")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_views") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Space: { + name: "Space", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") + }, + name: { + name: "name", + type: "String" + }, + image: { + name: "image", + type: "String", + optional: true + }, + ownerId: { + name: "ownerId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("owner_id") }] }], + foreignKeyFor: [ + "owner" + ] + }, + tier: { + name: "tier", + type: "SpaceTier", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("hobby") }] }], + default: "hobby" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + owner: { + name: "owner", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "spaces", name: "UserSpaces", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } + }, + polls: { + name: "polls", + type: "Poll", + array: true, + relation: { opposite: "space" } + }, + scheduledEvents: { + name: "scheduledEvents", + type: "ScheduledEvent", + array: true, + relation: { opposite: "space" } + }, + subscriptions: { + name: "subscriptions", + type: "Subscription", + array: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SpaceToSubscription") }] }], + relation: { opposite: "space", name: "SpaceToSubscription" } + }, + members: { + name: "members", + type: "SpaceMember", + array: true, + relation: { opposite: "space" } + }, + memberInvites: { + name: "memberInvites", + type: "SpaceMemberInvite", + array: true, + relation: { opposite: "space" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("ownerId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("spaces") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + SpaceMember: { + name: "SpaceMember", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") + }, + spaceId: { + name: "spaceId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + foreignKeyFor: [ + "space" + ] + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + role: { + name: "role", + type: "SpaceMemberRole", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], + default: "MEMBER" + }, + lastSelectedAt: { + name: "lastSelectedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_selected_at") }] }], + default: ExpressionUtils.call("now") + }, + 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" } + }, + 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: "memberOf", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId"), ExpressionUtils.field("userId")]) }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }, { name: "map", value: ExpressionUtils.literal("space_members_space_id_idx") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }, { name: "map", value: ExpressionUtils.literal("space_members_user_id_idx") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("space_members") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + spaceId_userId: { spaceId: { type: "String" }, userId: { type: "String" } } + } + }, + SpaceMemberInvite: { + name: "SpaceMemberInvite", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], + default: ExpressionUtils.call("uuid") + }, + spaceId: { + name: "spaceId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + foreignKeyFor: [ + "space" + ] + }, + email: { + name: "email", + type: "String" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + role: { + name: "role", + type: "SpaceMemberRole", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], + default: "MEMBER" + }, + inviterId: { + name: "inviterId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("inviter_id") }] }], + foreignKeyFor: [ + "invitedBy" + ] + }, + invitedBy: { + name: "invitedBy", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("inviterId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "spaceMemberInvites", fields: ["inviterId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "memberInvites", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId"), ExpressionUtils.field("email")]) }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }, { name: "map", value: ExpressionUtils.literal("space_member_invites_space_id_idx") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("space_member_invites") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + spaceId_email: { spaceId: { type: "String" }, email: { type: "String" } } + } + }, + Subscription: { + name: "Subscription", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }] + }, + priceId: { + name: "priceId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("price_id") }] }] + }, + quantity: { + name: "quantity", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], + default: 1 + }, + subscriptionItemId: { + name: "subscriptionItemId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_item_id") }] }] + }, + amount: { + name: "amount", + type: "Int" + }, + status: { + name: "status", + type: "SubscriptionStatus" + }, + active: { + name: "active", + type: "Boolean" + }, + currency: { + name: "currency", + type: "String" + }, + interval: { + name: "interval", + type: "SubscriptionInterval" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + periodStart: { + name: "periodStart", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_start") }] }] + }, + periodEnd: { + name: "periodEnd", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_end") }] }] + }, + cancelAtPeriodEnd: { + name: "cancelAtPeriodEnd", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("cancel_at_period_end") }] }], + default: false + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + spaceId: { + name: "spaceId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + foreignKeyFor: [ + "space" + ] + }, + user: { + name: "user", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "subscriptions", name: "UserToSubscription", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + space: { + name: "space", + type: "Space", + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SpaceToSubscription") }, { name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "subscriptions", name: "SpaceToSubscription", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscriptions") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + PaymentMethod: { + name: "PaymentMethod", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }] + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + type: { + name: "type", + type: "String" + }, + data: { + name: "data", + type: "Json" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + 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: "paymentMethods", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("payment_methods") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + ScheduledEvent: { + name: "ScheduledEvent", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + spaceId: { + name: "spaceId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + foreignKeyFor: [ + "space" + ] + }, + title: { + name: "title", + type: "String" + }, + description: { + name: "description", + type: "String", + optional: true + }, + location: { + name: "location", + type: "String", + optional: true + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + status: { + name: "status", + type: "ScheduledEventStatus", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("confirmed") }] }], + default: "confirmed" + }, + timeZone: { + name: "timeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + }, + start: { + name: "start", + type: "DateTime" + }, + end: { + name: "end", + type: "DateTime" + }, + allDay: { + name: "allDay", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("all_day") }] }], + default: false + }, + deletedAt: { + name: "deletedAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + }, + sequence: { + name: "sequence", + type: "Int", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], + default: 0 + }, + uid: { + name: "uid", + type: "String", + unique: true, + attributes: [{ name: "@unique" }] + }, + 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: "scheduledEvents", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + 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: "scheduledEvents", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } + }, + rescheduledDates: { + name: "rescheduledDates", + type: "RescheduledEventDate", + array: true, + relation: { opposite: "scheduledEvent" } + }, + invites: { + name: "invites", + type: "ScheduledEventInvite", + array: true, + relation: { opposite: "scheduledEvent" } + }, + polls: { + name: "polls", + type: "Poll", + array: true, + relation: { opposite: "scheduledEvent" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_events") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + uid: { type: "String" } + } + }, + RescheduledEventDate: { + name: "RescheduledEventDate", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + scheduledEventId: { + name: "scheduledEventId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + foreignKeyFor: [ + "scheduledEvent" + ] + }, + start: { + name: "start", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("start") }] }] + }, + end: { + name: "end", + type: "DateTime", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("end") }] }] + }, + allDay: { + name: "allDay", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("all_day") }] }], + default: false + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + scheduledEvent: { + name: "scheduledEvent", + type: "ScheduledEvent", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "rescheduledDates", fields: ["scheduledEventId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("scheduledEventId")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("rescheduled_event_dates") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + ScheduledEventInvite: { + name: "ScheduledEventInvite", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + scheduledEventId: { + name: "scheduledEventId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + foreignKeyFor: [ + "scheduledEvent" + ] + }, + inviteeName: { + name: "inviteeName", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_name") }] }] + }, + inviteeEmail: { + name: "inviteeEmail", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_email") }] }] + }, + inviteeId: { + name: "inviteeId", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + inviteeTimeZone: { + name: "inviteeTimeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_time_zone") }] }] + }, + status: { + name: "status", + type: "ScheduledEventInviteStatus", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("pending") }] }], + default: "pending" + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + scheduledEvent: { + name: "scheduledEvent", + type: "ScheduledEvent", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "invites", fields: ["scheduledEventId"], references: ["id"], onDelete: "Cascade" } + }, + user: { + name: "user", + type: "User", + optional: true, + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("inviteeId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + relation: { opposite: "scheduledEventInvites", fields: ["inviteeId"], references: ["id"], onDelete: "SetNull" } + } + }, + attributes: [ + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("scheduledEventId")]) }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("inviteeId")]) }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("inviteeEmail")]) }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_invites") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + Credential: { + name: "Credential", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + provider: { + name: "provider", + type: "String" + }, + providerAccountId: { + name: "providerAccountId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + }, + type: { + name: "type", + type: "CredentialType" + }, + secret: { + name: "secret", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("secret") }] }] + }, + scopes: { + name: "scopes", + type: "String", + array: true + }, + expiresAt: { + name: "expiresAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + calendarConnections: { + name: "calendarConnections", + type: "CalendarConnection", + array: true, + relation: { opposite: "credential" } + }, + 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: "credentials", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId"), ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }, { name: "name", value: ExpressionUtils.literal("user_provider_account_unique") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("expiresAt")]) }, { name: "name", value: ExpressionUtils.literal("credential_expiry_idx") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("credentials") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + user_provider_account_unique: { userId: { type: "String" }, provider: { type: "String" }, providerAccountId: { type: "String" } } + } + }, + CalendarConnection: { + name: "CalendarConnection", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + userId: { + name: "userId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + foreignKeyFor: [ + "user" + ] + }, + provider: { + name: "provider", + type: "String" + }, + integrationId: { + name: "integrationId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("integration_id") }] }] + }, + providerAccountId: { + name: "providerAccountId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + }, + email: { + name: "email", + type: "String" + }, + displayName: { + name: "displayName", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("display_name") }] }] + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + credential: { + name: "credential", + type: "Credential", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "calendarConnections", fields: ["credentialId"], references: ["id"], onDelete: "Cascade" } + }, + credentialId: { + name: "credentialId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("credential_id") }] }], + foreignKeyFor: [ + "credential" + ] + }, + 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: "calendarConnections", fields: ["userId"], references: ["id"], onDelete: "Cascade" } + }, + providerCalendars: { + name: "providerCalendars", + type: "ProviderCalendar", + array: true, + relation: { opposite: "calendarConnection" } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId"), ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }, { name: "name", value: ExpressionUtils.literal("user_provider_account_unique") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("calendar_connections") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + user_provider_account_unique: { userId: { type: "String" }, provider: { type: "String" }, providerAccountId: { type: "String" } } + } + }, + ProviderCalendar: { + name: "ProviderCalendar", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + calendarConnectionId: { + name: "calendarConnectionId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("calendar_connection_id") }] }], + foreignKeyFor: [ + "calendarConnection" + ] + }, + providerCalendarId: { + name: "providerCalendarId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_calendar_id") }] }] + }, + name: { + name: "name", + type: "String" + }, + isPrimary: { + name: "isPrimary", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("primary") }] }], + default: false + }, + timeZone: { + name: "timeZone", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + }, + isSelected: { + name: "isSelected", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("selected") }] }], + default: false + }, + isDeleted: { + name: "isDeleted", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted") }] }], + default: false + }, + isWritable: { + name: "isWritable", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("writable") }] }], + default: false + }, + providerData: { + name: "providerData", + type: "Json", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_data") }] }] + }, + lastSyncedAt: { + name: "lastSyncedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_synced_at") }] }], + default: ExpressionUtils.call("now") + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + }, + calendarConnection: { + name: "calendarConnection", + type: "CalendarConnection", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("calendarConnectionId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "providerCalendars", fields: ["calendarConnectionId"], references: ["id"], onDelete: "Cascade" } + }, + userDefaultDestination: { + name: "userDefaultDestination", + type: "User", + array: true, + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserDefaultDestinationCalendar") }] }], + relation: { opposite: "defaultDestinationCalendar", name: "UserDefaultDestinationCalendar" } + } + }, + attributes: [ + { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("calendarConnectionId"), ExpressionUtils.field("providerCalendarId")]) }, { name: "name", value: ExpressionUtils.literal("connection_calendar_unique") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("calendarConnectionId"), ExpressionUtils.field("isSelected")]) }, { name: "name", value: ExpressionUtils.literal("connection_selected_idx") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("isPrimary")]) }, { name: "name", value: ExpressionUtils.literal("primary_calendar_idx") }] }, + { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("lastSyncedAt")]) }, { name: "name", value: ExpressionUtils.literal("sync_time_idx") }] }, + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_calendars") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + connection_calendar_unique: { calendarConnectionId: { type: "String" }, providerCalendarId: { type: "String" } } + } + }, + InstanceSettings: { + name: "InstanceSettings", + fields: { + id: { + name: "id", + type: "Int", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], + default: 1 + }, + disableUserRegistration: { + name: "disableUserRegistration", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("disable_user_registration") }] }], + default: false + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }], + default: ExpressionUtils.call("now") + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("instance_settings") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "Int" } + } + }, + License: { + name: "License", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + licenseKey: { + name: "licenseKey", + type: "String", + unique: true, + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] + }, + version: { + name: "version", + type: "Int", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] + }, + type: { + name: "type", + type: "LicenseType" + }, + seats: { + name: "seats", + type: "Int", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] + }, + issuedAt: { + name: "issuedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("issued_at") }] }], + default: ExpressionUtils.call("now") + }, + expiresAt: { + name: "expiresAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + }, + licenseeEmail: { + name: "licenseeEmail", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] + }, + licenseeName: { + name: "licenseeName", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] + }, + status: { + name: "status", + type: "LicenseStatus", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACTIVE") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("status") }] }], + default: "ACTIVE" + }, + validations: { + name: "validations", + type: "LicenseValidation", + array: true, + relation: { opposite: "license" } + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("licenses") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + licenseKey: { type: "String" } + } + }, + LicenseValidation: { + name: "LicenseValidation", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + licenseId: { + name: "licenseId", + type: "String", + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_id") }] }], + foreignKeyFor: [ + "license" + ] + }, + license: { + name: "license", + type: "License", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("licenseId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "validations", fields: ["licenseId"], references: ["id"], onDelete: "Cascade" } + }, + ipAddress: { + name: "ipAddress", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] + }, + fingerprint: { + name: "fingerprint", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("fingerprint") }] }] + }, + validatedAt: { + name: "validatedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("validated_at") }] }], + default: ExpressionUtils.call("now") + }, + userAgent: { + name: "userAgent", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_agent") }] }] + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("license_validations") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + }, + InstanceLicense: { + name: "InstanceLicense", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + licenseKey: { + name: "licenseKey", + type: "String", + unique: true, + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] + }, + version: { + name: "version", + type: "Int", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] + }, + type: { + name: "type", + type: "LicenseType" + }, + seats: { + name: "seats", + type: "Int", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] + }, + issuedAt: { + name: "issuedAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("issued_at") }] }], + default: ExpressionUtils.call("now") + }, + expiresAt: { + name: "expiresAt", + type: "DateTime", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + }, + licenseeEmail: { + name: "licenseeEmail", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] + }, + licenseeName: { + name: "licenseeName", + type: "String", + optional: true, + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] + }, + status: { + name: "status", + type: "LicenseStatus", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACTIVE") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("status") }] }], + default: "ACTIVE" + } + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("instance_licenses") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + licenseKey: { type: "String" } + } + } + }, + enums: { + TimeFormat: { + values: { + hours12: "hours12", + hours24: "hours24" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("time_format") }] } + ] + }, + UserRole: { + values: { + admin: "admin", + user: "user" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("user_role") }] } + ] + }, + ParticipantVisibility: { + values: { + full: "full", + scoresOnly: "scoresOnly", + limited: "limited" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_visibility") }] } + ] + }, + PollStatus: { + values: { + live: "live", + paused: "paused", + finalized: "finalized" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_status") }] } + ] + }, + VoteType: { + values: { + yes: "yes", + no: "no", + ifNeedBe: "ifNeedBe" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("vote_type") }] } + ] + }, + SpaceMemberRole: { + values: { + ADMIN: "ADMIN", + MEMBER: "MEMBER" + } + }, + SpaceTier: { + values: { + hobby: "hobby", + pro: "pro" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("space_tiers") }] } + ] + }, + SubscriptionStatus: { + values: { + incomplete: "incomplete", + incomplete_expired: "incomplete_expired", + active: "active", + paused: "paused", + trialing: "trialing", + past_due: "past_due", + canceled: "canceled", + unpaid: "unpaid" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_status") }] } + ] + }, + SubscriptionInterval: { + values: { + month: "month", + year: "year" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_interval") }] } + ] + }, + ScheduledEventStatus: { + values: { + confirmed: "confirmed", + canceled: "canceled", + unconfirmed: "unconfirmed" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_status") }] } + ] + }, + ScheduledEventInviteStatus: { + values: { + pending: "pending", + accepted: "accepted", + declined: "declined", + tentative: "tentative" + }, + attributes: [ + { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_invite_status") }] } + ] + }, + CredentialType: { + values: { + OAUTH: "OAUTH" + } + }, + LicenseType: { + values: { + PLUS: "PLUS", + ORGANIZATION: "ORGANIZATION", + ENTERPRISE: "ENTERPRISE" + } + }, + LicenseStatus: { + values: { + ACTIVE: "ACTIVE", + REVOKED: "REVOKED" + } + } + }, + authType: "User", + plugins: {} +} as const satisfies SchemaDef; +export type SchemaType = typeof schema; diff --git a/tests/e2e/apps/rally/zenstack/schema.zmodel b/tests/e2e/apps/rally/zenstack/schema.zmodel new file mode 100644 index 00000000..f5a4dde4 --- /dev/null +++ b/tests/e2e/apps/rally/zenstack/schema.zmodel @@ -0,0 +1,12 @@ +import './models/user' +import './models/space' +import './models/poll' +import './models/instance-settings' +import './models/licensing' +import './models/integrations' +import './models/event' +import './models/billing' + +datasource db { + provider = "postgresql" +} diff --git a/tests/e2e/orm/client-api/name-mapping.test.ts b/tests/e2e/orm/client-api/name-mapping.test.ts index 6f279114..e1ba5430 100644 --- a/tests/e2e/orm/client-api/name-mapping.test.ts +++ b/tests/e2e/orm/client-api/name-mapping.test.ts @@ -157,6 +157,15 @@ describe('Name mapping tests', () => { role: 'USER', }); + // nested select + await expect( + db.user.findFirst({ + include: { posts: { where: { title: 'Post1' } } }, + }), + ).resolves.toMatchObject({ + posts: expect.arrayContaining([expect.objectContaining({ title: 'Post1', authorId: user.id })]), + }); + await expect( db.$qb.selectFrom('User').selectAll().where('email', '=', 'u1@test.com').executeTakeFirst(), ).resolves.toMatchObject({ @@ -199,6 +208,18 @@ describe('Name mapping tests', () => { title: 'Post1', }); + await expect( + db.$qb + .selectFrom('Post') + .innerJoin('User', (join) => join.onRef('User.id', '=', 'Post.authorId')) + .select(['User.email', 'Post.authorId', 'Post.title']) + .whereRef('Post.authorId', '=', 'User.id') + .executeTakeFirst(), + ).resolves.toMatchObject({ + authorId: user.id, + title: 'Post1', + }); + await expect( db.$qb .selectFrom('Post') diff --git a/tests/e2e/orm/schemas/name-mapping/schema.ts b/tests/e2e/orm/schemas/name-mapping/schema.ts index 97aa169a..b81c03ae 100644 --- a/tests/e2e/orm/schemas/name-mapping/schema.ts +++ b/tests/e2e/orm/schemas/name-mapping/schema.ts @@ -18,7 +18,7 @@ export const schema = { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], default: ExpressionUtils.call("autoincrement") }, email: { @@ -56,7 +56,7 @@ export const schema = { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("post_id") }] }], default: ExpressionUtils.call("autoincrement") }, title: { diff --git a/tests/e2e/orm/schemas/name-mapping/schema.zmodel b/tests/e2e/orm/schemas/name-mapping/schema.zmodel index 2dfbaeda..a5b45a63 100644 --- a/tests/e2e/orm/schemas/name-mapping/schema.zmodel +++ b/tests/e2e/orm/schemas/name-mapping/schema.zmodel @@ -11,7 +11,7 @@ enum Role { } model User { - id Int @id @default(autoincrement()) + id Int @id @default(autoincrement()) @map('user_id') email String @map('user_email') @unique role Role @default(USER) @map('user_role') posts Post[] @@ -19,7 +19,7 @@ model User { } model Post { - id Int @id @default(autoincrement()) + id Int @id @default(autoincrement()) @map('post_id') title String @map('post_title') author User @relation(fields: [authorId], references: [id]) authorId Int @map('author_id') diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 9748209c..c8d72b89 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "build": "pnpm test:generate && pnpm test:typecheck", - "test:generate": "tsx orm/scripts/generate.ts", + "test:generate": "tsx scripts/generate.ts", "test:typecheck": "tsc --noEmit", "test": "vitest run", "test:sqlite": "TEST_DB_PROVIDER=sqlite vitest run", diff --git a/tests/e2e/orm/scripts/generate.ts b/tests/e2e/scripts/generate.ts similarity index 78% rename from tests/e2e/orm/scripts/generate.ts rename to tests/e2e/scripts/generate.ts index 51ce6b5b..9d01fbe4 100644 --- a/tests/e2e/orm/scripts/generate.ts +++ b/tests/e2e/scripts/generate.ts @@ -8,7 +8,10 @@ import { fileURLToPath } from 'node:url'; const dir = path.dirname(fileURLToPath(import.meta.url)); async function main() { - const zmodelFiles = glob.sync(path.resolve(dir, '../schemas/**/*.zmodel')); + const zmodelFiles = [ + ...glob.sync(path.resolve(dir, '../orm/schemas/**/*.zmodel')), + ...glob.sync(path.resolve(dir, '../apps/**/schema.zmodel')), + ]; for (const file of zmodelFiles) { console.log(`Generating TS schema for: ${file}`); await generate(file); @@ -23,7 +26,7 @@ async function generate(schemaPath: string) { const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)); // plugin models - const pluginDocs = [path.resolve(_dirname, '../../node_modules/@zenstackhq/plugin-policy/plugin.zmodel')]; + const pluginDocs = [path.resolve(_dirname, '../node_modules/@zenstackhq/plugin-policy/plugin.zmodel')]; const result = await loadDocument(schemaPath, pluginDocs); if (!result.success) {