diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 69d9056e7..33dd30733 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -8,6 +8,7 @@ on: env: TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }} + VSCODE_TELEMETRY_TRACKING_TOKEN: ${{ secrets.VSCODE_TELEMETRY_TRACKING_TOKEN }} DO_NOT_TRACK: '1' permissions: diff --git a/README.md b/README.md index 859364b29..871dc8a7a 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ ZenStack is a TypeScript database toolkit for developing full-stack or backend N - 🧩 Designed for extensibility and flexibility - ⚙️ Automatic CRUD web APIs with adapters for popular frameworks - 🏖️ Automatic [TanStack Query](https://github.com/TanStack/query) hooks for easy CRUD from the frontend +- 💎 [Zod](https://zod.dev) schema generation # What's New in V3 @@ -111,3 +112,23 @@ Thank you for your generous support! # Community Join our [discord server](https://discord.gg/Ykhr738dUe) for chat and updates! + +# Contributors + +Thanks to all the contributors who have helped make ZenStack better! + +### Source + + + + + +### Docs + + + + + +## License + +[MIT](LICENSE) diff --git a/package.json b/package.json index 419fa65b4..dad6b22a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-v3", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack", "packageManager": "pnpm@10.23.0", "type": "module", diff --git a/packages/auth-adapters/better-auth/package.json b/packages/auth-adapters/better-auth/package.json index 56e06ce41..b95ba687c 100644 --- a/packages/auth-adapters/better-auth/package.json +++ b/packages/auth-adapters/better-auth/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/better-auth", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Better Auth Adapter. This adapter is modified from better-auth's Prisma adapter.", "type": "module", "scripts": { diff --git a/packages/cli/README.md b/packages/cli/README.md new file mode 100644 index 000000000..7adc0ae1a --- /dev/null +++ b/packages/cli/README.md @@ -0,0 +1,24 @@ +# @zenstackhq/cli + +The command-line interface for ZenStack. Provides commands for initializing projects, generating TypeScript code from ZModel schemas, managing database migrations, and etc. + +## Key Commands + +- `zenstack init` — Initialize ZenStack in an existing project +- `zenstack generate` — Compile ZModel schema to TypeScript +- `zenstack db push` — Sync schema to the database +- `zenstack db pull` — Pull database schema changes into ZModel +- `zenstack migrate dev` — Create and apply database migrations +- `zenstack migrate deploy` — Deploy migrations to production +- `zenstack format` — Format ZModel schema files +- `zenstack proxy|studio` — Start a database proxy server for using studio + +## Installation + +```bash +npm install -D @zenstackhq/cli +``` + +## Learn More + +- [ZenStack Documentation](https://zenstack.dev/docs) diff --git a/packages/cli/package.json b/packages/cli/package.json index b1bdb6b05..02ebb3c6c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack CLI", "description": "FullStack database toolkit with built-in access control and automatic API generation.", - "version": "3.4.6", + "version": "3.5.0", "type": "module", "author": { "name": "ZenStack Team" diff --git a/packages/cli/src/actions/action-utils.ts b/packages/cli/src/actions/action-utils.ts index aed343193..5f18f9be4 100644 --- a/packages/cli/src/actions/action-utils.ts +++ b/packages/cli/src/actions/action-utils.ts @@ -291,6 +291,14 @@ export async function loadPluginModule(provider: string, basePath: string) { } } + // try jiti import for bare package specifiers (handles workspace packages) + try { + const result = (await jiti.import(moduleSpec, { default: true })) as CliPlugin; + return result; + } catch { + // fall through to last resort + } + // last resort, try to import as esm directly try { const mod = await import(moduleSpec); diff --git a/packages/cli/src/actions/check.ts b/packages/cli/src/actions/check.ts index a7f765f36..61f12c57f 100644 --- a/packages/cli/src/actions/check.ts +++ b/packages/cli/src/actions/check.ts @@ -29,7 +29,9 @@ async function checkPluginResolution(schemaFile: string, model: Model) { for (const plugin of plugins) { const provider = getPluginProvider(plugin); if (!provider.startsWith('@core/')) { - await loadPluginModule(provider, path.dirname(schemaFile)); + const pluginSourcePath = + plugin.$cstNode?.parent?.element.$document?.uri?.fsPath ?? schemaFile; + await loadPluginModule(provider, path.dirname(pluginSourcePath)); } } } diff --git a/packages/cli/src/actions/generate.ts b/packages/cli/src/actions/generate.ts index ce499ef11..e65747405 100644 --- a/packages/cli/src/actions/generate.ts +++ b/packages/cli/src/actions/generate.ts @@ -186,7 +186,11 @@ async function runPlugins(schemaFile: string, model: Model, outputPath: string, throw new CliError(`Unknown core plugin: ${provider}`); } } else { - cliPlugin = await loadPluginModule(provider, path.dirname(schemaFile)); + // resolve relative plugin paths against the schema file where the plugin is declared, + // not the entry schema file + const pluginSourcePath = + plugin.$cstNode?.parent?.element.$document?.uri?.fsPath ?? schemaFile; + cliPlugin = await loadPluginModule(provider, path.dirname(pluginSourcePath)); } if (cliPlugin) { @@ -252,7 +256,7 @@ async function runPlugins(schemaFile: string, model: Model, outputPath: string, spinner?.succeed(); } catch (err) { spinner?.fail(); - console.error(err); + throw err; } } } diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index bdeca9b5d..f187ad93c 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,7 +1,7 @@ -import 'dotenv/config'; import { ZModelLanguageMetaData } from '@zenstackhq/language'; import colors from 'colors'; import { Command, CommanderError, Option } from 'commander'; +import 'dotenv/config'; import * as actions from './actions'; import { CliError } from './cli-error'; import { telemetry } from './telemetry'; diff --git a/packages/cli/test/generate.test.ts b/packages/cli/test/generate.test.ts index 291f0e734..9cc31ba96 100644 --- a/packages/cli/test/generate.test.ts +++ b/packages/cli/test/generate.test.ts @@ -1,7 +1,8 @@ +import { formatDocument } from '@zenstackhq/language'; import fs from 'node:fs'; import path from 'node:path'; import { describe, expect, it } from 'vitest'; -import { createProject, runCli } from './utils'; +import { createProject, getDefaultPrelude, runCli } from './utils'; const model = ` model User { @@ -272,6 +273,84 @@ model User { expect(fs.existsSync(path.join(workDir, 'zenstack/schema.ts'))).toBe(true); }); + it('should load plugin from a bare package specifier via jiti', async () => { + const modelWithBarePlugin = ` +plugin foo { + provider = 'my-test-plugin' +} + +model User { + id String @id @default(cuid()) +} +`; + const { workDir } = await createProject(modelWithBarePlugin); + // Create a fake node_modules package with a TS entry point + // This can only be resolved by jiti, not by native import() or fs.existsSync checks + const pkgDir = path.join(workDir, 'node_modules/my-test-plugin'); + fs.mkdirSync(pkgDir, { recursive: true }); + fs.writeFileSync( + path.join(pkgDir, 'package.json'), + JSON.stringify({ name: 'my-test-plugin', main: './index.ts' }), + ); + fs.writeFileSync( + path.join(pkgDir, 'index.ts'), + ` +const plugin = { + name: 'test-bare-plugin', + statusText: 'Testing bare plugin', + async generate() {}, +}; +export default plugin; +`, + ); + runCli('generate', workDir); + expect(fs.existsSync(path.join(workDir, 'zenstack/schema.ts'))).toBe(true); + }); + + it('should resolve plugin paths relative to the schema file where the plugin is declared', async () => { + // Entry schema imports a sub-schema that declares a plugin with a relative path. + // The plugin path should resolve relative to the sub-schema, not the entry schema. + const { workDir } = await createProject( + `import './core/core' + +${getDefaultPrelude()} + +model User { + id String @id @default(cuid()) +} +`, + { customPrelude: true }, + ); + + // Create core/ subdirectory with its own schema and plugin + const coreDir = path.join(workDir, 'zenstack/core'); + fs.mkdirSync(coreDir, { recursive: true }); + + const coreSchema = await formatDocument(` +plugin foo { + provider = './my-core-plugin.ts' +} +`); + fs.writeFileSync(path.join(coreDir, 'core.zmodel'), coreSchema); + + // Plugin lives next to the core schema, NOT next to the entry schema + fs.writeFileSync( + path.join(coreDir, 'my-core-plugin.ts'), + ` +const plugin = { + name: 'core-plugin', + statusText: 'Testing core plugin', + async generate() {}, +}; +export default plugin; +`, + ); + + // This would fail if the plugin path was resolved relative to the entry schema + runCli('generate', workDir); + expect(fs.existsSync(path.join(workDir, 'zenstack/schema.ts'))).toBe(true); + }); + it('should prefer CLI options over @core/typescript plugin settings for generateModels and generateInput', async () => { const modelWithPlugin = ` plugin typescript { diff --git a/packages/clients/client-helpers/package.json b/packages/clients/client-helpers/package.json index 384a8915e..0b35d8bab 100644 --- a/packages/clients/client-helpers/package.json +++ b/packages/clients/client-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/client-helpers", - "version": "3.4.6", + "version": "3.5.0", "description": "Helpers for implementing clients that consume ZenStack's CRUD service", "type": "module", "scripts": { diff --git a/packages/clients/client-helpers/src/types.ts b/packages/clients/client-helpers/src/types.ts index da66f9483..5f30ac613 100644 --- a/packages/clients/client-helpers/src/types.ts +++ b/packages/clients/client-helpers/src/types.ts @@ -1,8 +1,28 @@ +import type { ClientContract, QueryOptions } from '@zenstackhq/orm'; +import type { SchemaDef } from '@zenstackhq/schema'; + /** * A type that represents either a value of type T or a Promise that resolves to type T. */ export type MaybePromise = T | Promise | PromiseLike; +/** + * Infers the schema definition from a client contract type, or passes through a raw SchemaDef. + */ +export type InferSchema = T extends { $schema: infer S extends SchemaDef } ? S : T extends SchemaDef ? T : never; + +/** + * Extracts the ExtResult type from a client contract, or defaults to `{}`. + */ +export type InferExtResult = T extends ClientContract ? E : {}; + +/** + * Infers query options from a client contract type, or defaults to `QueryOptions`. + */ +export type InferOptions = T extends { $options: infer O extends QueryOptions } + ? O + : QueryOptions; + /** * List of ORM write actions. */ diff --git a/packages/clients/tanstack-query/package.json b/packages/clients/tanstack-query/package.json index f3fa224ac..21533de8e 100644 --- a/packages/clients/tanstack-query/package.json +++ b/packages/clients/tanstack-query/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/tanstack-query", - "version": "3.4.6", + "version": "3.5.0", "description": "TanStack Query Client for consuming ZenStack v3's CRUD service", "type": "module", "scripts": { diff --git a/packages/clients/tanstack-query/src/common/types.ts b/packages/clients/tanstack-query/src/common/types.ts index f745ceeb4..a967869ed 100644 --- a/packages/clients/tanstack-query/src/common/types.ts +++ b/packages/clients/tanstack-query/src/common/types.ts @@ -3,11 +3,12 @@ import type { FetchFn } from '@zenstackhq/client-helpers/fetch'; import type { GetProcedureNames, GetSlicedOperations, - OperationsIneligibleForDelegateModels, + ModelAllowsCreate, + OperationsRequiringCreate, ProcedureFunc, QueryOptions, } from '@zenstackhq/orm'; -import type { GetModels, IsDelegateModel, SchemaDef } from '@zenstackhq/schema'; +import type { GetModels, SchemaDef } from '@zenstackhq/schema'; /** * Context type for configuring the hooks. @@ -59,8 +60,8 @@ export type ExtraMutationOptions = { optimisticDataProvider?: OptimisticDataProvider; } & QueryContext; -type HooksOperationsIneligibleForDelegateModels = OperationsIneligibleForDelegateModels extends any - ? `use${Capitalize}` +type HooksOperationsRequiringCreate = OperationsRequiringCreate extends any + ? `use${Capitalize}` : never; type Modifiers = '' | 'Suspense' | 'Infinite' | 'SuspenseInfinite'; @@ -76,12 +77,12 @@ export type TrimSlicedOperations< > = { // trim operations based on slicing options [Key in keyof T as Key extends `use${Modifiers}${Capitalize>}` - ? IsDelegateModel extends true - ? // trim operations ineligible for delegate models - Key extends HooksOperationsIneligibleForDelegateModels - ? never - : Key - : Key + ? ModelAllowsCreate extends true + ? Key + : // trim create operations for models that don't allow create + Key extends HooksOperationsRequiringCreate + ? never + : Key : never]: T[Key]; }; diff --git a/packages/clients/tanstack-query/src/react.ts b/packages/clients/tanstack-query/src/react.ts index 5129750bf..e84aa7e09 100644 --- a/packages/clients/tanstack-query/src/react.ts +++ b/packages/clients/tanstack-query/src/react.ts @@ -19,13 +19,14 @@ import { type UseSuspenseQueryOptions, type UseSuspenseQueryResult, } from '@tanstack/react-query'; -import { createInvalidator, createOptimisticUpdater, DEFAULT_QUERY_ENDPOINT } from '@zenstackhq/client-helpers'; +import { createInvalidator, createOptimisticUpdater, DEFAULT_QUERY_ENDPOINT, type InferExtResult, type InferOptions, type InferSchema } from '@zenstackhq/client-helpers'; import { fetcher, makeUrl, marshal } from '@zenstackhq/client-helpers/fetch'; import { lowerCaseFirst } from '@zenstackhq/common-helpers'; import type { AggregateArgs, AggregateResult, BatchResult, + ClientContract, CountArgs, CountResult, CreateArgs, @@ -34,6 +35,7 @@ import type { DeleteArgs, DeleteManyArgs, ExistsArgs, + ExtResultBase, FindFirstArgs, FindManyArgs, FindUniqueArgs, @@ -68,6 +70,8 @@ import type { WithOptimistic, } from './common/types.js'; export type { FetchFn } from '@zenstackhq/client-helpers/fetch'; +export type { InferExtResult, InferOptions, InferSchema } from '@zenstackhq/client-helpers'; +export type { SchemaDef } from '@zenstackhq/schema'; type ProcedureHookFn< Schema extends SchemaDef, @@ -142,15 +146,20 @@ export type ModelMutationModelResult< TArgs, Array extends boolean = false, Options extends QueryOptions = QueryOptions, -> = Omit, TArgs>, 'mutateAsync'> & { + ExtResult extends ExtResultBase = {}, +> = Omit, TArgs>, 'mutateAsync'> & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions, T>, + ): Promise>; }; -export type ClientHooks = QueryOptions> = { - [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; +export type ClientHooks< + Schema extends SchemaDef, + Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, +> = { + [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; } & ProcedureHooks; type ProcedureHookGroup> = { @@ -213,87 +222,88 @@ export type ModelQueryHooks< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, > = TrimSlicedOperations< Schema, Model, Options, { - useFindUnique>( - args: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; - - useSuspenseFindUnique>( - args: SelectSubset>, - options?: ModelSuspenseQueryOptions | null>, - ): ModelSuspenseQueryResult | null>; - - useFindFirst>( - args?: SelectSubset>, - options?: ModelQueryOptions | null>, - ): ModelQueryResult | null>; - - useSuspenseFindFirst>( - args?: SelectSubset>, - options?: ModelSuspenseQueryOptions | null>, - ): ModelSuspenseQueryResult | null>; + useFindUnique>( + args: SelectSubset>, + options?: ModelQueryOptions | null>, + ): ModelQueryResult | null>; + + useSuspenseFindUnique>( + args: SelectSubset>, + options?: ModelSuspenseQueryOptions | null>, + ): ModelSuspenseQueryResult | null>; + + useFindFirst>( + args?: SelectSubset>, + options?: ModelQueryOptions | null>, + ): ModelQueryResult | null>; + + useSuspenseFindFirst>( + args?: SelectSubset>, + options?: ModelSuspenseQueryOptions | null>, + ): ModelSuspenseQueryResult | null>; useExists>( args?: Subset>, options?: ModelQueryOptions, ): ModelQueryResult; - useFindMany>( - args?: SelectSubset>, - options?: ModelQueryOptions[]>, - ): ModelQueryResult[]>; + useFindMany>( + args?: SelectSubset>, + options?: ModelQueryOptions[]>, + ): ModelQueryResult[]>; - useSuspenseFindMany>( - args?: SelectSubset>, - options?: ModelSuspenseQueryOptions[]>, - ): ModelSuspenseQueryResult[]>; + useSuspenseFindMany>( + args?: SelectSubset>, + options?: ModelSuspenseQueryOptions[]>, + ): ModelSuspenseQueryResult[]>; - useInfiniteFindMany>( - args?: SelectSubset>, - options?: ModelInfiniteQueryOptions[]>, - ): ModelInfiniteQueryResult[]>>; + useInfiniteFindMany>( + args?: SelectSubset>, + options?: ModelInfiniteQueryOptions[]>, + ): ModelInfiniteQueryResult[]>>; - useSuspenseInfiniteFindMany>( - args?: SelectSubset>, - options?: ModelSuspenseInfiniteQueryOptions[]>, - ): ModelSuspenseInfiniteQueryResult[]>>; + useSuspenseInfiniteFindMany>( + args?: SelectSubset>, + options?: ModelSuspenseInfiniteQueryOptions[]>, + ): ModelSuspenseInfiniteQueryResult[]>>; - useCreate>( - options?: ModelMutationOptions, T>, - ): ModelMutationModelResult; + useCreate>( + options?: ModelMutationOptions, T>, + ): ModelMutationModelResult; useCreateMany>( options?: ModelMutationOptions, ): ModelMutationResult; - useCreateManyAndReturn>( - options?: ModelMutationOptions[], T>, - ): ModelMutationModelResult; + useCreateManyAndReturn>( + options?: ModelMutationOptions[], T>, + ): ModelMutationModelResult; - useUpdate>( - options?: ModelMutationOptions, T>, - ): ModelMutationModelResult; + useUpdate>( + options?: ModelMutationOptions, T>, + ): ModelMutationModelResult; useUpdateMany>( options?: ModelMutationOptions, ): ModelMutationResult; - useUpdateManyAndReturn>( - options?: ModelMutationOptions[], T>, - ): ModelMutationModelResult; + useUpdateManyAndReturn>( + options?: ModelMutationOptions[], T>, + ): ModelMutationModelResult; - useUpsert>( - options?: ModelMutationOptions, T>, - ): ModelMutationModelResult; + useUpsert>( + options?: ModelMutationOptions, T>, + ): ModelMutationModelResult; - useDelete>( - options?: ModelMutationOptions, T>, - ): ModelMutationModelResult; + useDelete>( + options?: ModelMutationOptions, T>, + ): ModelMutationModelResult; useDeleteMany>( options?: ModelMutationOptions, @@ -334,23 +344,38 @@ export type ModelQueryHooks< /** * Gets data query hooks for all models in the schema. * + * Accepts either a raw `SchemaDef` or a `ClientContract` type (e.g. `typeof db`) as the generic parameter. + * When a `ClientContract` type is provided, computed fields from plugins are reflected in the result types. + * + * @example + * ```typescript + * // Basic usage with schema + * const client = useClientQueries(schema) + * + * // With server client type for computed field support + * import type { DbType } from '~/server/db' + * const client = useClientQueries(schema) + * ``` + * * @param schema The schema. * @param options Options for all queries originated from this hook. */ -export function useClientQueries = QueryOptions>( - schema: Schema, +export function useClientQueries< + SchemaOrClient extends SchemaDef | ClientContract, +>( + schema: InferSchema, options?: QueryContext, -): ClientHooks { +): ClientHooks, InferOptions>, InferExtResult extends ExtResultBase> ? InferExtResult : {}> { const result = Object.keys(schema.models).reduce( (acc, model) => { - (acc as any)[lowerCaseFirst(model)] = useModelQueries, Options>( - schema, - model as GetModels, + (acc as any)[lowerCaseFirst(model)] = useModelQueries( + schema as any, + model as any, options, ); return acc; }, - {} as ClientHooks, + {} as any, ); const procedures = (schema as any).procedures as Record | undefined; @@ -407,7 +432,8 @@ export function useModelQueries< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions, ->(schema: Schema, model: Model, rootOptions?: QueryContext): ModelQueryHooks { + ExtResult extends ExtResultBase = {}, +>(schema: Schema, model: Model, rootOptions?: QueryContext): ModelQueryHooks { const modelDef = Object.values(schema.models).find((m) => m.name.toLowerCase() === model.toLowerCase()); if (!modelDef) { throw new Error(`Model "${model}" not found in schema`); @@ -517,7 +543,7 @@ export function useModelQueries< useSuspenseGroupBy: (args: any, options?: any) => { return useInternalSuspenseQuery(schema, modelName, 'groupBy', args, { ...rootOptions, ...options }); }, - } as ModelQueryHooks; + } as ModelQueryHooks; } export function useInternalQuery( diff --git a/packages/clients/tanstack-query/src/svelte/index.svelte.ts b/packages/clients/tanstack-query/src/svelte/index.svelte.ts index 45af47cb3..9ddfe40e2 100644 --- a/packages/clients/tanstack-query/src/svelte/index.svelte.ts +++ b/packages/clients/tanstack-query/src/svelte/index.svelte.ts @@ -19,6 +19,9 @@ import { createInvalidator, createOptimisticUpdater, DEFAULT_QUERY_ENDPOINT, + type InferExtResult, + type InferOptions, + type InferSchema, type InvalidationPredicate, } from '@zenstackhq/client-helpers'; import { fetcher, makeUrl, marshal } from '@zenstackhq/client-helpers/fetch'; @@ -27,6 +30,7 @@ import type { AggregateArgs, AggregateResult, BatchResult, + ClientContract, CountArgs, CountResult, CreateArgs, @@ -35,6 +39,7 @@ import type { DeleteArgs, DeleteManyArgs, ExistsArgs, + ExtResultBase, FindFirstArgs, FindManyArgs, FindUniqueArgs, @@ -69,6 +74,8 @@ import type { WithOptimistic, } from '../common/types.js'; export type { FetchFn } from '@zenstackhq/client-helpers/fetch'; +export type { InferExtResult, InferOptions, InferSchema } from '@zenstackhq/client-helpers'; +export type { SchemaDef } from '@zenstackhq/schema'; type ProcedureHookFn< Schema extends SchemaDef, @@ -139,15 +146,20 @@ export type ModelMutationModelResult< TArgs, Array extends boolean = false, Options extends QueryOptions = QueryOptions, -> = Omit, TArgs>, 'mutateAsync'> & { + ExtResult extends ExtResultBase = {}, +> = Omit, TArgs>, 'mutateAsync'> & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions, T>, + ): Promise>; }; -export type ClientHooks = QueryOptions> = { - [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; +export type ClientHooks< + Schema extends SchemaDef, + Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, +> = { + [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; } & ProcedureHooks; type ProcedureHookGroup> = { @@ -200,65 +212,66 @@ export type ModelQueryHooks< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, > = TrimSlicedOperations< Schema, Model, Options, { - useFindUnique>( - args: Accessor>>, - options?: Accessor | null>>, - ): ModelQueryResult | null>; + useFindUnique>( + args: Accessor>>, + options?: Accessor | null>>, + ): ModelQueryResult | null>; - useFindFirst>( - args?: Accessor>>, - options?: Accessor | null>>, - ): ModelQueryResult | null>; + useFindFirst>( + args?: Accessor>>, + options?: Accessor | null>>, + ): ModelQueryResult | null>; useExists>( args?: Accessor>>, options?: Accessor>, ): ModelQueryResult; - useFindMany>( - args?: Accessor>>, - options?: Accessor[]>>, - ): ModelQueryResult[]>; + useFindMany>( + args?: Accessor>>, + options?: Accessor[]>>, + ): ModelQueryResult[]>; - useInfiniteFindMany>( - args?: Accessor>>, - options?: Accessor[]>>, - ): ModelInfiniteQueryResult[]>>; + useInfiniteFindMany>( + args?: Accessor>>, + options?: Accessor[]>>, + ): ModelInfiniteQueryResult[]>>; - useCreate>( - options?: Accessor, T>>, - ): ModelMutationModelResult; + useCreate>( + options?: Accessor, T>>, + ): ModelMutationModelResult; useCreateMany>( options?: Accessor>, ): ModelMutationResult; - useCreateManyAndReturn>( - options?: Accessor[], T>>, - ): ModelMutationModelResult; + useCreateManyAndReturn>( + options?: Accessor[], T>>, + ): ModelMutationModelResult; - useUpdate>( - options?: Accessor, T>>, - ): ModelMutationModelResult; + useUpdate>( + options?: Accessor, T>>, + ): ModelMutationModelResult; useUpdateMany>( options?: Accessor>, ): ModelMutationResult; - useUpdateManyAndReturn>( - options?: Accessor[], T>>, - ): ModelMutationModelResult; + useUpdateManyAndReturn>( + options?: Accessor[], T>>, + ): ModelMutationModelResult; - useUpsert>( - options?: Accessor, T>>, - ): ModelMutationModelResult; - useDelete>( - options?: Accessor, T>>, - ): ModelMutationModelResult; + useUpsert>( + options?: Accessor, T>>, + ): ModelMutationModelResult; + useDelete>( + options?: Accessor, T>>, + ): ModelMutationModelResult; useDeleteMany>( options?: Accessor>, @@ -283,21 +296,36 @@ export type ModelQueryHooks< /** * Gets data query hooks for all models in the schema. + * + * Accepts either a raw `SchemaDef` or a `ClientContract` type (e.g. `typeof db`) as the generic parameter. + * When a `ClientContract` type is provided, computed fields from plugins are reflected in the result types. + * + * @example + * ```typescript + * // Basic usage with schema + * const client = useClientQueries(schema) + * + * // With server client type for computed field support + * import type { DbType } from '~/server/db' + * const client = useClientQueries(schema) + * ``` */ -export function useClientQueries = QueryOptions>( - schema: Schema, +export function useClientQueries< + SchemaOrClient extends SchemaDef | ClientContract, +>( + schema: InferSchema, options?: Accessor, -): ClientHooks { +): ClientHooks, InferOptions>, InferExtResult extends ExtResultBase> ? InferExtResult : {}> { const result = Object.keys(schema.models).reduce( (acc, model) => { - (acc as any)[lowerCaseFirst(model)] = useModelQueries, Options>( - schema, - model as GetModels, + (acc as any)[lowerCaseFirst(model)] = useModelQueries( + schema as any, + model as any, options, ); return acc; }, - {} as ClientHooks, + {} as any, ); const procedures = (schema as any).procedures as Record | undefined; @@ -347,7 +375,8 @@ export function useModelQueries< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions, ->(schema: Schema, model: Model, rootOptions?: Accessor): ModelQueryHooks { + ExtResult extends ExtResultBase = {}, +>(schema: Schema, model: Model, rootOptions?: Accessor): ModelQueryHooks { const modelDef = Object.values(schema.models).find((m) => m.name.toLowerCase() === model.toLowerCase()); if (!modelDef) { throw new Error(`Model "${model}" not found in schema`); @@ -423,7 +452,7 @@ export function useModelQueries< useGroupBy: (args: any, options?: any) => { return useInternalQuery(schema, modelName, 'groupBy', args, options); }, - } as unknown as ModelQueryHooks; + } as unknown as ModelQueryHooks; } export function useInternalQuery( diff --git a/packages/clients/tanstack-query/src/vue.ts b/packages/clients/tanstack-query/src/vue.ts index b45a28333..4b0e8a682 100644 --- a/packages/clients/tanstack-query/src/vue.ts +++ b/packages/clients/tanstack-query/src/vue.ts @@ -17,6 +17,9 @@ import { createInvalidator, createOptimisticUpdater, DEFAULT_QUERY_ENDPOINT, + type InferExtResult, + type InferOptions, + type InferSchema, type InvalidationPredicate, } from '@zenstackhq/client-helpers'; import { fetcher, makeUrl, marshal } from '@zenstackhq/client-helpers/fetch'; @@ -25,6 +28,7 @@ import type { AggregateArgs, AggregateResult, BatchResult, + ClientContract, CountArgs, CountResult, CreateArgs, @@ -33,6 +37,7 @@ import type { DeleteArgs, DeleteManyArgs, ExistsArgs, + ExtResultBase, FindFirstArgs, FindManyArgs, FindUniqueArgs, @@ -67,6 +72,9 @@ import type { WithOptimistic, } from './common/types.js'; export type { FetchFn } from '@zenstackhq/client-helpers/fetch'; +export type { InferExtResult, InferOptions, InferSchema } from '@zenstackhq/client-helpers'; +export type { SchemaDef } from '@zenstackhq/schema'; + export const VueQueryContextKey = 'zenstack-vue-query-context'; type ProcedureHookFn< @@ -129,18 +137,23 @@ export type ModelMutationModelResult< TArgs, Array extends boolean = false, Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, > = Omit< - ModelMutationResult, false, Array>, TArgs>, + ModelMutationResult, TArgs>, 'mutateAsync' > & { mutateAsync( args: T, - options?: ModelMutationOptions, T>, - ): Promise>; + options?: ModelMutationOptions, T>, + ): Promise>; }; -export type ClientHooks = QueryOptions> = { - [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; +export type ClientHooks< + Schema extends SchemaDef, + Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, +> = { + [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; } & ProcedureHooks; type ProcedureHookGroup> = { @@ -202,67 +215,68 @@ export type ModelQueryHooks< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions = QueryOptions, + ExtResult extends ExtResultBase = {}, > = TrimSlicedOperations< Schema, Model, Options, { - useFindUnique>( - args: MaybeRefOrGetter>>, - options?: MaybeRefOrGetter | null>>, - ): ModelQueryResult | null>; + useFindUnique>( + args: MaybeRefOrGetter>>, + options?: MaybeRefOrGetter | null>>, + ): ModelQueryResult | null>; - useFindFirst>( - args?: MaybeRefOrGetter>>, - options?: MaybeRefOrGetter | null>>, - ): ModelQueryResult | null>; + useFindFirst>( + args?: MaybeRefOrGetter>>, + options?: MaybeRefOrGetter | null>>, + ): ModelQueryResult | null>; useExists>( args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter>, ): ModelQueryResult; - useFindMany>( - args?: MaybeRefOrGetter>>, - options?: MaybeRefOrGetter[]>>, - ): ModelQueryResult[]>; + useFindMany>( + args?: MaybeRefOrGetter>>, + options?: MaybeRefOrGetter[]>>, + ): ModelQueryResult[]>; - useInfiniteFindMany>( - args?: MaybeRefOrGetter>>, - options?: MaybeRefOrGetter[]>>, - ): ModelInfiniteQueryResult[]>>; + useInfiniteFindMany>( + args?: MaybeRefOrGetter>>, + options?: MaybeRefOrGetter[]>>, + ): ModelInfiniteQueryResult[]>>; - useCreate>( - options?: MaybeRefOrGetter, T>>, - ): ModelMutationModelResult; + useCreate>( + options?: MaybeRefOrGetter, T>>, + ): ModelMutationModelResult; useCreateMany>( options?: MaybeRefOrGetter>, ): ModelMutationResult; - useCreateManyAndReturn>( - options?: MaybeRefOrGetter[], T>>, - ): ModelMutationModelResult; + useCreateManyAndReturn>( + options?: MaybeRefOrGetter[], T>>, + ): ModelMutationModelResult; - useUpdate>( - options?: MaybeRefOrGetter, T>>, - ): ModelMutationModelResult; + useUpdate>( + options?: MaybeRefOrGetter, T>>, + ): ModelMutationModelResult; useUpdateMany>( options?: MaybeRefOrGetter>, ): ModelMutationResult; - useUpdateManyAndReturn>( - options?: MaybeRefOrGetter[], T>>, - ): ModelMutationModelResult; + useUpdateManyAndReturn>( + options?: MaybeRefOrGetter[], T>>, + ): ModelMutationModelResult; - useUpsert>( - options?: MaybeRefOrGetter, T>>, - ): ModelMutationModelResult; + useUpsert>( + options?: MaybeRefOrGetter, T>>, + ): ModelMutationModelResult; - useDelete>( - options?: MaybeRefOrGetter, T>>, - ): ModelMutationModelResult; + useDelete>( + options?: MaybeRefOrGetter, T>>, + ): ModelMutationModelResult; useDeleteMany>( options?: MaybeRefOrGetter>, @@ -287,11 +301,26 @@ export type ModelQueryHooks< /** * Gets data query hooks for all models in the schema. + * + * Accepts either a raw `SchemaDef` or a `ClientContract` type (e.g. `typeof db`) as the generic parameter. + * When a `ClientContract` type is provided, computed fields from plugins are reflected in the result types. + * + * @example + * ```typescript + * // Basic usage with schema + * const client = useClientQueries(schema) + * + * // With server client type for computed field support + * import type { DbType } from '~/server/db' + * const client = useClientQueries(schema) + * ``` */ -export function useClientQueries = QueryOptions>( - schema: Schema, +export function useClientQueries< + SchemaOrClient extends SchemaDef | ClientContract, +>( + schema: InferSchema, options?: MaybeRefOrGetter, -): ClientHooks { +): ClientHooks, InferOptions>, InferExtResult extends ExtResultBase> ? InferExtResult : {}> { const merge = (rootOpt: MaybeRefOrGetter | undefined, opt: MaybeRefOrGetter | undefined): any => { return computed(() => { const rootVal = toValue(rootOpt) ?? {}; @@ -302,14 +331,14 @@ export function useClientQueries { - (acc as any)[lowerCaseFirst(model)] = useModelQueries, Options>( - schema, - model as GetModels, + (acc as any)[lowerCaseFirst(model)] = useModelQueries( + schema as any, + model as any, options, ); return acc; }, - {} as ClientHooks, + {} as any, ); const procedures = (schema as any).procedures as Record | undefined; @@ -359,7 +388,8 @@ export function useModelQueries< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions, ->(schema: Schema, model: Model, rootOptions?: MaybeRefOrGetter): ModelQueryHooks { + ExtResult extends ExtResultBase = {}, +>(schema: Schema, model: Model, rootOptions?: MaybeRefOrGetter): ModelQueryHooks { const modelDef = Object.values(schema.models).find((m) => m.name.toLowerCase() === model.toLowerCase()); if (!modelDef) { throw new Error(`Model "${model}" not found in schema`); @@ -441,7 +471,7 @@ export function useModelQueries< useGroupBy: (args: any, options?: any) => { return useInternalQuery(schema, modelName, 'groupBy', args, merge(rootOptions, options)); }, - } as ModelQueryHooks; + } as ModelQueryHooks; } export function useInternalQuery( diff --git a/packages/clients/tanstack-query/test/react-sliced-client.test-d.ts b/packages/clients/tanstack-query/test/react-sliced-client.test-d.ts index 8b31551d7..78b2eca0a 100644 --- a/packages/clients/tanstack-query/test/react-sliced-client.test-d.ts +++ b/packages/clients/tanstack-query/test/react-sliced-client.test-d.ts @@ -1,4 +1,4 @@ -import { ZenStackClient, type GetQueryOptions } from '@zenstackhq/orm'; +import { ZenStackClient } from '@zenstackhq/orm'; import { describe, expectTypeOf, it } from 'vitest'; import { useClientQueries } from '../src/react'; import { schema } from './schemas/basic/schema-lite'; @@ -20,7 +20,7 @@ describe('React client sliced client test', () => { }); it('works with sliced models', () => { - const client = useClientQueries>(schema); + const client = useClientQueries(schema); expectTypeOf(client).toHaveProperty('user'); expectTypeOf(client).toHaveProperty('post'); @@ -28,18 +28,17 @@ describe('React client sliced client test', () => { }); it('works with sliced operations', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - includedOperations: ['findUnique', 'findMany', 'update']; - }; - }; - }; - } - >(schema); + const _slicedOps = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + includedOperations: ['findUnique', 'findMany', 'update'], + }, + }, + }, + }); + const client = useClientQueries(schema); expectTypeOf(client.user).toHaveProperty('useFindUnique'); expectTypeOf(client.user).toHaveProperty('useFindMany'); @@ -48,22 +47,21 @@ describe('React client sliced client test', () => { }); it('works with sliced filters', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - fields: { - $all: { - includedFilterKinds: ['Equality']; - }; - }; - }; - }; - }; - } - >(schema); + const _slicedFilters = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + fields: { + $all: { + includedFilterKinds: ['Equality'], + }, + }, + }, + }, + }, + }); + const client = useClientQueries(schema); // Equality filter should be allowed client.user.useFindMany({ @@ -76,15 +74,15 @@ describe('React client sliced client test', () => { }); it('works with sliced procedures', () => { - const client = useClientQueries< - typeof procSchema, - { - slicing: { - includedProcedures: ['greet', 'sum']; - excludedProcedures: ['sum']; - }; - } - >(procSchema); + const _slicedProcs = new ZenStackClient(procSchema, { + dialect: {} as any, + procedures: {} as any, + slicing: { + includedProcedures: ['greet', 'sum'], + excludedProcedures: ['sum'], + }, + }); + const client = useClientQueries(procSchema); expectTypeOf(client.$procs).toHaveProperty('greet'); expectTypeOf(client.$procs).not.toHaveProperty('sum'); diff --git a/packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts b/packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts index af9b66ee6..4ea2da51e 100644 --- a/packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts +++ b/packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,7 +18,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, email: { name: "email", @@ -50,7 +50,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, title: { name: "title", @@ -68,7 +68,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "owner" - ] + ] as readonly string[] }, category: { name: "category", @@ -82,7 +82,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "category" - ] + ] as readonly string[] } }, idFields: ["id"], @@ -97,7 +97,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -124,7 +124,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", @@ -147,7 +147,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", diff --git a/packages/clients/tanstack-query/test/svelte-sliced-client.test-d.ts b/packages/clients/tanstack-query/test/svelte-sliced-client.test-d.ts index 5b83f6ff4..2290536a8 100644 --- a/packages/clients/tanstack-query/test/svelte-sliced-client.test-d.ts +++ b/packages/clients/tanstack-query/test/svelte-sliced-client.test-d.ts @@ -1,4 +1,4 @@ -import { ZenStackClient, type GetQueryOptions } from '@zenstackhq/orm'; +import { ZenStackClient } from '@zenstackhq/orm'; import { describe, expectTypeOf, it } from 'vitest'; import { useClientQueries } from '../src/svelte/index.svelte'; import { schema } from './schemas/basic/schema-lite'; @@ -20,7 +20,7 @@ describe('Svelte client sliced client test', () => { }); it('works with sliced models', () => { - const client = useClientQueries>(schema); + const client = useClientQueries(schema); expectTypeOf(client).toHaveProperty('user'); expectTypeOf(client).toHaveProperty('post'); @@ -28,18 +28,17 @@ describe('Svelte client sliced client test', () => { }); it('works with sliced operations', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - includedOperations: ['findUnique', 'findMany', 'update']; - }; - }; - }; - } - >(schema); + const _slicedOps = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + includedOperations: ['findUnique', 'findMany', 'update'], + }, + }, + }, + }); + const client = useClientQueries(schema); expectTypeOf(client.user).toHaveProperty('useFindUnique'); expectTypeOf(client.user).toHaveProperty('useFindMany'); @@ -48,22 +47,21 @@ describe('Svelte client sliced client test', () => { }); it('works with sliced filters', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - fields: { - $all: { - includedFilterKinds: ['Equality']; - }; - }; - }; - }; - }; - } - >(schema); + const _slicedFilters = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + fields: { + $all: { + includedFilterKinds: ['Equality'], + }, + }, + }, + }, + }, + }); + const client = useClientQueries(schema); // Equality filter should be allowed client.user.useFindMany(() => ({ @@ -76,15 +74,15 @@ describe('Svelte client sliced client test', () => { }); it('works with sliced procedures', () => { - const client = useClientQueries< - typeof procSchema, - { - slicing: { - includedProcedures: ['greet', 'sum']; - excludedProcedures: ['sum']; - }; - } - >(procSchema); + const _slicedProcs = new ZenStackClient(procSchema, { + dialect: {} as any, + procedures: {} as any, + slicing: { + includedProcedures: ['greet', 'sum'], + excludedProcedures: ['sum'], + }, + }); + const client = useClientQueries(procSchema); expectTypeOf(client.$procs).toHaveProperty('greet'); expectTypeOf(client.$procs).not.toHaveProperty('sum'); diff --git a/packages/clients/tanstack-query/test/vue-sliced-client.test-d.ts b/packages/clients/tanstack-query/test/vue-sliced-client.test-d.ts index 5fdd11d6a..51637c955 100644 --- a/packages/clients/tanstack-query/test/vue-sliced-client.test-d.ts +++ b/packages/clients/tanstack-query/test/vue-sliced-client.test-d.ts @@ -1,4 +1,4 @@ -import { ZenStackClient, type GetQueryOptions } from '@zenstackhq/orm'; +import { ZenStackClient } from '@zenstackhq/orm'; import { describe, expectTypeOf, it } from 'vitest'; import { useClientQueries } from '../src/vue'; import { schema } from './schemas/basic/schema-lite'; @@ -20,7 +20,7 @@ describe('Vue client sliced client test', () => { }); it('works with sliced models', () => { - const client = useClientQueries>(schema); + const client = useClientQueries(schema); expectTypeOf(client).toHaveProperty('user'); expectTypeOf(client).toHaveProperty('post'); @@ -28,18 +28,17 @@ describe('Vue client sliced client test', () => { }); it('works with sliced operations', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - includedOperations: ['findUnique', 'findMany', 'update']; - }; - }; - }; - } - >(schema); + const _slicedOps = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + includedOperations: ['findUnique', 'findMany', 'update'], + }, + }, + }, + }); + const client = useClientQueries(schema); expectTypeOf(client.user).toHaveProperty('useFindUnique'); expectTypeOf(client.user).toHaveProperty('useFindMany'); @@ -48,22 +47,21 @@ describe('Vue client sliced client test', () => { }); it('works with sliced filters', () => { - const client = useClientQueries< - typeof schema, - { - slicing: { - models: { - user: { - fields: { - $all: { - includedFilterKinds: ['Equality']; - }; - }; - }; - }; - }; - } - >(schema); + const _slicedFilters = new ZenStackClient(schema, { + dialect: {} as any, + slicing: { + models: { + user: { + fields: { + $all: { + includedFilterKinds: ['Equality'], + }, + }, + }, + }, + }, + }); + const client = useClientQueries(schema); // Equality filter should be allowed client.user.useFindMany({ @@ -76,15 +74,15 @@ describe('Vue client sliced client test', () => { }); it('works with sliced procedures', () => { - const client = useClientQueries< - typeof procSchema, - { - slicing: { - includedProcedures: ['greet', 'sum']; - excludedProcedures: ['sum']; - }; - } - >(procSchema); + const _slicedProcs = new ZenStackClient(procSchema, { + dialect: {} as any, + procedures: {} as any, + slicing: { + includedProcedures: ['greet', 'sum'], + excludedProcedures: ['sum'], + }, + }); + const client = useClientQueries(procSchema); expectTypeOf(client.$procs).toHaveProperty('greet'); expectTypeOf(client.$procs).not.toHaveProperty('sum'); diff --git a/packages/common-helpers/README.md b/packages/common-helpers/README.md new file mode 100644 index 000000000..03140818e --- /dev/null +++ b/packages/common-helpers/README.md @@ -0,0 +1,3 @@ +# @zenstackhq/common-helpers + +A collection of small, general-purpose utility functions shared across ZenStack packages. diff --git a/packages/common-helpers/package.json b/packages/common-helpers/package.json index 35bad22e4..4eafe47e0 100644 --- a/packages/common-helpers/package.json +++ b/packages/common-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/common-helpers", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Common Helpers", "type": "module", "scripts": { diff --git a/packages/config/eslint-config/package.json b/packages/config/eslint-config/package.json index ca574596d..4db182c02 100644 --- a/packages/config/eslint-config/package.json +++ b/packages/config/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/eslint-config", - "version": "3.4.6", + "version": "3.5.0", "type": "module", "private": true, "license": "MIT" diff --git a/packages/config/typescript-config/package.json b/packages/config/typescript-config/package.json index b3277c1d6..e4cce0cce 100644 --- a/packages/config/typescript-config/package.json +++ b/packages/config/typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/typescript-config", - "version": "3.4.6", + "version": "3.5.0", "private": true, "license": "MIT" } diff --git a/packages/config/vitest-config/package.json b/packages/config/vitest-config/package.json index 7d085f782..f6ed411d1 100644 --- a/packages/config/vitest-config/package.json +++ b/packages/config/vitest-config/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/vitest-config", "type": "module", - "version": "3.4.6", + "version": "3.5.0", "private": true, "license": "MIT", "exports": { diff --git a/packages/create-zenstack/README.md b/packages/create-zenstack/README.md new file mode 100644 index 000000000..625e96d46 --- /dev/null +++ b/packages/create-zenstack/README.md @@ -0,0 +1,13 @@ +# create-zenstack + +Scaffolding tool to create a new ZenStack project from a template with ZenStack packages installed and a sample ZModel schema generated. + +## Usage + +```bash +npm create zenstack@latest my-app +``` + +## Learn More + +- [ZenStack Documentation](https://zenstack.dev/docs) diff --git a/packages/create-zenstack/package.json b/packages/create-zenstack/package.json index 221d756c6..30475634b 100644 --- a/packages/create-zenstack/package.json +++ b/packages/create-zenstack/package.json @@ -1,6 +1,6 @@ { "name": "create-zenstack", - "version": "3.4.6", + "version": "3.5.0", "description": "Create a new ZenStack project", "type": "module", "scripts": { diff --git a/packages/ide/vscode/eslint.config.mjs b/packages/ide/vscode/eslint.config.mjs index 5698b9910..7c11ab373 100644 --- a/packages/ide/vscode/eslint.config.mjs +++ b/packages/ide/vscode/eslint.config.mjs @@ -1,4 +1,11 @@ import config from '@zenstackhq/eslint-config/base.js'; /** @type {import("eslint").Linter.Config} */ -export default config; +export default [ + ...config, + { + rules: { + 'no-prototype-builtins': 'off', + }, + }, +]; diff --git a/packages/ide/vscode/package.json b/packages/ide/vscode/package.json index b877a5575..c053b796a 100644 --- a/packages/ide/vscode/package.json +++ b/packages/ide/vscode/package.json @@ -1,7 +1,7 @@ { "name": "zenstack-v3", "publisher": "zenstack", - "version": "3.4.6", + "version": "3.5.0", "displayName": "ZenStack V3 Language Tools", "description": "VSCode extension for ZenStack (v3) ZModel language", "private": true, @@ -10,7 +10,7 @@ "url": "https://github.com/zenstackhq/zenstack" }, "scripts": { - "build": "tsc --noEmit && tsup", + "build": "tsc --noEmit && tsup && tsx scripts/post-build.ts", "watch": "tsup --watch", "lint": "eslint src --ext ts", "vscode:publish": "pnpm build && vsce publish --no-dependencies --follow-symlinks", @@ -33,13 +33,18 @@ "dependencies": { "@zenstackhq/language": "workspace:*", "langium": "catalog:", + "mixpanel": "^0.18.0", + "uuid": "^11.1.0", "vscode-languageclient": "^9.0.1", - "vscode-languageserver": "^9.0.1" + "vscode-languageserver": "^9.0.1", + "vscode-uri": "^3.1.0", + "zod": "catalog:" }, "devDependencies": { "@types/vscode": "^1.90.0", "@zenstackhq/eslint-config": "workspace:*", - "@zenstackhq/typescript-config": "workspace:*" + "@zenstackhq/typescript-config": "workspace:*", + "dotenv": "^17.2.3" }, "files": [ "dist", @@ -79,6 +84,68 @@ "scopeName": "source.zmodel-v3", "path": "./syntaxes/zmodel.tmLanguage.json" } + ], + "menus": { + "editor/title": [ + { + "command": "zenstack.preview-zmodel-v3", + "when": "editorLangId == zmodel-v3", + "group": "navigation" + }, + { + "command": "zenstack.save-zmodel-documentation-v3", + "when": "(activeWebviewPanelId == 'markdown.preview' || activeCustomEditorId == 'vscode.markdown.preview.editor') && zenstack.isMarkdownPreview == true", + "group": "navigation" + } + ], + "commandPalette": [ + { + "command": "zenstack.preview-zmodel-v3", + "when": "editorLangId == zmodel-v3" + }, + { + "command": "zenstack.clear-documentation-cache-v3" + }, + { + "command": "zenstack.logout-v3" + } + ] + }, + "commands": [ + { + "command": "zenstack.preview-zmodel-v3", + "title": "ZenStack: Preview ZModel Documentation", + "icon": "$(preview)" + }, + { + "command": "zenstack.save-zmodel-documentation-v3", + "title": "ZenStack: Save ZModel Documentation", + "icon": "$(save)" + }, + { + "command": "zenstack.clear-documentation-cache-v3", + "title": "ZenStack: Clear Documentation Cache", + "icon": "$(trash)" + }, + { + "command": "zenstack.logout-v3", + "title": "ZenStack: Logout", + "icon": "$(log-out)" + } + ], + "keybindings": [ + { + "command": "zenstack.preview-zmodel-v3", + "key": "ctrl+shift+v", + "mac": "cmd+shift+v", + "when": "editorLangId == zmodel-v3" + }, + { + "command": "zenstack.save-zmodel-documentation-v3", + "key": "ctrl+shift+s", + "mac": "cmd+shift+s", + "when": "(activeWebviewPanelId == 'markdown.preview' || activeCustomEditorId == 'vscode.markdown.preview.editor') && zenstack.isMarkdownPreview == true" + } ] }, "activationEvents": [ diff --git a/packages/ide/vscode/scripts/post-build.ts b/packages/ide/vscode/scripts/post-build.ts new file mode 100644 index 000000000..24bfbe2ea --- /dev/null +++ b/packages/ide/vscode/scripts/post-build.ts @@ -0,0 +1,16 @@ +import dotenv from 'dotenv'; +import fs from 'node:fs'; + +dotenv.config({ path: './.env.local' }); +dotenv.config({ path: './.env' }); + +const telemetryToken = process.env.VSCODE_TELEMETRY_TRACKING_TOKEN; +if (!telemetryToken) { + console.warn('Warning: VSCODE_TELEMETRY_TRACKING_TOKEN environment variable is not set, skipping token injection'); + process.exit(0); +} +const file = 'dist/extension.js'; +let content = fs.readFileSync(file, 'utf-8'); +content = content.replace('', telemetryToken); +fs.writeFileSync(file, content, 'utf-8'); +console.log('Telemetry token injected into dist/extension.js'); diff --git a/packages/ide/vscode/src/extension/documentation-cache.ts b/packages/ide/vscode/src/extension/documentation-cache.ts new file mode 100644 index 000000000..6183ee38a --- /dev/null +++ b/packages/ide/vscode/src/extension/documentation-cache.ts @@ -0,0 +1,152 @@ +import * as vscode from 'vscode'; +import { createHash } from 'crypto'; + +// Cache entry interface +interface CacheEntry { + data: string; + timestamp: number; + extensionVersion: string; +} + +/** + * DocumentationCache class handles persistent caching of ZModel documentation + * using VS Code's globalState for cross-session persistence + */ +export class DocumentationCache implements vscode.Disposable { + private static readonly CACHE_DURATION_MS = 30 * 24 * 60 * 60 * 1000; // 30 days cache duration + private static readonly CACHE_PREFIX = 'doc-cache.'; + + private extensionContext: vscode.ExtensionContext; + private extensionVersion: string; + + constructor(context: vscode.ExtensionContext) { + this.extensionContext = context; + this.extensionVersion = context.extension.packageJSON.version as string; + // clear expired cache entries on initialization + this.clearExpiredCache(); + } + + /** + * Dispose of the cache resources (implements vscode.Disposable) + */ + dispose(): void {} + + /** + * Get the cache prefix used for keys + */ + getCachePrefix(): string { + return DocumentationCache.CACHE_PREFIX; + } + + /** + * Enable cache synchronization across machines via VS Code Settings Sync + */ + private enableCacheSync(): void { + const cacheKeys = this.extensionContext.globalState + .keys() + .filter((key) => key.startsWith(DocumentationCache.CACHE_PREFIX)); + if (cacheKeys.length > 0) { + this.extensionContext.globalState.setKeysForSync(cacheKeys); + } + } + + /** + * Generate a cache key from request body with normalized content + */ + private generateCacheKey(models: string[]): string { + // Remove ALL whitespace characters from each model string for cache key generation + // This ensures identical content with different formatting uses the same cache + const normalizedModels = models.map((model) => model.replace(/\s/g, '')).sort(); + const hash = createHash('sha512') + .update(JSON.stringify({ models: normalizedModels })) + .digest('hex'); + return `${DocumentationCache.CACHE_PREFIX}${hash}`; + } + + /** + * Check if cache entry is still valid (not expired) + */ + private isCacheValid(entry: CacheEntry): boolean { + return Date.now() - entry.timestamp < DocumentationCache.CACHE_DURATION_MS; + } + + /** + * Get cached response if available and valid + */ + async getCachedResponse(models: string[]): Promise { + const cacheKey = this.generateCacheKey(models); + const entry = this.extensionContext.globalState.get(cacheKey); + + if (entry && this.isCacheValid(entry)) { + console.log('Using cached documentation response from persistent storage'); + return entry.data; + } + + // Clean up expired entry if it exists + if (entry) { + await this.extensionContext.globalState.update(cacheKey, undefined); + } + + return null; + } + + /** + * Cache a response for future use + */ + async setCachedResponse(models: string[], data: string): Promise { + const cacheKey = this.generateCacheKey(models); + const cacheEntry: CacheEntry = { + data, + timestamp: Date.now(), + extensionVersion: this.extensionVersion, + }; + + await this.extensionContext.globalState.update(cacheKey, cacheEntry); + + // Update sync keys to include new cache entry + this.enableCacheSync(); + } + + /** + * Clear expired cache entries from persistent storage + */ + async clearExpiredCache(): Promise { + const now = Date.now(); + let clearedCount = 0; + const allKeys = this.extensionContext.globalState.keys(); + + for (const key of allKeys) { + if (key.startsWith(DocumentationCache.CACHE_PREFIX)) { + const entry = this.extensionContext.globalState.get(key); + if ( + entry?.extensionVersion !== this.extensionVersion || + now - entry.timestamp >= DocumentationCache.CACHE_DURATION_MS + ) { + await this.extensionContext.globalState.update(key, undefined); + clearedCount++; + } + } + } + + if (clearedCount > 0) { + console.log(`Cleared ${clearedCount} expired cache entries from persistent storage`); + } + } + + /** + * Clear all cache entries from persistent storage + */ + async clearAllCache(): Promise { + const allKeys = this.extensionContext.globalState.keys(); + let clearedCount = 0; + + for (const key of allKeys) { + if (key.startsWith(DocumentationCache.CACHE_PREFIX)) { + await this.extensionContext.globalState.update(key, undefined); + clearedCount++; + } + } + + console.log(`Cleared all cache entries from persistent storage (${clearedCount} items)`); + } +} diff --git a/packages/ide/vscode/src/extension/machine-id-utils.ts b/packages/ide/vscode/src/extension/machine-id-utils.ts new file mode 100644 index 000000000..b0aecfc8c --- /dev/null +++ b/packages/ide/vscode/src/extension/machine-id-utils.ts @@ -0,0 +1,73 @@ +// modified from https://github.com/automation-stack/node-machine-id + +import { execSync } from 'child_process'; +import { createHash } from 'crypto'; +import { v4 as uuid } from 'uuid'; + +const { platform } = process; +const win32RegBinPath = { + native: '%windir%\\System32', + mixed: '%windir%\\sysnative\\cmd.exe /c %windir%\\System32', +}; +const guid = { + darwin: 'ioreg -rd1 -c IOPlatformExpertDevice', + win32: + `${win32RegBinPath[isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe ` + + 'QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography ' + + '/v MachineGuid', + linux: '( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname 2> /dev/null) | head -n 1 || :', + freebsd: 'kenv -q smbios.system.uuid || sysctl -n kern.hostuuid', +}; + +function isWindowsProcessMixedOrNativeArchitecture() { + if (process.arch === 'ia32' && process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) { + return 'mixed'; + } + return 'native'; +} + +function hash(guid: string): string { + return createHash('sha256').update(guid).digest('hex'); +} + +function expose(result: string): string { + switch (platform) { + case 'darwin': + return result + .split('IOPlatformUUID')[1]! + .split('\n')[0]! + .replace(/=|\s+|"/gi, '') + .toLowerCase(); + case 'win32': + return result + .toString() + .split('REG_SZ')[1]! + .replace(/\r+|\n+|\s+/gi, '') + .toLowerCase(); + case 'linux': + return result + .toString() + .replace(/\r+|\n+|\s+/gi, '') + .toLowerCase(); + case 'freebsd': + return result + .toString() + .replace(/\r+|\n+|\s+/gi, '') + .toLowerCase(); + default: + throw new Error(`Unsupported platform: ${process.platform}`); + } +} + +export function getMachineId() { + if (!(platform in guid)) { + return uuid(); + } + try { + const value = execSync(guid[platform as keyof typeof guid]); + const id = expose(value.toString()); + return hash(id); + } catch { + return uuid(); + } +} diff --git a/packages/ide/vscode/src/extension/main.ts b/packages/ide/vscode/src/extension/main.ts index a7fab381d..2b942146f 100644 --- a/packages/ide/vscode/src/extension/main.ts +++ b/packages/ide/vscode/src/extension/main.ts @@ -2,12 +2,27 @@ import * as path from 'node:path'; import type * as vscode from 'vscode'; import type { LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node.js'; import { LanguageClient, TransportKind } from 'vscode-languageclient/node.js'; +import { DocumentationCache } from './documentation-cache'; +import { ReleaseNotesManager } from './release-notes-manager'; +import telemetry from './vscode-telemetry'; +import { ZenStackAuthenticationProvider } from './zenstack-auth-provider'; +import { ZModelPreview } from './zmodel-preview'; let client: LanguageClient; // This function is called when the extension is activated. export function activate(context: vscode.ExtensionContext): void { + telemetry.track('extension:activate'); + + // Initialize and register the ZenStack authentication provider + context.subscriptions.push(new ZenStackAuthenticationProvider(context)); + client = startLanguageClient(context); + + const documentationCache = new DocumentationCache(context); + context.subscriptions.push(documentationCache); + context.subscriptions.push(new ZModelPreview(context, client, documentationCache)); + context.subscriptions.push(new ReleaseNotesManager(context)); } // This function is called when the extension is deactivated. diff --git a/packages/ide/vscode/src/extension/release-notes-manager.ts b/packages/ide/vscode/src/extension/release-notes-manager.ts new file mode 100644 index 000000000..88349eeaf --- /dev/null +++ b/packages/ide/vscode/src/extension/release-notes-manager.ts @@ -0,0 +1,77 @@ +import * as vscode from 'vscode'; + +/** + * ReleaseNotesManager class handles release notes functionality + */ +export class ReleaseNotesManager implements vscode.Disposable { + private extensionContext: vscode.ExtensionContext; + private readonly zmodelPreviewReleaseNoteKey = 'zmodel-v3-preview-release-note-shown'; + + constructor(context: vscode.ExtensionContext) { + this.extensionContext = context; + this.initialize(); + } + + /** + * Initialize and register commands, show release notes if first time + */ + initialize(): void { + this.showReleaseNotesIfFirstTime(); + } + + /** + * Show release notes on first activation of this version + */ + async showReleaseNotesIfFirstTime(): Promise { + // Show release notes if this is the first time activating this version + if (!this.extensionContext.globalState.get(this.zmodelPreviewReleaseNoteKey)) { + await this.showReleaseNotes(); + // Update the stored version to prevent showing again + await this.extensionContext.globalState.update(this.zmodelPreviewReleaseNoteKey, true); + // Add this key to sync keys for cross-machine synchronization + this.extensionContext.globalState.setKeysForSync([this.zmodelPreviewReleaseNoteKey]); + } + } + + /** + * Show release notes (can be called manually) + */ + async showReleaseNotes(): Promise { + try { + // Read the release notes HTML file + const releaseNotesPath = vscode.Uri.joinPath( + this.extensionContext.extensionUri, + 'res/zmodel-v3-preview-release-notes.html', + ); + + const htmlBytes = await vscode.workspace.fs.readFile(releaseNotesPath); + const htmlContent = Buffer.from(htmlBytes).toString('utf8'); + // Create and show the release notes webview + const panel = vscode.window.createWebviewPanel( + 'ZenstackReleaseNotes', + 'ZenStack - New Feature Announcement!', + vscode.ViewColumn.One, + { + enableScripts: true, + retainContextWhenHidden: true, + }, + ); + + panel.webview.html = htmlContent; + + // Optional: Close the panel when user clicks outside or after some time + panel.onDidDispose(() => { + // Panel disposed + }); + } catch (error) { + console.error('Error showing release notes:', error); + } + } + + /** + * Dispose of resources + */ + dispose(): void { + // Any cleanup if needed + } +} diff --git a/packages/ide/vscode/src/extension/vscode-telemetry.ts b/packages/ide/vscode/src/extension/vscode-telemetry.ts new file mode 100644 index 000000000..99a58a280 --- /dev/null +++ b/packages/ide/vscode/src/extension/vscode-telemetry.ts @@ -0,0 +1,79 @@ +import type { Mixpanel } from 'mixpanel'; +import { init } from 'mixpanel'; +import * as os from 'os'; +import { v5 as uuidv5 } from 'uuid'; +import * as vscode from 'vscode'; +import { version as extensionVersion } from '../../package.json'; +import { getMachineId } from './machine-id-utils'; + +export const VSCODE_TELEMETRY_TRACKING_TOKEN = ''; + +export type TelemetryEvents = + | 'extension:activate' + | 'extension:zmodel-preview' + | 'extension:zmodel-save' + | 'extension:signin:show' + | 'extension:signin:start' + | 'extension:signin:error' + | 'extension:signin:complete'; + +export class VSCodeTelemetry { + private readonly mixpanel: Mixpanel | undefined; + private readonly deviceId = this.getDeviceId(); + private readonly _os_type = os.type(); + private readonly _os_release = os.release(); + private readonly _os_arch = os.arch(); + private readonly _os_version = os.version(); + private readonly _os_platform = os.platform(); + private readonly vscodeAppName = vscode.env.appName; + private readonly vscodeVersion = vscode.version; + private readonly vscodeAppHost = vscode.env.appHost; + + constructor() { + if (vscode.env.isTelemetryEnabled) { + this.mixpanel = init(VSCODE_TELEMETRY_TRACKING_TOKEN, { + geolocate: true, + }); + } + } + + private getDeviceId() { + const hostId = getMachineId(); + // namespace UUID for generating UUIDv5 from DNS 'zenstack.dev' + return uuidv5(hostId, '133cac15-3efb-50fa-b5fc-4b90e441e563'); + } + + track(event: TelemetryEvents, properties: Record = {}) { + if (this.mixpanel) { + const payload = { + distinct_id: this.deviceId, + time: new Date(), + $os: this._os_type, + osType: this._os_type, + osRelease: this._os_release, + osPlatform: this._os_platform, + osArch: this._os_arch, + osVersion: this._os_version, + nodeVersion: process.version, + vscodeAppName: this.vscodeAppName, + vscodeVersion: this.vscodeVersion, + vscodeAppHost: this.vscodeAppHost, + extensionVersion, + ...properties, + }; + this.mixpanel.track(event, payload); + } + } + + identify(userId: string) { + if (this.mixpanel) { + this.mixpanel.track('$identify', { + $identified_id: userId, + $anon_id: this.deviceId, + token: VSCODE_TELEMETRY_TRACKING_TOKEN, + }); + } + } +} + +export default new VSCodeTelemetry(); diff --git a/packages/ide/vscode/src/extension/zenstack-auth-provider.ts b/packages/ide/vscode/src/extension/zenstack-auth-provider.ts new file mode 100644 index 000000000..b8081e668 --- /dev/null +++ b/packages/ide/vscode/src/extension/zenstack-auth-provider.ts @@ -0,0 +1,252 @@ +import * as vscode from 'vscode'; +import telemetry from './vscode-telemetry'; +interface JWTClaims { + jti?: string; + sub?: string; + email?: string; + exp?: number; + [key: string]: unknown; +} + +export const AUTH_PROVIDER_ID = 'ZenStack'; +export const AUTH_URL = 'https://accounts.zenstack.dev'; +export const API_URL = 'https://api.zenstack.dev'; +const EXTENSION_ID = 'zenstack.zenstack-v3'; + +export class ZenStackAuthenticationProvider implements vscode.AuthenticationProvider, vscode.Disposable { + private _onDidChangeSessions = + new vscode.EventEmitter(); + public readonly onDidChangeSessions = this._onDidChangeSessions.event; + + private _sessions: vscode.AuthenticationSession[] = []; + private _context: vscode.ExtensionContext; + private _disposable: vscode.Disposable; + private pendingAuth?: { + resolve: (session: vscode.AuthenticationSession) => void; + reject: (error: Error) => void; + scopes: readonly string[]; + }; + + constructor(context: vscode.ExtensionContext) { + this._context = context; + + this._disposable = vscode.Disposable.from( + vscode.authentication.registerAuthenticationProvider(AUTH_PROVIDER_ID, 'ZenStack', this), + vscode.window.registerUriHandler({ + handleUri: async (uri: vscode.Uri) => { + if (uri.path === '/auth-callback') { + await this.handleAuthCallback(uri); + } + }, + }), + // Register logout command + vscode.commands.registerCommand('zenstack.logout-v3', async () => { + await this.logoutAllSessions(); + }), + ); + } + + async getSessions(_scopes?: readonly string[]): Promise { + // Check if we have stored sessions in VS Code's secret storage + const storedSessions = await this.getStoredSessions(); + this._sessions = storedSessions; + return this._sessions; + } + + async createSession(scopes: readonly string[]): Promise { + // Create a login flow + const session = await this.performLogin(scopes); + if (session) { + this._sessions.push(session); + await this.storeSession(session); + this._onDidChangeSessions.fire({ + added: [session], + removed: [], + changed: [], + }); + } + return session; + } + + async removeSession(sessionId: string): Promise { + const sessionIndex = this._sessions.findIndex((s) => s.id === sessionId); + if (sessionIndex > -1) { + const session = this._sessions[sessionIndex]!; + this._sessions.splice(sessionIndex, 1); + await this.removeStoredSession(sessionId); + this._onDidChangeSessions.fire({ + added: [], + removed: [session], + changed: [], + }); + } + } + + /** + * Log out all sessions + */ + async logoutAllSessions(): Promise { + if (this._sessions.length === 0) { + return; + } + + (await this.getSessions()).forEach(async (s) => await this.removeSession(s.id)); + vscode.window.showInformationMessage('Successfully logged out of ZenStack.'); + } + + private async performLogin(scopes: readonly string[]): Promise { + // Create the authentication promise + return vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: 'Signing in to ZenStack', + cancellable: true, + }, + async (progress, token) => { + return new Promise((resolve, reject) => { + // Handle cancellation + token.onCancellationRequested(() => { + if (this.pendingAuth) { + delete this.pendingAuth; + } + reject(new Error('User Cancelled')); + }); + + const appName = vscode.env.uriScheme; + const redirectUrl = `${API_URL}/oauth/oauth_callback?vscodeapp=${appName}&extId=${EXTENSION_ID}`; + const signInUrl = vscode.Uri.parse(new URL('/sign-in', AUTH_URL).toString()).with({ + query: `redirect_url=${encodeURIComponent(redirectUrl)}`, + }); + + const finalUrl = signInUrl.toString(true); + console.log('ZenStack sign-in URL:', finalUrl); + + // Store the state and resolve function for later use + this.pendingAuth = { resolve, reject, scopes }; + + // Open the ZenStack sign-in page in the user's default browser + // @ts-ignore - vscode issue: https://github.com/microsoft/vscode/issues/85930 + vscode.env.openExternal(finalUrl).then( + () => { + console.log('Opened ZenStack sign-in page in browser'); + progress.report({ message: 'Waiting for return from browser...' }); + }, + (error) => { + if (this.pendingAuth) { + delete this.pendingAuth; + } + reject(new Error(`Failed to open sign-in page: ${error}`)); + }, + ); + + // 2 minutes timeout + setTimeout(() => { + if (this.pendingAuth) { + delete this.pendingAuth; + } + reject(new Error('Timeout')); + }, 120000); + }); + }, + ); + } + + // Handle authentication callback from ZenStack + public async handleAuthCallback(callbackUri: vscode.Uri): Promise { + const query = new URLSearchParams(callbackUri.query); + const accessToken = query.get('access_token'); + if (!this.pendingAuth) { + console.warn('No pending authentication found'); + return; + } + if (!accessToken) { + this.pendingAuth.reject(new Error('No access token received')); + delete this.pendingAuth; + return; + } + try { + // Create session from the access token + const session = await this.createSessionFromAccessToken(accessToken); + this.pendingAuth.resolve(session); + delete this.pendingAuth; + } catch (error) { + if (this.pendingAuth) { + this.pendingAuth.reject(error instanceof Error ? error : new Error(String(error))); + delete this.pendingAuth; + } + } + } + + private async createSessionFromAccessToken(accessToken: string): Promise { + try { + // Decode JWT to get claims + const claims = this.parseJWTClaims(accessToken); + telemetry.identify(claims.email!); + return { + id: claims.jti || Math.random().toString(36), + accessToken: accessToken, + account: { + id: claims.sub || 'unknown', + label: claims.email || 'unknown@zenstack.dev', + }, + scopes: [], + }; + } catch (error) { + throw new Error(`Failed to create session from access token: ${error}`); + } + } + + private parseJWTClaims(token: string): JWTClaims { + try { + // JWT tokens have 3 parts separated by dots: header.payload.signature + const parts = token.split('.'); + if (parts.length !== 3) { + throw new Error('Invalid JWT format'); + } + + // Decode the payload (second part) - JWT uses base64url encoding + const decoded = Buffer.from(parts[1]!, 'base64url').toString('utf8'); + + return JSON.parse(decoded); + } catch (error) { + throw new Error(`Failed to parse JWT claims: ${error}`); + } + } + + private async getStoredSessions(): Promise { + try { + const stored = await this._context.secrets.get('zenstack-auth-sessions'); + return stored ? JSON.parse(stored) : []; + } catch (error) { + console.error('Error retrieving stored sessions:', error); + return []; + } + } + + private async storeSession(session: vscode.AuthenticationSession): Promise { + try { + const sessions = await this.getStoredSessions(); + sessions.push(session); + await this._context.secrets.store('zenstack-auth-sessions', JSON.stringify(sessions)); + } catch (error) { + console.error('Error storing session:', error); + } + } + + private async removeStoredSession(sessionId: string): Promise { + try { + const sessions = await this.getStoredSessions(); + const filteredSessions = sessions.filter((s) => s.id !== sessionId); + await this._context.secrets.store('zenstack-auth-sessions', JSON.stringify(filteredSessions)); + } catch (error) { + console.error('Error removing stored session:', error); + } + } + + /** + * Dispose the registered services + */ + public async dispose() { + this._disposable.dispose(); + } +} diff --git a/packages/ide/vscode/src/extension/zmodel-preview.ts b/packages/ide/vscode/src/extension/zmodel-preview.ts new file mode 100644 index 000000000..f4d7bf224 --- /dev/null +++ b/packages/ide/vscode/src/extension/zmodel-preview.ts @@ -0,0 +1,405 @@ +import * as vscode from 'vscode'; +import * as path from 'path'; +import * as os from 'os'; +import { z } from 'zod'; +import { LanguageClient } from 'vscode-languageclient/node'; +import { URI } from 'vscode-uri'; +import { DocumentationCache } from './documentation-cache'; +import { API_URL, AUTH_PROVIDER_ID } from './zenstack-auth-provider'; +import telemetry from './vscode-telemetry'; + +/** + * ZModelPreview class handles ZModel file preview functionality + */ +export class ZModelPreview implements vscode.Disposable { + private documentationCache: DocumentationCache; + private languageClient: LanguageClient; + private lastGeneratedMarkdown: string | null = null; + // use a zero-width space in the file name to make it non-colliding with user file + private readonly previewZModelFileName = `zmodel${'\u200B'}-preview.md`; + + // Schema for validating the request body + private static DocRequestSchema = z.object({ + models: z.array( + z.object({ + path: z.string().optional(), + content: z.string(), + }), + ), + environments: z + .object({ + vscodeAppName: z.string(), + vscodeVersion: z.string(), + vscodeAppHost: z.string(), + osRelease: z.string(), + osType: z.string(), + }) + .optional(), + }); + + constructor(context: vscode.ExtensionContext, client: LanguageClient, cache: DocumentationCache) { + this.documentationCache = cache; + this.languageClient = client; + this.initialize(context); + } + + /** + * Initialize and register commands + */ + initialize(context: vscode.ExtensionContext): void { + this.registerCommands(context); + + context.subscriptions.push( + vscode.window.tabGroups.onDidChangeTabs(() => { + const activeTabLabels = vscode.window.tabGroups.all.filter((group) => + group.activeTab?.label?.endsWith(this.previewZModelFileName), + ); + if (activeTabLabels.length > 0) { + vscode.commands.executeCommand('setContext', 'zenstack.isMarkdownPreview', true); + } else { + vscode.commands.executeCommand('setContext', 'zenstack.isMarkdownPreview', false); + } + }), + ); + } + + /** + * Register ZModel preview commands + */ + private registerCommands(context: vscode.ExtensionContext): void { + // Register the preview command for zmodel files + context.subscriptions.push( + vscode.commands.registerCommand('zenstack.preview-zmodel-v3', async () => { + await this.previewZModelFile(); + }), + ); + + // Register the save documentation command for zmodel files + context.subscriptions.push( + vscode.commands.registerCommand('zenstack.save-zmodel-documentation-v3', async () => { + await this.saveZModelDocumentation(); + }), + ); + + // Register cache management commands + context.subscriptions.push( + vscode.commands.registerCommand('zenstack.clear-documentation-cache-v3', async () => { + await this.documentationCache.clearAllCache(); + vscode.window.showInformationMessage('ZenStack documentation cache cleared'); + }), + ); + } + + /** + * Preview a ZModel file + */ + async previewZModelFile(): Promise { + telemetry.track('extension:zmodel-preview'); + const editor = vscode.window.activeTextEditor; + + if (!editor) { + vscode.window.showErrorMessage('No active editor found.'); + return; + } + + const document = editor.document; + if (!document.fileName.endsWith('.zmodel')) { + vscode.window.showErrorMessage('The active file is not a ZModel file.'); + return; + } + + // Check authentication before proceeding + const session = await this.requireAuth(); + if (!session) { + return; + } + + try { + this.checkForMermaidExtensions(); + // Show progress indicator + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: 'Generating ZModel documentation...', + cancellable: false, + }, + async () => { + const markdownContent = await this.generateZModelDocumentation(document); + + if (markdownContent) { + // Store the generated content for potential saving later + this.lastGeneratedMarkdown = markdownContent; + + await this.openMarkdownPreview(markdownContent); + } + }, + ); + } catch (error) { + console.error('Error previewing ZModel:', error); + vscode.window.showErrorMessage( + `Failed to preview ZModel: ${error instanceof Error ? error.message : String(error)}`, + ); + } + } + + /** + * Get all imported ZModel URIs using the language server + */ + private async getAllImportedZModelURIs(document: vscode.TextDocument): Promise<{ + hasSyntaxErrors: boolean; + importedURIs: URI[]; + }> { + if (!this.languageClient) { + throw new Error('Language client not initialized'); + } + + try { + // Ensure the language server is ready + await this.languageClient.start(); + + // Send the custom request to get all imported ZModel URIs + const result = await this.languageClient.sendRequest('zenstack/getAllImportedZModelURIs', { + textDocument: { + uri: document.uri.toString(), + }, + }); + + return result as { + hasSyntaxErrors: boolean; + importedURIs: URI[]; + }; + } catch (error) { + console.error('Error getting AST from language server:', error); + throw error; + } + } + + /** + * Generate documentation for ZModel + */ + private async generateZModelDocumentation(document: vscode.TextDocument): Promise { + try { + const astInfo = await this.getAllImportedZModelURIs(document); + + if (astInfo?.hasSyntaxErrors !== false) { + vscode.window.showWarningMessage('Please fix the errors in the ZModel first'); + return ''; + } + + const importedURIs = astInfo?.importedURIs; + + // get vscode document from importedURIs + const importedModels = await Promise.all( + importedURIs.map(async (uri) => { + try { + const fileUri = vscode.Uri.file(uri.path); + const fileContent = await vscode.workspace.fs.readFile(fileUri); + const filePath = fileUri.path; + return { content: Buffer.from(fileContent).toString('utf8').trim(), path: filePath }; + } catch (error) { + throw new Error( + `Failed to read imported ZModel file at ${uri.path}: ${ + error instanceof Error ? error.message : String(error) + }`, + ); + } + }), + ); + + const allModels = [{ content: document.getText().trim(), path: document.uri.path }, ...importedModels]; + + const session = await this.requireAuth(); + if (!session) { + throw new Error('Authentication required to generate documentation'); + } + + // Prepare request body + const requestBody: z.infer = { + models: allModels, + environments: { + vscodeAppName: vscode.env.appName, + vscodeVersion: vscode.version, + vscodeAppHost: vscode.env.appHost, + osRelease: os.release(), + osType: os.type(), + }, + }; + + const allModelsContent = allModels.map((m) => m.content); + + // Check cache first + const cachedResponse = await this.documentationCache.getCachedResponse(allModelsContent); + if (cachedResponse) { + return cachedResponse; + } + + // record the time spent + const startTime = Date.now(); + const apiResponse = await fetch(`${API_URL}/api/doc`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + authorization: session.accessToken, + }, + body: JSON.stringify(requestBody), + }); + + console.log(`API request completed in ${Date.now() - startTime} ms`); + + if (!apiResponse.ok) { + throw new Error(`API request failed: ${apiResponse.status} ${apiResponse.statusText}`); + } + + const responseText = await apiResponse.text(); + + // Cache the response + await this.documentationCache.setCachedResponse(allModelsContent, responseText); + + return responseText; + } catch (error) { + console.error('Error generating documentation:', error); + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Failed to generate documentation: ${errorMessage}`); + } + } + + /** + * Open markdown preview + */ + private async openMarkdownPreview(markdownContent: string): Promise { + // Create a temporary markdown file with a descriptive name in the system temp folder + const tempFilePath = path.join(os.tmpdir(), this.previewZModelFileName); + const tempFile = vscode.Uri.file(tempFilePath); + + try { + // Write the markdown content to the temp file + await vscode.workspace.fs.writeFile(tempFile, new TextEncoder().encode(markdownContent)); + // Open the markdown preview side by side + await vscode.commands.executeCommand('markdown.showPreviewToSide', tempFile); + } catch (error) { + console.error('Error creating markdown preview:', error); + throw new Error( + `Failed to create markdown preview: ${error instanceof Error ? error.message : String(error)}`, + ); + } + } + + /** + * Save ZModel documentation to a user-selected file + */ + async saveZModelDocumentation(): Promise { + telemetry.track('extension:zmodel-save'); + // Check if we have cached content first + if (!this.lastGeneratedMarkdown) { + vscode.window.showErrorMessage( + 'No documentation content available to save. Please generate the documentation first by running "Preview ZModel Documentation".', + ); + return; + } + + // Show save dialog + let defaultFilePath = `zmodel-doc.md`; + + const workspaceFolders = vscode.workspace.workspaceFolders; + if (workspaceFolders && workspaceFolders.length > 0) { + const workspacePath = workspaceFolders[0]!.uri.fsPath; + // If the workspace folder exists, use it + defaultFilePath = path.join(workspacePath, defaultFilePath); + } + + const saveUri = await vscode.window.showSaveDialog({ + defaultUri: vscode.Uri.file(defaultFilePath), + filters: { + Markdown: ['md'], + 'All Files': ['*'], + }, + saveLabel: 'Save Documentation', + }); + + if (!saveUri) { + return; // User cancelled + } + + try { + // Write the markdown content to the selected file + await vscode.workspace.fs.writeFile(saveUri, new TextEncoder().encode(this.lastGeneratedMarkdown)); + // Open and close the saved file to refresh the shown markdown preview + await vscode.commands.executeCommand('vscode.open', saveUri); + await vscode.commands.executeCommand('workbench.action.closeActiveEditor'); + } catch (error) { + console.error('Error saving markdown file:', error); + vscode.window.showErrorMessage( + `Failed to save documentation: ${error instanceof Error ? error.message : String(error)}`, + ); + } + } + + /** + * Check for Mermaid extensions + */ + private checkForMermaidExtensions(): void { + const setting = vscode.workspace.getConfiguration('zenstack').get('searchForExtensions'); + if (setting !== false) { + const extensions = vscode.extensions.all.filter((extension) => + ['markdown-mermaid', 'vscode-mermaid-chart', 'vscode-mermaid-preview'].some((name) => + extension.packageJSON.name?.toLowerCase().includes(name.toLowerCase()), + ), + ); + if (extensions.length === 0) { + const searchAction = 'Search'; + const stopShowing = "Don't show again"; + vscode.window + .showInformationMessage( + 'Search for extensions to view mermaid chart in ZModel preview doc?', + searchAction, + stopShowing, + ) + .then((selectedAction) => { + if (selectedAction === searchAction) { + vscode.commands.executeCommand('workbench.extensions.search', 'markdown-mermaid'); + } else if (selectedAction === stopShowing) { + vscode.workspace + .getConfiguration('zenstack') + .update('searchForExtensions', false, vscode.ConfigurationTarget.Global); + } + }); + } + } + } + + // Utility to require authentication when needed + private async requireAuth(): Promise { + let session: vscode.AuthenticationSession | undefined; + + session = await vscode.authentication.getSession(AUTH_PROVIDER_ID, [], { createIfNone: false }); + + if (!session) { + const signIn = 'Sign in'; + const selection = await vscode.window.showWarningMessage('Please sign in to use this feature', signIn); + telemetry.track('extension:signin:show'); + if (selection === signIn) { + telemetry.track('extension:signin:start'); + try { + session = await vscode.authentication.getSession(AUTH_PROVIDER_ID, [], { createIfNone: true }); + if (session) { + telemetry.track('extension:signin:complete'); + vscode.window.showInformationMessage('ZenStack sign-in successful!'); + } + } catch (e: unknown) { + telemetry.track('extension:signin:error', { error: e instanceof Error ? e.message : String(e) }); + vscode.window.showErrorMessage( + 'ZenStack sign-in failed: ' + (e instanceof Error ? e.message : String(e)), + ); + } + } + } + return session; + } + + /** + * Dispose of resources + */ + dispose(): void { + // Any cleanup if needed + } +} diff --git a/packages/ide/vscode/src/language-server/main.ts b/packages/ide/vscode/src/language-server/main.ts index efa215690..b51ebaf3d 100644 --- a/packages/ide/vscode/src/language-server/main.ts +++ b/packages/ide/vscode/src/language-server/main.ts @@ -1,4 +1,7 @@ import { createZModelLanguageServices } from '@zenstackhq/language'; +import type { Model } from '@zenstackhq/language/ast'; +import { getDocument, resolveImport } from '@zenstackhq/language/utils'; +import { URI, type LangiumDocument, type LangiumDocuments } from 'langium'; import { startLanguageServer } from 'langium/lsp'; import { NodeFileSystem } from 'langium/node'; import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js'; @@ -15,5 +18,75 @@ const { shared } = createZModelLanguageServices( true, ); +// Add custom LSP request handlers +connection.onRequest('zenstack/getAllImportedZModelURIs', async (params: { textDocument: { uri: string } }) => { + try { + const uri = URI.parse(params.textDocument.uri); + const document = await shared.workspace.LangiumDocuments.getOrCreateDocument(uri); + + // Ensure the document is parsed and built + if (!document.parseResult) { + await shared.workspace.DocumentBuilder.build([document]); + } + + const langiumDocuments = shared.workspace.LangiumDocuments; + + // load all imports + const importedURIs = eagerLoadAllImports(document, langiumDocuments); + + const importedDocuments = await Promise.all( + importedURIs.map((uri) => langiumDocuments.getOrCreateDocument(uri)), + ); + + // build the document together with standard library, plugin modules, and imported documents + await shared.workspace.DocumentBuilder.build([document, ...importedDocuments], { + validation: true, + }); + + let hasSyntaxErrors = false; + for (const doc of [document, ...importedDocuments]) { + if ( + doc.parseResult.lexerErrors.length > 0 || + doc.parseResult.parserErrors.length > 0 || + doc.diagnostics?.some((e) => e.severity === 1) + ) { + hasSyntaxErrors = true; + break; + } + } + + return { + hasSyntaxErrors, + importedURIs, + }; + } catch (error) { + console.error('Error getting imported ZModel file:', error); + return { + hasSyntaxErrors: true, + importedURIs: [], + }; + } +}); + +function eagerLoadAllImports(document: LangiumDocument, documents: LangiumDocuments, uris: Set = new Set()) { + const uriString = document.uri.toString(); + if (!uris.has(uriString)) { + uris.add(uriString); + const model = document.parseResult.value as Model; + + for (const imp of model.imports) { + const importedModel = resolveImport(documents, imp); + if (importedModel) { + const importedDoc = getDocument(importedModel); + eagerLoadAllImports(importedDoc, documents, uris); + } + } + } + + return Array.from(uris) + .filter((x) => uriString != x) + .map((e) => URI.parse(e)); +} + // Start the language server with the shared services startLanguageServer(shared); diff --git a/packages/language/README.md b/packages/language/README.md new file mode 100644 index 000000000..21b685c7b --- /dev/null +++ b/packages/language/README.md @@ -0,0 +1,7 @@ +# @zenstackhq/language + +The ZModel language specification and tooling package, built on [Langium](https://langium.org/). + +## Learn More + +- [ZModel Language Reference](https://zenstack.dev/docs/reference/zmodel) diff --git a/packages/language/package.json b/packages/language/package.json index 4dfba58c5..e61dd5d8c 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/language", "description": "ZenStack ZModel language specification", - "version": "3.4.6", + "version": "3.5.0", "license": "MIT", "author": "ZenStack Team", "files": [ diff --git a/packages/language/res/zmodel-v3-preview-release-notes.html b/packages/language/res/zmodel-v3-preview-release-notes.html new file mode 100644 index 000000000..262895d87 --- /dev/null +++ b/packages/language/res/zmodel-v3-preview-release-notes.html @@ -0,0 +1,95 @@ + + + + + + + + +
+

🎉 Introducing ZModel Documentation Preview

+

Preview documentation directly from your ZModel powered by AI

+
+ +
+

📖 What's New

+

+ You can now preview comprehensive documentation for your ZModel files, just like you would preview a + markdown file. +

+
+ +
+

🚀 How to Use

+
    +
  1. Open your .zmodel file
  2. +
  3. + Click () in the editor toolbar, or press + Cmd + Shift + V (Mac) or + Ctrl + Shift + V (Windows) +
  4. +
  5. Sign in with ZenStack (one-time setup)
  6. +
  7. + Click () in the preview toolbar to save the doc, or press + Cmd + Shift + S (Mac) or + Ctrl + Shift + S (Windows) +
  8. +
+
+ +
+

💡 Tips

+
    +
  • Ensure your zmodel is error-free before generating.
  • +
  • Use your main zmodel file, which will include all imported models, for complete documentation.
  • +
  • + Add clear, descriptive comments in your ZModel. The more context you provide, the better the + results. +
  • +
+
+ +

+ Happy coding with ZenStack! 🚀
+

+ + diff --git a/packages/orm/README.md b/packages/orm/README.md new file mode 100644 index 000000000..9a46f2d59 --- /dev/null +++ b/packages/orm/README.md @@ -0,0 +1,34 @@ +# @zenstackhq/orm + +The core ZenStack ORM engine, built on top of [Kysely](https://kysely.dev/). Provides a type-safe database client (`ZenStackClient`) with a high-level, [Prisma](https://prisma.io/)-compatible CRUD API and direct access to the underlying Kysely query builder for advanced queries. + +## Key Features + +- **Type-safe CRUD operations** generated from your ZModel schema +- **Plugin system** for query interception and entity mutation hooks +- **Multi-dialect support** — SQLite (better-sqlite3), PostgreSQL (pg), and MySQL (mysql2) +- **Computed fields** evaluated at the database level +- **Custom procedures** for encapsulating complex queries and mutations + +## Installation + +```bash +npm install @zenstackhq/orm +``` + +## Usage + +```typescript +import { ZenStackClient } from '@zenstackhq/orm'; +import schema from './schema'; + +const client = new ZenStackClient(schema, { + /* dialect config */ +}); + +const user = await client.user.findFirst({ where: { email: 'alice@example.com' } }); +``` + +## Learn More + +- [ZenStack Documentation](https://zenstack.dev/docs) diff --git a/packages/orm/package.json b/packages/orm/package.json index ed1a1d826..3b26d02cf 100644 --- a/packages/orm/package.json +++ b/packages/orm/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/orm", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack ORM", "type": "module", "scripts": { diff --git a/packages/orm/src/client/client-impl.ts b/packages/orm/src/client/client-impl.ts index 1046d0ca8..cabc8bb41 100644 --- a/packages/orm/src/client/client-impl.ts +++ b/packages/orm/src/client/client-impl.ts @@ -10,9 +10,11 @@ import { Transaction, type KyselyProps, } from 'kysely'; +import z from 'zod'; import type { ProcedureDef, SchemaDef } from '../schema'; import type { AnyKysely } from '../utils/kysely-utils'; import type { UnwrapTuplePromises } from '../utils/type-utils'; +import { formatError } from '../utils/zod-utils'; import type { AuthType, ClientConstructor, @@ -31,6 +33,7 @@ import { FindOperationHandler } from './crud/operations/find'; import { GroupByOperationHandler } from './crud/operations/group-by'; import { UpdateOperationHandler } from './crud/operations/update'; import { InputValidator } from './crud/validator'; +import type { Diagnostics, QueryInfo } from './diagnostics'; import { createConfigError, createNotFoundError, createNotSupportedError } from './errors'; import { ZenStackDriver } from './executor/zenstack-driver'; import { ZenStackQueryExecutor } from './executor/zenstack-query-executor'; @@ -39,8 +42,14 @@ import { SchemaDbPusher } from './helpers/schema-db-pusher'; import type { ClientOptions, ProceduresOptions } from './options'; import type { AnyPlugin } from './plugin'; import { createZenStackPromise, type ZenStackPromise } from './promise'; +import { fieldHasDefaultValue, getField, isUnsupportedField, requireModel } from './query-utils'; import { ResultProcessor } from './result-processor'; +type ExtResultFieldDef = { + needs: Record; + compute: (data: Record) => unknown; +}; + /** * ZenStack ORM client. */ @@ -60,6 +69,7 @@ export class ClientImpl { readonly kyselyProps: KyselyProps; private auth: AuthType | undefined; inputValidator: InputValidator; + readonly slowQueries: QueryInfo[] = []; constructor( private readonly schema: SchemaDef, @@ -75,10 +85,7 @@ export class ClientImpl { ...this.$options.functions, }; - if (!baseClient && !options.skipValidationForComputedFields) { - // validate computed fields configuration once for the root client - this.validateComputedFieldsConfig(); - } + this.validateOptions(baseClient, options); // here we use kysely's props constructor so we can pass a custom query executor if (baseClient) { @@ -96,6 +103,7 @@ export class ClientImpl { }; this.kyselyRaw = baseClient.kyselyRaw; this.auth = baseClient.auth; + this.slowQueries = baseClient.slowQueries; } else { const driver = new ZenStackDriver(options.dialect.createDriver(), new Log(this.$options.log ?? [])); const compiler = options.dialect.createQueryCompiler(); @@ -119,48 +127,52 @@ export class ClientImpl { }); } - this.kysely = new Kysely(this.kyselyProps); - this.inputValidator = baseClient?.inputValidator ?? new InputValidator(this as any); - - return createClientProxy(this); - } - - get $qb() { - return this.kysely; - } + if (baseClient?.isTransaction && !executor) { + // if we're creating a derived client from a transaction client and not replacing + // the executor, reuse the current kysely instance to retain the transaction context + this.kysely = baseClient.$qb; + } else { + this.kysely = new Kysely(this.kyselyProps); + } - get $qbRaw() { - return this.kyselyRaw; - } + this.inputValidator = + baseClient?.inputValidator ?? + new InputValidator(this as any, { enabled: this.$options.validateInput !== false }); - get $zod() { - return this.inputValidator.zodFactory; + return createClientProxy(this); } - get isTransaction() { - return this.kysely.isTransaction; - } + private validateOptions(baseClient: ClientImpl | undefined, options: ClientOptions) { + if (!baseClient && !options.skipValidationForComputedFields) { + // validate computed fields configuration once for the root client + this.validateComputedFieldsConfig(options); + } - /** - * Create a new client with a new query executor. - */ - withExecutor(executor: QueryExecutor) { - return new ClientImpl(this.schema, this.$options, this, executor); + if (options.diagnostics) { + const diagnosticsSchema = z.object({ + slowQueryThresholdMs: z.number().nonnegative().optional(), + slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional(), + }); + const parseResult = diagnosticsSchema.safeParse(options.diagnostics); + if (!parseResult.success) { + throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`); + } + } } /** * Validates that all computed fields in the schema have corresponding configurations. */ - private validateComputedFieldsConfig() { + private validateComputedFieldsConfig(options: ClientOptions) { const computedFieldsConfig = - 'computedFields' in this.$options - ? (this.$options.computedFields as Record | undefined) - : undefined; + 'computedFields' in options ? (options.computedFields as Record | undefined) : undefined; for (const [modelName, modelDef] of Object.entries(this.$schema.models)) { if (modelDef.computedFields) { for (const fieldName of Object.keys(modelDef.computedFields)) { - const modelConfig = computedFieldsConfig?.[modelName]; + // check both uncapitalized (current) and original (backward compat) model name + const modelConfig = + computedFieldsConfig?.[lowerCaseFirst(modelName)] ?? computedFieldsConfig?.[modelName]; const fieldConfig = modelConfig?.[fieldName]; // Check if the computed field has a configuration if (fieldConfig === null || fieldConfig === undefined) { @@ -181,6 +193,29 @@ export class ClientImpl { } } + get $qb() { + return this.kysely; + } + + get $qbRaw() { + return this.kyselyRaw; + } + + get $zod() { + return this.inputValidator.zodFactory; + } + + get isTransaction() { + return this.kysely.isTransaction; + } + + /** + * Create a new client with a new query executor. + */ + withExecutor(executor: QueryExecutor) { + return new ClientImpl(this.schema, this.$options, this, executor); + } + // overload for interactive transaction $transaction( callback: (tx: ClientContract) => Promise, @@ -348,7 +383,9 @@ export class ClientImpl { const newClient = new ClientImpl(this.schema, newOptions, this); // create a new validator to have a fresh schema cache, because plugins may extend the // query args schemas - newClient.inputValidator = new InputValidator(newClient as any); + newClient.inputValidator = new InputValidator(newClient as any, { + enabled: newOptions.validateInput !== false, + }); return newClient; } @@ -367,7 +404,9 @@ export class ClientImpl { const newClient = new ClientImpl(this.schema, newOptions, this); // create a new validator to have a fresh schema cache, because plugins may // extend the query args schemas - newClient.inputValidator = new InputValidator(newClient as any); + newClient.inputValidator = new InputValidator(newClient as any, { + enabled: newClient.$options.validateInput !== false, + }); return newClient; } @@ -380,12 +419,14 @@ export class ClientImpl { const newClient = new ClientImpl(this.schema, newOptions, this); // create a new validator to have a fresh schema cache, because plugins may // extend the query args schemas - newClient.inputValidator = new InputValidator(newClient as any); + newClient.inputValidator = new InputValidator(newClient as any, { + enabled: newOptions.validateInput !== false, + }); return newClient; } $setAuth(auth: AuthType | undefined) { - if (auth !== undefined && typeof auth !== 'object') { + if (auth !== undefined && (typeof auth !== 'object' || auth === null || Array.isArray(auth))) { throw new Error('Invalid auth object'); } const newClient = new ClientImpl(this.schema, this.$options, this); @@ -400,7 +441,9 @@ export class ClientImpl { $setOptions>(options: Options): ClientContract { const newClient = new ClientImpl(this.schema, options as ClientOptions, this); // create a new validator to have a fresh schema cache, because options may change validation settings - newClient.inputValidator = new InputValidator(newClient as any); + newClient.inputValidator = new InputValidator(newClient as any, { + enabled: newClient.$options.validateInput !== false, + }); return newClient as unknown as ClientContract; } @@ -412,6 +455,13 @@ export class ClientImpl { return this.$setOptions(newOptions); } + get $diagnostics(): Promise { + return Promise.resolve({ + zodCache: this.inputValidator.zodFactory.cacheStats, + slowQueries: this.slowQueries.map((q) => ({ ...q })).sort((a, b) => b.durationMs - a.durationMs), + }); + } + $executeRaw(query: TemplateStringsArray, ...values: any[]) { return createZenStackPromise(async () => { const result = await sql(query, ...values).execute(this.kysely); @@ -547,6 +597,11 @@ function createModelCrudHandler( inputValidator: InputValidator, resultProcessor: ResultProcessor, ): ModelOperations { + // check if any plugin defines ext result fields + const plugins = client.$options.plugins ?? []; + const schema = client.$schema; + const hasAnyExtResult = hasExtResultFieldDefs(plugins); + const createPromise = ( operation: CoreCrudOperations, nominalOperation: AllCrudOperations, @@ -557,17 +612,30 @@ function createModelCrudHandler( ) => { return createZenStackPromise(async (txClient?: ClientContract) => { let proceed = async (_args: unknown) => { + // prepare args for ext result: strip ext result field names from select/omit, + // inject needs fields into select (recursively handles nested relations) + const shouldApplyExtResult = hasAnyExtResult && EXT_RESULT_OPERATIONS.has(operation); + const processedArgs = shouldApplyExtResult + ? prepareArgsForExtResult(_args, model, schema, plugins) + : _args; + const _handler = txClient ? handler.withClient(txClient) : handler; - const r = await _handler.handle(operation, _args); + const r = await _handler.handle(operation, processedArgs); if (!r && throwIfNoResult) { throw createNotFoundError(model); } let result: unknown; if (r && postProcess) { - result = resultProcessor.processResult(r, model, args); + result = resultProcessor.processResult(r, model, processedArgs); } else { result = r ?? null; } + + // compute ext result fields (recursively handles nested relations) + if (result && shouldApplyExtResult) { + result = applyExtResult(result, model, _args, schema, plugins); + } + return result; }; @@ -821,5 +889,274 @@ function createModelCrudHandler( } } + // Remove create/upsert operations for models with required Unsupported fields + const modelDef = requireModel(client.$schema, model); + if (Object.values(modelDef.fields).some((f) => isUnsupportedField(f) && !f.optional && !fieldHasDefaultValue(f))) { + for (const op of ['create', 'createMany', 'createManyAndReturn', 'upsert'] as const) { + delete (operations as any)[op]; + } + } + return operations as ModelOperations; } + +// #region Extended result field helpers + +// operations that return model rows and should have ext result fields applied +const EXT_RESULT_OPERATIONS = new Set([ + 'findMany', + 'findUnique', + 'findFirst', + 'create', + 'createManyAndReturn', + 'update', + 'updateManyAndReturn', + 'upsert', + 'delete', +]); + +/** + * Returns true if any plugin defines ext result fields for any model. + */ +function hasExtResultFieldDefs(plugins: AnyPlugin[]): boolean { + return plugins.some((p) => p.result && Object.keys(p.result).length > 0); +} + +/** + * Collects extended result field definitions from all plugins for a given model. + */ +function collectExtResultFieldDefs( + model: string, + schema: SchemaDef, + plugins: AnyPlugin[], +): Map { + const defs = new Map(); + for (const plugin of plugins) { + const resultConfig = plugin.result; + if (resultConfig) { + const modelConfig = resultConfig[lowerCaseFirst(model)]; + if (modelConfig) { + for (const [fieldName, fieldDef] of Object.entries(modelConfig)) { + if (getField(schema, model, fieldName)) { + throw new Error( + `Plugin "${plugin.id}" registers ext result field "${fieldName}" on model "${model}" which conflicts with an existing model field`, + ); + } + for (const needField of Object.keys((fieldDef as ExtResultFieldDef).needs ?? {})) { + const needDef = getField(schema, model, needField); + if (!needDef || needDef.relation) { + throw new Error( + `Plugin "${plugin.id}" registers ext result field "${fieldName}" on model "${model}" with invalid need "${needField}"`, + ); + } + } + defs.set(fieldName, fieldDef as ExtResultFieldDef); + } + } + } + } + return defs; +} + +/** + * Prepares query args for extended result fields (recursive): + * - Strips ext result field names from `select` and `omit` + * - Injects `needs` fields into `select` when ext result fields are explicitly selected + * - Recurses into `include` and `select` for nested relation fields + */ +function prepareArgsForExtResult(args: unknown, model: string, schema: SchemaDef, plugins: AnyPlugin[]): unknown { + if (!args || typeof args !== 'object') { + return args; + } + + const extResultDefs = collectExtResultFieldDefs(model, schema, plugins); + const typedArgs = args as Record; + let result = typedArgs; + let changed = false; + + const select = typedArgs['select'] as Record | undefined; + const omit = typedArgs['omit'] as Record | undefined; + const include = typedArgs['include'] as Record | undefined; + + if (select && extResultDefs.size > 0) { + const newSelect = { ...select }; + for (const [fieldName, fieldDef] of extResultDefs) { + if (newSelect[fieldName]) { + delete newSelect[fieldName]; + // inject needs fields + for (const needField of Object.keys(fieldDef.needs)) { + if (!newSelect[needField]) { + newSelect[needField] = true; + } + } + } + } + result = { ...result, select: newSelect }; + changed = true; + } + + if (omit && extResultDefs.size > 0) { + const newOmit = { ...omit }; + for (const [fieldName, fieldDef] of extResultDefs) { + if (newOmit[fieldName]) { + // strip ext result field names from omit (they don't exist in the DB) + delete newOmit[fieldName]; + } else { + // this ext result field is active — ensure its needs are not omitted + for (const needField of Object.keys(fieldDef.needs)) { + if (newOmit[needField]) { + delete newOmit[needField]; + } + } + } + } + result = { ...result, omit: newOmit }; + changed = true; + } + + // Recurse into nested relations in `include` + if (include) { + const newInclude = { ...include }; + let includeChanged = false; + for (const [field, value] of Object.entries(newInclude)) { + if (value && typeof value === 'object') { + const fieldDef = getField(schema, model, field); + if (fieldDef?.relation) { + const targetModel = fieldDef.type; + const processed = prepareArgsForExtResult(value, targetModel, schema, plugins); + if (processed !== value) { + newInclude[field] = processed; + includeChanged = true; + } + } + } + } + if (includeChanged) { + result = changed ? { ...result, include: newInclude } : { ...typedArgs, include: newInclude }; + changed = true; + } + } + + // Recurse into nested relations in `select` (relation fields can have nested args) + if (select) { + const currentSelect = (changed ? (result as Record)['select'] : select) as + | Record + | undefined; + if (currentSelect) { + const newSelect = { ...currentSelect }; + let selectChanged = false; + for (const [field, value] of Object.entries(newSelect)) { + if (value && typeof value === 'object') { + const fieldDef = getField(schema, model, field); + if (fieldDef?.relation) { + const targetModel = fieldDef.type; + const processed = prepareArgsForExtResult(value, targetModel, schema, plugins); + if (processed !== value) { + newSelect[field] = processed; + selectChanged = true; + } + } + } + } + if (selectChanged) { + result = { ...result, select: newSelect }; + changed = true; + } + } + } + + return changed ? result : args; +} + +/** + * Applies extended result field computation to query results (recursive). + * Processes the current model's ext result fields, then recurses into nested relation data. + */ +function applyExtResult( + result: unknown, + model: string, + originalArgs: unknown, + schema: SchemaDef, + plugins: AnyPlugin[], +): unknown { + const extResultDefs = collectExtResultFieldDefs(model, schema, plugins); + if (Array.isArray(result)) { + for (let i = 0; i < result.length; i++) { + result[i] = applyExtResultToRow(result[i], model, originalArgs, schema, plugins, extResultDefs); + } + return result; + } else { + return applyExtResultToRow(result, model, originalArgs, schema, plugins, extResultDefs); + } +} + +function applyExtResultToRow( + row: unknown, + model: string, + originalArgs: unknown, + schema: SchemaDef, + plugins: AnyPlugin[], + extResultDefs: Map, +): unknown { + if (!row || typeof row !== 'object') { + return row; + } + + const data = row as Record; + const typedArgs = (originalArgs && typeof originalArgs === 'object' ? originalArgs : {}) as Record; + const select = typedArgs['select'] as Record | undefined; + const omit = typedArgs['omit'] as Record | undefined; + const include = typedArgs['include'] as Record | undefined; + + // Compute ext result fields for the current model + for (const [fieldName, fieldDef] of extResultDefs) { + if (select && !select[fieldName]) { + continue; + } + if (omit?.[fieldName]) { + continue; + } + const needsSatisfied = Object.keys(fieldDef.needs).every((needField) => needField in data); + if (needsSatisfied) { + data[fieldName] = fieldDef.compute(data); + } + } + + // Strip fields that shouldn't be in the result: when `select` was used, + // drop any field not in the original select and not a computed ext result field; + // when `omit` was used, re-delete any field the user originally omitted. + if (select) { + for (const key of Object.keys(data)) { + if (!select[key] && !extResultDefs.has(key)) { + delete data[key]; + } + } + } else if (omit) { + for (const key of Object.keys(omit)) { + if (omit[key] && !extResultDefs.has(key)) { + delete data[key]; + } + } + } + + // Recurse into nested relation data + const relationSource = include ?? select; + if (relationSource) { + for (const [field, value] of Object.entries(relationSource)) { + if (data[field] == null) { + continue; + } + const fieldDef = getField(schema, model, field); + if (!fieldDef?.relation) { + continue; + } + const targetModel = fieldDef.type; + const nestedArgs = value && typeof value === 'object' ? value : undefined; + data[field] = applyExtResult(data[field], targetModel, nestedArgs, schema, plugins); + } + } + + return data; +} + +// #endregion diff --git a/packages/orm/src/client/contract.ts b/packages/orm/src/client/contract.ts index c6b772aa4..4a451e203 100644 --- a/packages/orm/src/client/contract.ts +++ b/packages/orm/src/client/contract.ts @@ -2,7 +2,6 @@ import { type FieldIsArray, type GetModels, type GetTypeDefs, - type IsDelegateModel, type ProcedureDef, type RelationFields, type RelationFieldType, @@ -39,11 +38,18 @@ import type { UpdateManyArgs, UpsertArgs, } from './crud-types'; +import type { Diagnostics } from './diagnostics'; import type { ClientOptions, QueryOptions } from './options'; -import type { ExtClientMembersBase, ExtQueryArgsBase, RuntimePlugin } from './plugin'; +import type { + ExtClientMembersBase, + ExtQueryArgsBase, + ExtResultBase, + ExtResultInferenceArgs, + RuntimePlugin, +} from './plugin'; import type { ZenStackPromise } from './promise'; import type { ToKysely } from './query-builder'; -import type { GetSlicedModels, GetSlicedOperations, GetSlicedProcedures } from './type-utils'; +import type { GetSlicedModels, GetSlicedOperations, GetSlicedProcedures, ModelAllowsCreate } from './type-utils'; import type { ZodSchemaFactory } from './zod/factory'; type TransactionUnsupportedMethods = (typeof TRANSACTION_UNSUPPORTED_METHODS)[number]; @@ -67,6 +73,7 @@ export type ClientContract< Options extends ClientOptions = ClientOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtClientMembers extends ExtClientMembersBase = {}, + ExtResult extends ExtResultBase = {}, > = { /** * The schema definition. @@ -117,17 +124,26 @@ export type ClientContract< $queryRawUnsafe(query: string, ...values: any[]): ZenStackPromise; /** - * The current user identity. + * The current user identity. If the client is not bound to any user context, returns `undefined`. */ get $auth(): AuthType | undefined; /** - * Sets the current user identity. + * Returns a new client bound to the specified user identity. The original client remains unchanged. + * Pass `undefined` to return a client without any user context. + * + * @example + * ``` + * const userClient = db.$setAuth({ id: 'user-id' }); + * ``` */ - $setAuth(auth: AuthType | undefined): ClientContract; + $setAuth( + auth: AuthType | undefined, + ): ClientContract; /** - * Returns a new client with new options applied. + * Returns a new client with new options applied. The original client remains unchanged. + * * @example * ``` * const dbNoValidation = db.$setOptions({ ...db.$options, validateInput: false }); @@ -135,18 +151,22 @@ export type ClientContract< */ $setOptions>( options: NewOptions, - ): ClientContract; + ): ClientContract; /** - * Returns a new client enabling/disabling input validations expressed with attributes like - * `@email`, `@regex`, `@@validate`, etc. + * Returns a new client enabling/disabling query args validation. The original client remains unchanged. * * @deprecated Use {@link $setOptions} instead. */ - $setInputValidation(enable: boolean): ClientContract; + $setInputValidation(enable: boolean): ClientContract; /** * The Kysely query builder instance. + * + * @example + * ``` + * db.$qb.selectFrom('User').selectAll().where('id', '=', 1).execute(); + * ``` */ readonly $qb: ToKysely; @@ -157,14 +177,31 @@ export type ClientContract< /** * Starts an interactive transaction. + * + * @example + * ``` + * await db.$transaction(async (tx) => { + * const user = await tx.user.update({ where: { id: 1 }, data: { name: 'Alice' } }); + * const post = await tx.post.create({ data: { title: 'Hello World', authorId: user.id } }); + * return { user, posts: [post] }; + * ``` */ $transaction( - callback: (tx: TransactionClientContract) => Promise, + callback: ( + tx: TransactionClientContract, + ) => Promise, options?: { isolationLevel?: TransactionIsolationLevel }, ): Promise; /** - * Starts a sequential transaction. + * Starts a sequential transaction that runs the provided operations in order. + * + * @example + * ``` + * await db.$transaction([ + * db.user.update({ where: { id: 1 }, data: { name: 'Alice' } }), + * db.post.create({ data: { title: 'Hello World', authorId: 1 } }), + * ]); */ $transaction

[]>( arg: [...P], @@ -172,23 +209,36 @@ export type ClientContract< ): Promise>; /** - * Returns a new client with the specified plugin installed. + * Returns a new client with the specified plugin installed. The original client remains unchanged. + * + * @see {@link https://zenstack.dev/docs/orm/plugins/|Plugin Documentation} */ $use< PluginSchema extends SchemaDef = Schema, PluginExtQueryArgs extends ExtQueryArgsBase = {}, PluginExtClientMembers extends ExtClientMembersBase = {}, + PluginExtResult extends ExtResultBase = {}, + _R = {}, // auxiliary type for inferring precise typing for `PluginExtResult` >( - plugin: RuntimePlugin, - ): ClientContract; + plugin: RuntimePlugin & { + // intersect with the `result` extension field for precise typing + result?: ExtResultInferenceArgs; + }, + ): ClientContract< + Schema, + Options, + ExtQueryArgs & PluginExtQueryArgs, + ExtClientMembers & PluginExtClientMembers, + ExtResult & PluginExtResult + >; /** - * Returns a new client with the specified plugin removed. + * Returns a new client with the specified plugin removed. The original client remains unchanged. */ - $unuse(pluginId: string): ClientContract; + $unuse(pluginId: string): ClientContract; /** - * Returns a new client with all plugins removed. + * Returns a new client with all plugins removed. The original client remains unchanged. */ $unuseAll(): ClientContract; @@ -212,8 +262,19 @@ export type ClientContract< * @private */ $pushSchema(): Promise; + + /** + * Returns diagnostics information such as cache and slow query statistics. + */ + get $diagnostics(): Promise; } & { - [Key in GetSlicedModels as Uncapitalize]: ModelOperations; + [Key in GetSlicedModels as Uncapitalize]: ModelOperations< + Schema, + Key, + Options, + ExtQueryArgs, + ExtResult + >; } & ProcedureOperations & ExtClientMembers; @@ -225,7 +286,8 @@ export type TransactionClientContract< Options extends ClientOptions, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends ExtClientMembersBase, -> = Omit, TransactionUnsupportedMethods>; + ExtResult extends ExtResultBase = {}, +> = Omit, TransactionUnsupportedMethods>; export type ProcedureOperations< Schema extends SchemaDef, @@ -284,8 +346,8 @@ type SliceOperations< // keep only operations included by slicing options [Key in keyof T as Key extends GetSlicedOperations ? Key : never]: T[Key]; }, - // exclude operations not applicable to delegate models - IsDelegateModel extends true ? OperationsIneligibleForDelegateModels : never + // exclude create operations for models that don't allow create (delegate models, required Unsupported fields) + ModelAllowsCreate extends true ? never : OperationsRequiringCreate >; export type AllModelOperations< @@ -293,7 +355,8 @@ export type AllModelOperations< Model extends GetModels, Options extends QueryOptions, ExtQueryArgs extends ExtQueryArgsBase, -> = CommonModelOperations & + ExtResult extends ExtResultBase = {}, +> = CommonModelOperations & // provider-specific operations (Schema['provider']['type'] extends 'mysql' ? {} @@ -316,9 +379,9 @@ export type AllModelOperations< * }); * ``` */ - createManyAndReturn>( - args?: SelectSubset>, - ): ZenStackPromise[]>; + createManyAndReturn>( + args?: SelectSubset>, + ): ZenStackPromise[]>; /** * Updates multiple entities and returns them. @@ -342,9 +405,9 @@ export type AllModelOperations< * }); * ``` */ - updateManyAndReturn>( - args: Subset>, - ): ZenStackPromise[]>; + updateManyAndReturn>( + args: Subset>, + ): ZenStackPromise[]>; }); type CommonModelOperations< @@ -352,6 +415,7 @@ type CommonModelOperations< Model extends GetModels, Options extends QueryOptions, ExtQueryArgs extends ExtQueryArgsBase, + ExtResult extends ExtResultBase = {}, > = { /** * Returns a list of entities. @@ -434,9 +498,9 @@ type CommonModelOperations< * }); // result: `{ _count: { posts: number } }` * ``` */ - findMany>( - args?: SelectSubset>, - ): ZenStackPromise[]>; + findMany>( + args?: SelectSubset>, + ): ZenStackPromise[]>; /** * Returns a uniquely identified entity. @@ -444,9 +508,9 @@ type CommonModelOperations< * @returns a single entity or null if not found * @see {@link findMany} */ - findUnique>( - args: SelectSubset>, - ): ZenStackPromise | null>; + findUnique>( + args: SelectSubset>, + ): ZenStackPromise | null>; /** * Returns a uniquely identified entity or throws `NotFoundError` if not found. @@ -454,9 +518,9 @@ type CommonModelOperations< * @returns a single entity * @see {@link findMany} */ - findUniqueOrThrow>( - args: SelectSubset>, - ): ZenStackPromise>; + findUniqueOrThrow>( + args: SelectSubset>, + ): ZenStackPromise>; /** * Returns the first entity. @@ -464,9 +528,9 @@ type CommonModelOperations< * @returns a single entity or null if not found * @see {@link findMany} */ - findFirst>( - args?: SelectSubset>, - ): ZenStackPromise | null>; + findFirst>( + args?: SelectSubset>, + ): ZenStackPromise | null>; /** * Returns the first entity or throws `NotFoundError` if not found. @@ -474,9 +538,9 @@ type CommonModelOperations< * @returns a single entity * @see {@link findMany} */ - findFirstOrThrow>( - args?: SelectSubset>, - ): ZenStackPromise>; + findFirstOrThrow>( + args?: SelectSubset>, + ): ZenStackPromise>; /** * Creates a new entity. @@ -530,9 +594,9 @@ type CommonModelOperations< * }); * ``` */ - create>( - args: SelectSubset>, - ): ZenStackPromise>; + create>( + args: SelectSubset>, + ): ZenStackPromise>; /** * Creates multiple entities. Only scalar fields are allowed. @@ -680,9 +744,9 @@ type CommonModelOperations< * }); * ``` */ - update>( - args: SelectSubset>, - ): ZenStackPromise>; + update>( + args: SelectSubset>, + ): ZenStackPromise>; /** * Updates multiple entities. @@ -728,9 +792,9 @@ type CommonModelOperations< * }); * ``` */ - upsert>( - args: SelectSubset>, - ): ZenStackPromise>; + upsert>( + args: SelectSubset>, + ): ZenStackPromise>; /** * Deletes a uniquely identifiable entity. @@ -751,9 +815,9 @@ type CommonModelOperations< * }); // result: `{ id: string; email: string }` * ``` */ - delete>( - args: SelectSubset>, - ): ZenStackPromise>; + delete>( + args: SelectSubset>, + ): ZenStackPromise>; /** * Deletes multiple entities. @@ -880,14 +944,15 @@ type CommonModelOperations< ): ZenStackPromise; }; -export type OperationsIneligibleForDelegateModels = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert'; +export type OperationsRequiringCreate = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert'; export type ModelOperations< Schema extends SchemaDef, Model extends GetModels, Options extends ClientOptions = ClientOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, -> = SliceOperations, Schema, Model, Options>; + ExtResult extends ExtResultBase = {}, +> = SliceOperations, Schema, Model, Options>; //#endregion diff --git a/packages/orm/src/client/crud-types.ts b/packages/orm/src/client/crud-types.ts index 6c335cf93..99fb9e69c 100644 --- a/packages/orm/src/client/crud-types.ts +++ b/packages/orm/src/client/crud-types.ts @@ -6,7 +6,6 @@ import type { FieldHasDefault, FieldIsArray, FieldIsDelegateDiscriminator, - FieldIsDelegateRelation, FieldIsRelation, FieldType, ForeignKeyFields, @@ -58,9 +57,9 @@ import type { CoreUpdateOperations, } from './crud/operations/base'; import type { FilterKind, QueryOptions } from './options'; -import type { ExtQueryArgsBase } from './plugin'; +import type { ExtQueryArgsBase, ExtResultBase } from './plugin'; import type { ToKyselySchema } from './query-builder'; -import type { GetSlicedFilterKindsForField, GetSlicedModels } from './type-utils'; +import type { GetSlicedFilterKindsForField, GetSlicedModels, ModelAllowsCreate } from './type-utils'; //#region Query results @@ -122,10 +121,10 @@ type OptionsLevelOmit< Model extends GetModels, Field extends GetModelFields, Options extends QueryOptions, -> = Model extends keyof Options['omit'] - ? Field extends keyof Options['omit'][Model] - ? Options['omit'][Model][Field] extends boolean - ? Options['omit'][Model][Field] +> = Uncapitalize extends keyof Options['omit'] + ? Field extends keyof Options['omit'][Uncapitalize] + ? Options['omit'][Uncapitalize][Field] extends boolean + ? Options['omit'][Uncapitalize][Field] : undefined : undefined : undefined; @@ -152,21 +151,25 @@ type ModelSelectResult< Select, Omit, Options extends QueryOptions, + ExtResult extends ExtResultBase = {}, > = { [Key in keyof Select as Select[Key] extends false | undefined ? // not selected never - : Key extends '_count' - ? // select "_count" - Select[Key] extends SelectCount - ? Key - : never - : Key extends keyof Omit - ? Omit[Key] extends true - ? // omit - never - : Key - : Key]: Key extends '_count' + : Key extends keyof ExtractExtResult + ? // ext result field — handled by SelectAwareExtResult intersection in ModelResult + never + : Key extends '_count' + ? // select "_count" + Select[Key] extends SelectCount + ? Key + : never + : Key extends keyof Omit + ? Omit[Key] extends true + ? // omit + never + : Key + : Key]: Key extends '_count' ? // select "_count" result SelectCountResult : Key extends NonRelationFields @@ -180,7 +183,8 @@ type ModelSelectResult< Select[Key], Options, ModelFieldIsOptional, - FieldIsArray + FieldIsArray, + ExtResult > : never; }; @@ -201,12 +205,13 @@ export type ModelResult< Options extends QueryOptions = QueryOptions, Optional = false, Array = false, + ExtResult extends ExtResultBase = {}, > = WrapType< - Args extends { + (Args extends { select: infer S extends object; omit?: infer O extends object; } & Record - ? ModelSelectResult + ? ModelSelectResult : Args extends { include: infer I extends object; omit?: infer O extends object; @@ -222,7 +227,8 @@ export type ModelResult< I[Key], Options, ModelFieldIsOptional, - FieldIsArray + FieldIsArray, + ExtResult >; } & ('_count' extends keyof I ? I['_count'] extends false | undefined @@ -231,7 +237,9 @@ export type ModelResult< : {}) : Args extends { omit: infer O } & Record ? DefaultModelResult - : DefaultModelResult, + : DefaultModelResult) & + // intersect with fields contributed by result extension plugins + SelectAwareExtResult, Optional, Array >; @@ -243,14 +251,16 @@ export type SimplifiedResult< Options extends QueryOptions = QueryOptions, Optional = false, Array = false, -> = Simplify>; + ExtResult extends ExtResultBase = {}, +> = Simplify>; export type SimplifiedPlainResult< Schema extends SchemaDef, Model extends GetModels, Args = {}, Options extends QueryOptions = QueryOptions, -> = Simplify>; + ExtResult extends ExtResultBase = {}, +> = Simplify>; export type TypeDefResult< Schema extends SchemaDef, @@ -946,24 +956,30 @@ export type SelectIncludeOmit< AllowCount extends boolean, Options extends QueryOptions = QueryOptions, AllowRelation extends boolean = true, + ExtResult extends ExtResultBase = {}, > = { /** * Explicitly select fields and relations to be returned by the query. */ - select?: SelectInput | null; + select?: + | (SelectInput & + ExtResultSelectOmitFields) + | null; /** * Explicitly omit fields from the query result. */ - omit?: OmitInput | null; -} & (AllowRelation extends true - ? { - /** - * Specifies relations to be included in the query result. All scalar fields are included. - */ - include?: IncludeInput | null; - } - : {}); + omit?: (OmitInput & ExtResultSelectOmitFields) | null; +} & { + /** + * Specifies relations to be included in the query result. All scalar fields are included. + */ + [K in AllowRelation extends true + ? RelationFields extends never + ? never + : 'include' + : never]?: IncludeInput | null; +}; export type SelectInput< Schema extends SchemaDef, @@ -971,9 +987,10 @@ export type SelectInput< Options extends QueryOptions = QueryOptions, AllowCount extends boolean = true, AllowRelation extends boolean = true, + ExtResult extends ExtResultBase = {}, > = { [Key in NonRelationFields]?: boolean; -} & (AllowRelation extends true ? IncludeInput : {}); +} & (AllowRelation extends true ? IncludeInput : {}); type SelectCount, Options extends QueryOptions> = | boolean @@ -995,6 +1012,7 @@ export type IncludeInput< Model extends GetModels, Options extends QueryOptions = QueryOptions, AllowCount extends boolean = true, + ExtResult extends ExtResultBase = {}, > = { [Key in RelationFields as RelationFieldType extends GetSlicedModels< Schema, @@ -1013,7 +1031,8 @@ export type IncludeInput< ? true : ModelFieldIsOptional extends true ? true - : false + : false, + ExtResult >; } & (AllowCount extends true ? // _count is only allowed if the model has to-many relations @@ -1087,7 +1106,7 @@ type RelationFilter< //#region Field utils -type MapModelFieldType< +export type MapModelFieldType< Schema extends SchemaDef, Model extends GetModels, Field extends GetModelFields, @@ -1203,6 +1222,7 @@ export type FindArgs< Options extends QueryOptions, Collection extends boolean, AllowFilter extends boolean = true, + ExtResult extends ExtResultBase = {}, > = (Collection extends true ? SortAndTakeArgs & (ProviderSupportsDistinct extends true @@ -1215,21 +1235,23 @@ export type FindArgs< : {}) : {}) & (AllowFilter extends true ? FilterArgs : {}) & - SelectIncludeOmit; + SelectIncludeOmit; export type FindManyArgs< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, -> = FindArgs & ExtractExtQueryArgs; + ExtResult extends ExtResultBase = {}, +> = FindArgs & ExtractExtQueryArgs; export type FindFirstArgs< Schema extends SchemaDef, Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, -> = FindArgs & ExtractExtQueryArgs; + ExtResult extends ExtResultBase = {}, +> = FindArgs & ExtractExtQueryArgs; export type ExistsArgs< Schema extends SchemaDef, @@ -1243,9 +1265,10 @@ export type FindUniqueArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = { where: WhereUniqueInput; -} & SelectIncludeOmit & +} & SelectIncludeOmit & ExtractExtQueryArgs; //#endregion @@ -1257,9 +1280,10 @@ export type CreateArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = { data: CreateInput; -} & SelectIncludeOmit & +} & SelectIncludeOmit & ExtractExtQueryArgs; export type CreateManyArgs< @@ -1274,8 +1298,9 @@ export type CreateManyAndReturnArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = CreateManyInput & - SelectIncludeOmit & + SelectIncludeOmit & ExtractExtQueryArgs; type OptionalWrap, T extends object> = Optional< @@ -1331,6 +1356,15 @@ type CreateFKPayload> } >; +type RelationModelAllowsCreate< + Schema extends SchemaDef, + Model extends GetModels, + Field extends RelationFields, +> = + GetModelFieldType extends GetModels + ? ModelAllowsCreate> + : false; + type CreateRelationFieldPayload< Schema extends SchemaDef, Model extends GetModels, @@ -1360,8 +1394,10 @@ type CreateRelationFieldPayload< }, // no "createMany" for non-array fields | (FieldIsArray extends true ? never : 'createMany') - // exclude operations not applicable to delegate models - | (FieldIsDelegateRelation extends true ? 'create' | 'createMany' | 'connectOrCreate' : never) + // exclude create operations for models that don't allow create + | (RelationModelAllowsCreate extends true + ? never + : 'create' | 'createMany' | 'connectOrCreate') >; type CreateRelationPayload< @@ -1484,6 +1520,7 @@ export type UpdateArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = { /** * The data to update the record with. @@ -1494,7 +1531,7 @@ export type UpdateArgs< * The unique filter to find the record to update. */ where: WhereUniqueInput; -} & SelectIncludeOmit & +} & SelectIncludeOmit & ExtractExtQueryArgs; export type UpdateManyArgs< @@ -1509,8 +1546,9 @@ export type UpdateManyAndReturnArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = UpdateManyPayload & - SelectIncludeOmit & + SelectIncludeOmit & ExtractExtQueryArgs; type UpdateManyPayload< @@ -1540,6 +1578,7 @@ export type UpsertArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = { /** * The data to create the record if it doesn't exist. @@ -1555,7 +1594,7 @@ export type UpsertArgs< * The unique filter to find the record to update. */ where: WhereUniqueInput; -} & SelectIncludeOmit & +} & SelectIncludeOmit & ExtractExtQueryArgs; type UpdateScalarInput< @@ -1715,10 +1754,10 @@ type ToManyRelationUpdateInput< */ set?: SetRelationInput; }, - // exclude - FieldIsDelegateRelation extends true - ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' - : never + // exclude create operations for models that don't allow create + RelationModelAllowsCreate extends true + ? never + : 'create' | 'createMany' | 'connectOrCreate' | 'upsert' >; type ToOneRelationUpdateInput< @@ -1765,7 +1804,8 @@ type ToOneRelationUpdateInput< delete?: NestedDeleteInput; } : {}), - FieldIsDelegateRelation extends true ? 'create' | 'connectOrCreate' | 'upsert' : never + // exclude create operations for models that don't allow create + RelationModelAllowsCreate extends true ? never : 'create' | 'connectOrCreate' | 'upsert' >; // #endregion @@ -1777,12 +1817,13 @@ export type DeleteArgs< Model extends GetModels, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, + ExtResult extends ExtResultBase = {}, > = { /** * The unique filter to find the record to delete. */ where: WhereUniqueInput; -} & SelectIncludeOmit & +} & SelectIncludeOmit & ExtractExtQueryArgs; export type DeleteManyArgs< @@ -2409,4 +2450,65 @@ type ExtractExtQueryArgs = ( : {}) & ('$all' extends keyof ExtQueryArgs ? ExtQueryArgs['$all'] : {}); +/** + * Extracts extended result field types for a specific model from ExtResult. + * Maps `{ needs, compute }` definitions to `{ fieldName: ReturnType }`. + * When ExtResult is `{}`, this resolves to `{}` (no-op for intersection). + */ +export type ExtractExtResult = + Uncapitalize extends keyof ExtResult + ? { + [K in keyof ExtResult[Uncapitalize]]: ExtResult[Uncapitalize][K] extends { + compute: (...args: any[]) => infer R; + } + ? R + : never; + } + : {}; + +/** + * Extracts extended result field names as optional boolean keys for use in select/omit inputs. + * When ExtResult is `{}`, this resolves to `{}` (no-op for intersection). + */ +export type ExtResultSelectOmitFields< + ExtResult extends ExtResultBase, + Model extends string, +> = keyof ExtResult extends never + ? {} + : Uncapitalize extends keyof ExtResult + ? { [K in keyof ExtResult[Uncapitalize]]?: boolean } + : {}; + +type TruthyKeys = { + [K in Keys]: K extends keyof S ? (S[K] extends false | undefined ? never : K) : never; +}[Keys]; + +/** + * Select/omit-aware version of ExtractExtResult. + * - If T has `select`, only includes ext result fields that are explicitly selected. + * - If T has `omit`, excludes ext result fields that are explicitly omitted. + * - Otherwise, includes all ext result fields. + */ +export type SelectAwareExtResult< + ExtResult extends ExtResultBase, + Model extends string, + T, +> = keyof ExtResult extends never + ? {} + : T extends { select: infer S } + ? S extends null | undefined + ? ExtractExtResult + : Pick< + ExtractExtResult, + TruthyKeys>> + > + : T extends { omit: infer O } + ? O extends null | undefined + ? ExtractExtResult + : Omit< + ExtractExtResult, + TruthyKeys>> + > + : ExtractExtResult; + // #endregion diff --git a/packages/orm/src/client/crud/dialects/base-dialect.ts b/packages/orm/src/client/crud/dialects/base-dialect.ts index e38382f1f..5fae51ef5 100644 --- a/packages/orm/src/client/crud/dialects/base-dialect.ts +++ b/packages/orm/src/client/crud/dialects/base-dialect.ts @@ -1,4 +1,4 @@ -import { enumerate, invariant, isPlainObject } from '@zenstackhq/common-helpers'; +import { enumerate, invariant, isPlainObject, lowerCaseFirst } from '@zenstackhq/common-helpers'; import type { AliasableExpression, Expression, ExpressionBuilder, ExpressionWrapper, SqlBool, ValueNode } from 'kysely'; import { expressionBuilder, sql, type SelectQueryBuilder } from 'kysely'; import { match, P } from 'ts-pattern'; @@ -26,9 +26,8 @@ import { getManyToManyRelation, getRelationForeignKeyFieldPairs, isEnum, - isInheritedField, - isRelationField, isTypeDef, + getModelFields, makeDefaultOrderBy, requireField, requireIdFields, @@ -1127,33 +1126,26 @@ export abstract class BaseCrudDialect { omit: Record | undefined | null, modelAlias: string, ) { - const modelDef = requireModel(this.schema, model); let result = query; - for (const field of Object.keys(modelDef.fields)) { - if (isRelationField(this.schema, model, field)) { - continue; - } - if (this.shouldOmitField(omit, model, field)) { + for (const fieldDef of getModelFields(this.schema, model, { inherited: true, computed: true })) { + if (this.shouldOmitField(omit, model, fieldDef.name)) { continue; } - result = this.buildSelectField(result, model, modelAlias, field); + result = this.buildSelectField(result, model, modelAlias, fieldDef.name); } // select all fields from delegate descendants and pack into a JSON field `$delegate$Model` const descendants = getDelegateDescendantModels(this.schema, model); for (const subModel of descendants) { result = this.buildDelegateJoin(model, modelAlias, subModel.name, result); - result = result.select((eb) => { + result = result.select(() => { const jsonObject: Record> = {}; - for (const field of Object.keys(subModel.fields)) { - if ( - isRelationField(this.schema, subModel.name, field) || - isInheritedField(this.schema, subModel.name, field) - ) { + for (const fieldDef of getModelFields(this.schema, subModel.name, { computed: true })) { + if (this.shouldOmitField(omit, subModel.name, fieldDef.name)) { continue; } - jsonObject[field] = eb.ref(`${subModel.name}.${field}`); + jsonObject[fieldDef.name] = this.fieldRef(subModel.name, fieldDef.name, subModel.name); } return this.buildJsonObject(jsonObject).as(`${DELEGATE_JOINED_FIELD_PREFIX}${subModel.name}`); }); @@ -1168,12 +1160,12 @@ export abstract class BaseCrudDialect { return (omit as any)[field]; } - if ( - this.options.omit?.[model] && - typeof this.options.omit[model] === 'object' && - typeof (this.options.omit[model] as any)[field] === 'boolean' - ) { - return (this.options.omit[model] as any)[field]; + // client-level: check both uncapitalized (current) and original (backward compat) model name + const uncapModel = lowerCaseFirst(model); + const omitConfig = (this.options.omit as Record | undefined)?.[uncapModel] ?? + (this.options.omit as Record | undefined)?.[model]; + if (omitConfig && typeof omitConfig === 'object' && typeof omitConfig[field] === 'boolean') { + return omitConfig[field]; } // schema-level @@ -1363,7 +1355,9 @@ export abstract class BaseCrudDialect { let computer: Function | undefined; if ('computedFields' in this.options) { const computedFields = this.options.computedFields as Record; - computer = computedFields?.[fieldDef.originModel ?? model]?.[field]; + // check both uncapitalized (current) and original (backward compat) model name + const computedModel = fieldDef.originModel ?? model; + computer = computedFields?.[lowerCaseFirst(computedModel)]?.[field] ?? computedFields?.[computedModel]?.[field]; } if (!computer) { throw createConfigError(`Computed field "${field}" implementation not provided for model "${model}"`); diff --git a/packages/orm/src/client/crud/dialects/lateral-join-dialect-base.ts b/packages/orm/src/client/crud/dialects/lateral-join-dialect-base.ts index 94f29b20a..cbcdbee30 100644 --- a/packages/orm/src/client/crud/dialects/lateral-join-dialect-base.ts +++ b/packages/orm/src/client/crud/dialects/lateral-join-dialect-base.ts @@ -245,12 +245,12 @@ export abstract class LateralJoinDialectBase extends B ); } - if (typeof payload === 'object' && payload.include && typeof payload.include === 'object') { + if (typeof payload === 'object' && (payload as any).include && typeof (payload as any).include === 'object') { // include relation fields Object.assign( objArgs, - ...Object.entries(payload.include) + ...Object.entries((payload as any).include) .filter(([, value]) => value) .map(([field]) => ({ [field]: eb.ref(`${parentResultName}$${field}.$data`), @@ -270,7 +270,7 @@ export abstract class LateralJoinDialectBase extends B ) { let result = query; if (typeof payload === 'object') { - const selectInclude = payload.include ?? payload.select; + const selectInclude = (payload as any).include ?? payload.select; if (selectInclude && typeof selectInclude === 'object') { Object.entries(selectInclude) .filter(([, value]) => value) diff --git a/packages/orm/src/client/crud/dialects/mysql.ts b/packages/orm/src/client/crud/dialects/mysql.ts index 6e444227b..5533a59aa 100644 --- a/packages/orm/src/client/crud/dialects/mysql.ts +++ b/packages/orm/src/client/crud/dialects/mysql.ts @@ -10,7 +10,6 @@ import { type SelectQueryBuilder, type SqlBool, } from 'kysely'; -import { match } from 'ts-pattern'; import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types'; import type { BuiltinType, FieldDef, SchemaDef } from '../../../schema'; import type { SortOrder } from '../../crud-types'; @@ -93,9 +92,10 @@ export class MySqlCrudDialect extends LateralJoinDiale throw createNotSupportedError(`MySQL does not support array literals`); } } else { - return match(type) - .with('Boolean', () => (value ? 1 : 0)) // MySQL uses 1/0 for boolean like SQLite - .with('DateTime', () => { + switch (type) { + case 'Boolean': + return value ? 1 : 0; + case 'DateTime': // MySQL DATETIME format: 'YYYY-MM-DD HH:MM:SS.mmm' if (value instanceof Date) { // force UTC @@ -106,15 +106,15 @@ export class MySqlCrudDialect extends LateralJoinDiale } else { return value; } - }) - .with('Decimal', () => (value !== null ? value.toString() : value)) - .with('Json', () => { + case 'Decimal': + return value !== null ? value.toString() : value; + case 'Json': return this.eb.cast(this.eb.val(JSON.stringify(value)), 'json'); - }) - .with('Bytes', () => - Buffer.isBuffer(value) ? value : value instanceof Uint8Array ? Buffer.from(value) : value, - ) - .otherwise(() => value); + case 'Bytes': + return Buffer.isBuffer(value) ? value : value instanceof Uint8Array ? Buffer.from(value) : value; + default: + return value; + } } } @@ -122,13 +122,21 @@ export class MySqlCrudDialect extends LateralJoinDiale if (value === null || value === undefined) { return value; } - return match(type) - .with('Boolean', () => this.transformOutputBoolean(value)) - .with('DateTime', () => this.transformOutputDate(value)) - .with('Bytes', () => this.transformOutputBytes(value)) - .with('BigInt', () => this.transformOutputBigInt(value)) - .with('Decimal', () => this.transformDecimal(value)) - .otherwise(() => super.transformOutput(value, type, array)); + + switch (type) { + case 'Boolean': + return this.transformOutputBoolean(value); + case 'DateTime': + return this.transformOutputDate(value); + case 'Bytes': + return this.transformOutputBytes(value); + case 'BigInt': + return this.transformOutputBigInt(value); + case 'Decimal': + return this.transformDecimal(value); + default: + return super.transformOutput(value, type, array); + } } private transformOutputBoolean(value: unknown) { @@ -282,26 +290,31 @@ export class MySqlCrudDialect extends LateralJoinDiale operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown, ) { - return match(operation) - .with('array_contains', () => { + switch (operation) { + case 'array_contains': { const v = Array.isArray(value) ? value : [value]; return sql`JSON_CONTAINS(${lhs}, ${sql.val(JSON.stringify(v))})`; - }) - .with('array_starts_with', () => - this.eb( + } + + case 'array_starts_with': { + return this.eb( this.eb.fn('JSON_EXTRACT', [lhs, this.eb.val('$[0]')]), '=', this.transformInput(value, 'Json', false), - ), - ) - .with('array_ends_with', () => - this.eb( + ); + } + + case 'array_ends_with': { + return this.eb( sql`JSON_EXTRACT(${lhs}, CONCAT('$[', JSON_LENGTH(${lhs}) - 1, ']'))`, '=', this.transformInput(value, 'Json', false), - ), - ) - .exhaustive(); + ); + } + + default: + throw createInvalidInputError(`Unsupported array filter operation: ${operation}`); + } } protected override buildJsonArrayExistsPredicate( diff --git a/packages/orm/src/client/crud/dialects/postgresql.ts b/packages/orm/src/client/crud/dialects/postgresql.ts index 67d429de8..a601f8028 100644 --- a/packages/orm/src/client/crud/dialects/postgresql.ts +++ b/packages/orm/src/client/crud/dialects/postgresql.ts @@ -9,7 +9,6 @@ import { type SqlBool, } from 'kysely'; import { parse as parsePostgresArray } from 'postgres-array'; -import { match } from 'ts-pattern'; import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types'; import type { BuiltinType, FieldDef, SchemaDef } from '../../../schema'; import type { SortOrder } from '../../crud-types'; @@ -21,6 +20,18 @@ import { LateralJoinDialectBase } from './lateral-join-dialect-base'; export class PostgresCrudDialect extends LateralJoinDialectBase { private static typeParserOverrideApplied = false; + private readonly zmodelToSqlTypeMap: Record = { + String: 'text', + Boolean: 'boolean', + Int: 'integer', + BigInt: 'bigint', + Float: 'double precision', + Decimal: 'decimal', + DateTime: 'timestamp', + Bytes: 'bytea', + Json: 'jsonb', + }; + constructor(schema: Schema, options: ClientOptions) { super(schema, options); this.overrideTypeParsers(); @@ -34,23 +45,39 @@ export class PostgresCrudDialect extends LateralJoinDi if (this.options.fixPostgresTimezone !== false && !PostgresCrudDialect.typeParserOverrideApplied) { PostgresCrudDialect.typeParserOverrideApplied = true; + const fixTimezone = (value: unknown) => { + if (typeof value !== 'string') { + return value; + } + if (!this.hasTimezoneOffset(value)) { + // force UTC if no offset + value += 'Z'; + } + const result = new Date(value); + return isNaN(result.getTime()) + ? value // fallback to original value if parsing fails + : result; + }; + // override node-pg's default type parser to resolve the timezone handling issue // with "TIMESTAMP WITHOUT TIME ZONE" fields // https://github.com/brianc/node-postgres/issues/429 import(/* webpackIgnore: true */ 'pg') // suppress bundler analysis warnings .then((pg) => { - pg.types.setTypeParser(pg.types.builtins.TIMESTAMP, (value) => { + // timestamp + pg.types.setTypeParser(pg.types.builtins.TIMESTAMP, fixTimezone); + pg.types.setTypeParser(1115, (value) => { + // timestamp array if (typeof value !== 'string') { return value; } - if (!this.hasTimezoneOffset(value)) { - // force UTC if no offset - value += 'Z'; + try { + const arr = parsePostgresArray(value); + return arr.map(fixTimezone); + } catch { + // fallback to original value if parsing fails + return value; } - const result = new Date(value); - return isNaN(result.getTime()) - ? value // fallback to original value if parsing fails - : result; }); }) .catch(() => { @@ -128,16 +155,16 @@ export class PostgresCrudDialect extends LateralJoinDi return value.map((v) => this.transformInput(v, type, false)); } } else { - return match(type) - .with('DateTime', () => - value instanceof Date + switch (type) { + case 'DateTime': + return value instanceof Date ? value.toISOString() : typeof value === 'string' ? new Date(value).toISOString() - : value, - ) - .with('Decimal', () => (value !== null ? value.toString() : value)) - .with('Json', () => { + : value; + case 'Decimal': + return value !== null ? value.toString() : value; + case 'Json': if ( value === null || typeof value === 'string' || @@ -149,8 +176,9 @@ export class PostgresCrudDialect extends LateralJoinDi } else { return value; } - }) - .otherwise(() => value); + default: + return value; + } } } @@ -158,16 +186,23 @@ export class PostgresCrudDialect extends LateralJoinDi if (value === null || value === undefined) { return value; } - return match(type) - .with('DateTime', () => this.transformOutputDate(value)) - .with('Bytes', () => this.transformOutputBytes(value)) - .with('BigInt', () => this.transformOutputBigInt(value)) - .with('Decimal', () => this.transformDecimal(value)) - .when( - (type) => isEnum(this.schema, type), - () => this.transformOutputEnum(value, array), - ) - .otherwise(() => super.transformOutput(value, type, array)); + + switch (type) { + case 'DateTime': + return this.transformOutputDate(value); + case 'Bytes': + return this.transformOutputBytes(value); + case 'BigInt': + return this.transformOutputBigInt(value); + case 'Decimal': + return this.transformDecimal(value); + default: + if (isEnum(this.schema, type)) { + return this.transformOutputEnum(value, array); + } else { + return super.transformOutput(value, type, array); + } + } } private transformOutputBigInt(value: unknown) { @@ -323,26 +358,24 @@ export class PostgresCrudDialect extends LateralJoinDi operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown, ) { - return match(operation) - .with('array_contains', () => { + switch (operation) { + case 'array_contains': { const v = Array.isArray(value) ? value : [value]; return sql`${lhs} @> ${sql.val(JSON.stringify(v))}::jsonb`; - }) - .with('array_starts_with', () => - this.eb( + } + case 'array_starts_with': + return this.eb( this.eb.fn('jsonb_extract_path', [lhs, this.eb.val('0')]), '=', this.transformInput(value, 'Json', false), - ), - ) - .with('array_ends_with', () => - this.eb( + ); + case 'array_ends_with': + return this.eb( this.eb.fn('jsonb_extract_path', [lhs, sql`(jsonb_array_length(${lhs}) - 1)::text`]), '=', this.transformInput(value, 'Json', false), - ), - ) - .exhaustive(); + ); + } } protected override buildJsonArrayExistsPredicate( @@ -362,20 +395,7 @@ export class PostgresCrudDialect extends LateralJoinDi // reduce enum to text for type compatibility return 'text'; } else { - return ( - match(zmodelType) - .with('String', () => 'text') - .with('Boolean', () => 'boolean') - .with('Int', () => 'integer') - .with('BigInt', () => 'bigint') - .with('Float', () => 'double precision') - .with('Decimal', () => 'decimal') - .with('DateTime', () => 'timestamp') - .with('Bytes', () => 'bytea') - .with('Json', () => 'jsonb') - // fallback to text - .otherwise(() => 'text') - ); + return this.zmodelToSqlTypeMap[zmodelType] ?? 'text'; } } diff --git a/packages/orm/src/client/crud/dialects/sqlite.ts b/packages/orm/src/client/crud/dialects/sqlite.ts index 95e2910f8..28935c7c7 100644 --- a/packages/orm/src/client/crud/dialects/sqlite.ts +++ b/packages/orm/src/client/crud/dialects/sqlite.ts @@ -12,7 +12,6 @@ import { type SelectQueryBuilder, type SqlBool, } from 'kysely'; -import { match } from 'ts-pattern'; import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types'; import type { BuiltinType, FieldDef, GetModels, SchemaDef } from '../../../schema'; import { DELEGATE_JOINED_FIELD_PREFIX } from '../../constants'; @@ -90,18 +89,22 @@ export class SqliteCrudDialect extends BaseCrudDialect if (Array.isArray(value)) { return value.map((v) => this.transformInput(v, type, false)); } else { - return match(type) - .with('Boolean', () => (value ? 1 : 0)) - .with('DateTime', () => - value instanceof Date + switch (type) { + case 'Boolean': + return value ? 1 : 0; + case 'DateTime': + return value instanceof Date ? value.toISOString() : typeof value === 'string' ? new Date(value).toISOString() - : value, - ) - .with('Decimal', () => (value as Decimal).toString()) - .with('Bytes', () => Buffer.from(value as Uint8Array)) - .otherwise(() => value); + : value; + case 'Decimal': + return (value as Decimal).toString(); + case 'Bytes': + return Buffer.from(value as Uint8Array); + default: + return value; + } } } @@ -112,14 +115,22 @@ export class SqliteCrudDialect extends BaseCrudDialect // typed JSON field return this.transformOutputJson(value); } else { - return match(type) - .with('Boolean', () => this.transformOutputBoolean(value)) - .with('DateTime', () => this.transformOutputDate(value)) - .with('Bytes', () => this.transformOutputBytes(value)) - .with('Decimal', () => this.transformOutputDecimal(value)) - .with('BigInt', () => this.transformOutputBigInt(value)) - .with('Json', () => this.transformOutputJson(value)) - .otherwise(() => super.transformOutput(value, type, array)); + switch (type) { + case 'Boolean': + return this.transformOutputBoolean(value); + case 'DateTime': + return this.transformOutputDate(value); + case 'Bytes': + return this.transformOutputBytes(value); + case 'Decimal': + return this.transformOutputDecimal(value); + case 'BigInt': + return this.transformOutputBigInt(value); + case 'Json': + return this.transformOutputJson(value); + default: + return super.transformOutput(value, type, array); + } } } @@ -296,10 +307,10 @@ export class SqliteCrudDialect extends BaseCrudDialect ); } - if (typeof payload === 'object' && payload.include && typeof payload.include === 'object') { + if (typeof payload === 'object' && (payload as any).include && typeof (payload as any).include === 'object') { // include relation fields objArgs.push( - ...Object.entries(payload.include) + ...Object.entries((payload as any).include) .filter(([, value]) => value) .map(([field, value]) => { const subJson = this.buildRelationJSON( @@ -415,8 +426,8 @@ export class SqliteCrudDialect extends BaseCrudDialect operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown, ) { - return match(operation) - .with('array_contains', () => { + switch (operation) { + case 'array_contains': if (Array.isArray(value)) { throw createNotSupportedError( 'SQLite "array_contains" only supports checking for a single value, not an array of values', @@ -424,14 +435,11 @@ export class SqliteCrudDialect extends BaseCrudDialect } else { return sql`EXISTS (SELECT 1 FROM json_each(${lhs}) WHERE value = ${value})`; } - }) - .with('array_starts_with', () => - this.eb(this.eb.fn('json_extract', [lhs, this.eb.val('$[0]')]), '=', value), - ) - .with('array_ends_with', () => - this.eb(sql`json_extract(${lhs}, '$[' || (json_array_length(${lhs}) - 1) || ']')`, '=', value), - ) - .exhaustive(); + case 'array_starts_with': + return this.eb(this.eb.fn('json_extract', [lhs, this.eb.val('$[0]')]), '=', value); + case 'array_ends_with': + return this.eb(sql`json_extract(${lhs}, '$[' || (json_array_length(${lhs}) - 1) || ']')`, '=', value); + } } protected override buildJsonArrayExistsPredicate( diff --git a/packages/orm/src/client/crud/operations/base.ts b/packages/orm/src/client/crud/operations/base.ts index a12f0fe2a..46306c034 100644 --- a/packages/orm/src/client/crud/operations/base.ts +++ b/packages/orm/src/client/crud/operations/base.ts @@ -3,10 +3,8 @@ import { clone, enumerate, invariant, isPlainObject } from '@zenstackhq/common-h import { default as cuid1 } from 'cuid'; import { createQueryId, - DeleteResult, expressionBuilder, sql, - UpdateResult, type Compilable, type ExpressionBuilder, type IsolationLevel, @@ -565,7 +563,7 @@ export abstract class BaseOperationHandler { fromRelation.ids, m2m.otherModel, m2m.otherField, - createdEntity, + [createdEntity], m2m.joinTable, ); } @@ -657,40 +655,39 @@ export abstract class BaseOperationHandler { leftEntity: any, rightModel: string, rightField: string, - rightEntity: any, + rightEntities: any[], joinTable: string, - ): Promise { - const sortedRecords = [ - { - model: leftModel, - field: leftField, - entity: leftEntity, - }, - { - model: rightModel, - field: rightField, - entity: rightEntity, - }, - ].sort((a, b) => - // the implicit m2m join table's "A", "B" fk fields' order is determined - // by model name's sort order, and when identical (for self-relations), - // field name's sort order - a.model !== b.model ? a.model.localeCompare(b.model) : a.field.localeCompare(b.field), - ); + ): Promise { + if (rightEntities.length === 0) { + return; + } + + // the implicit m2m join table's "A", "B" fk fields' order is determined + // by model name's sort order, and when identical (for self-relations), + // field name's sort order + const leftFirst = + leftModel !== rightModel + ? leftModel.localeCompare(rightModel) <= 0 + : leftField.localeCompare(rightField) <= 0; - const firstIds = requireIdFields(this.schema, sortedRecords[0]!.model); - const secondIds = requireIdFields(this.schema, sortedRecords[1]!.model); - invariant(firstIds.length === 1, 'many-to-many relation must have exactly one id field'); - invariant(secondIds.length === 1, 'many-to-many relation must have exactly one id field'); + const leftIdField = requireIdFields(this.schema, leftModel); + const rightIdField = requireIdFields(this.schema, rightModel); + invariant(leftIdField.length === 1, 'many-to-many relation must have exactly one id field'); + invariant(rightIdField.length === 1, 'many-to-many relation must have exactly one id field'); + + const leftIdValue = leftEntity[leftIdField[0]!]; + const rightIdValues = rightEntities.map((e) => e[rightIdField[0]!]); // Prisma's convention for many-to-many: fk fields are named "A" and "B" if (action === 'connect') { - const result = await kysely + const values = rightIdValues.map((rightId) => ({ + A: leftFirst ? leftIdValue : rightId, + B: leftFirst ? rightId : leftIdValue, + })); + + await kysely .insertInto(joinTable as any) - .values({ - A: sortedRecords[0]!.entity[firstIds[0]!], - B: sortedRecords[1]!.entity[secondIds[0]!], - } as any) + .values(values as any) // case for `INSERT IGNORE` or `ON CONFLICT DO NOTHING` syntax .$if(this.dialect.insertIgnoreMethod === 'onConflict', (qb) => qb.onConflict((oc) => oc.columns(['A', 'B'] as any).doNothing()), @@ -698,15 +695,15 @@ export abstract class BaseOperationHandler { // case for `INSERT IGNORE` syntax .$if(this.dialect.insertIgnoreMethod === 'ignore', (qb) => qb.ignore()) .execute(); - return result[0] as any; } else { const eb = expressionBuilder(); - const result = await kysely + const [leftCol, rightCol] = leftFirst ? (['A', 'B'] as const) : (['B', 'A'] as const); + + await kysely .deleteFrom(joinTable as any) - .where(eb(`${joinTable}.A`, '=', sortedRecords[0]!.entity[firstIds[0]!])) - .where(eb(`${joinTable}.B`, '=', sortedRecords[1]!.entity[secondIds[0]!])) + .where(eb(`${joinTable}.${leftCol}`, '=', leftIdValue)) + .where(eb(`${joinTable}.${rightCol}`, 'in', rightIdValues)) .execute(); - return result[0] as any; } } @@ -1132,6 +1129,13 @@ export abstract class BaseOperationHandler { return formatExpr.value.replace(/(? { const parentWhere = await this.buildUpdateParentRelationFilter(kysely, fromRelation); - let combinedWhere: WhereInput, any, false> = where ?? {}; + let combinedWhere: Record = where ?? {}; if (Object.keys(parentWhere).length > 0) { combinedWhere = Object.keys(combinedWhere).length > 0 ? { AND: [parentWhere, combinedWhere] } : parentWhere; } + const origWhere = combinedWhere; const modelDef = this.requireModel(model); let finalData = data; @@ -1177,46 +1182,36 @@ export abstract class BaseOperationHandler { } } - // read pre-update entity with ids so that the caller can use it to identify - // the entity being updated, the read data is used as return value if no update - // is made to the entity - const thisEntity = await this.getEntityIds(kysely, model, combinedWhere); - if (!thisEntity) { - if (throwIfNotFound) { - throw createNotFoundError(model); - } else { - return null; + // lazily load the entity to be updated + let thisEntity: any; + const loadThisEntity = async () => { + if (thisEntity === undefined) { + thisEntity = (await this.getEntityIds(kysely, model, origWhere)) ?? null; + if (!thisEntity && throwIfNotFound) { + throw createNotFoundError(model); + } } - } - - if (Object.keys(finalData).length === 0) { return thisEntity; - } + }; - let needIdRead = false; - if (!this.isIdFilter(model, combinedWhere)) { - if (modelDef.baseModel) { - // when updating a model with delegate base, base fields may be referenced in the filter, - // so we read the id out if the filter is not ready an id filter, and and use it as the - // update filter instead - needIdRead = true; - } - if (!this.dialect.supportsReturning) { - // for dialects that don't support RETURNING, we need to read the id fields - // to identify the updated entity - needIdRead = true; - } + if (Object.keys(finalData).length === 0) { + return loadThisEntity(); } - if (needIdRead) { - const readResult = await this.readUnique(kysely, model, { - where: combinedWhere, - select: this.makeIdSelect(model), - }); - if (!readResult && throwIfNotFound) { - throw createNotFoundError(model); + if ( + // when updating a model with delegate base, base fields may be referenced in the filter, + // so we read the id out if the filter and and use it as the update filter instead + modelDef.baseModel || + // for dialects that don't support RETURNING, we need to read the id fields + // to identify the updated entity for toplevel updates + (!this.dialect.supportsReturning && !fromRelation) + ) { + // update the filter to db-loaded id fields + combinedWhere = await loadThisEntity(); + if (!combinedWhere) { + // not found + return null; } - combinedWhere = readResult; } if (modelDef.baseModel) { @@ -1227,20 +1222,32 @@ export abstract class BaseOperationHandler { finalData, throwIfNotFound, ); + + if (!baseUpdateResult.baseEntity) { + // base entity not found + if (throwIfNotFound) { + throw createNotFoundError(model); + } else { + return null; + } + } + // only fields not consumed by base update will be used for this model finalData = baseUpdateResult.remainingFields; // make sure to include only the id fields from the base entity in the final filter - combinedWhere = baseUpdateResult.baseEntity - ? getIdValues(this.schema, modelDef.baseModel!, baseUpdateResult.baseEntity) - : baseUpdateResult.baseEntity; + combinedWhere = getIdValues(this.schema, modelDef.baseModel!, baseUpdateResult.baseEntity); // update this entity with fields in updated base - if (baseUpdateResult.baseEntity) { + await loadThisEntity(); + if (thisEntity) { for (const [key, value] of Object.entries(baseUpdateResult.baseEntity)) { if (key in thisEntity) { thisEntity[key] = value; } } + } else { + // base entity not found + return null; } } @@ -1254,12 +1261,20 @@ export abstract class BaseOperationHandler { if (!allowRelationUpdate) { throw createNotSupportedError(`Relation update not allowed for field "${field}"`); } + + // load this entity for passing on to relation updates as parent + const relationParent = await loadThisEntity(); + if (!relationParent) { + // not found + return null; + } + const parentUpdates = await this.processRelationUpdates( kysely, model, field, fieldDef, - thisEntity, + relationParent, finalData[field], ); @@ -1278,18 +1293,17 @@ export abstract class BaseOperationHandler { if (!hasFieldUpdate) { // nothing to update, return the existing entity - return thisEntity; + return loadThisEntity(); } else { - fieldsToReturn = fieldsToReturn ?? requireIdFields(this.schema, model); - let updatedEntity: any; if (this.dialect.supportsReturning) { + const returnFields = fieldsToReturn !== undefined && fieldsToReturn.length > 0; const query = kysely .updateTable(model) .where(() => this.dialect.buildFilter(model, model, combinedWhere)) .set(updateFields) - .returning(fieldsToReturn as any) + .$if(returnFields, (qb) => qb.returning(fieldsToReturn as any)) .modifyEnd( this.makeContextComment({ model, @@ -1297,8 +1311,42 @@ export abstract class BaseOperationHandler { }), ); - updatedEntity = await this.executeQueryTakeFirst(kysely, query, 'update'); + if (returnFields) { + updatedEntity = await this.executeQueryTakeFirst(kysely, query, 'update'); + } else { + const r = await this.executeQuery(kysely, query, 'update'); + if (!r.numAffectedRows) { + // nothing updated + updatedEntity = null; + } else { + // if no specific fields to return, we are done, return `true` to indicate a successful update + updatedEntity = true; + } + } } else { + // post-update read filter + let readFilter = combinedWhere; + + // check if we are updating any id fields, if so, we need to fetch original entity ids + // before the update, and overwrite the filter with updated id values for post-update read + const idFields = requireIdFields(this.schema, model); + const updatingIdFields = idFields.some((idField) => idField in updateFields); + + if (updatingIdFields) { + const origIdValues = await loadThisEntity(); + invariant(origIdValues, 'Original entity should have been loaded for update without RETURNING'); + + readFilter = { ...origIdValues }; + // replace id fields in the filter with updated values if they are being updated + // const readFilter: any = { ...origWhere }; + for (const idField of idFields) { + if (idField in updateFields && updateFields[idField] !== undefined) { + // if id fields are being updated, use the new values + readFilter[idField] = updateFields[idField]; + } + } + } + // Fallback for databases that don't support RETURNING (e.g., MySQL) const updateQuery = kysely .updateTable(model) @@ -1312,37 +1360,19 @@ export abstract class BaseOperationHandler { ); const updateResult = await this.executeQuery(kysely, updateQuery, 'update'); + if (!updateResult.numAffectedRows) { - // no rows updated + // nothing updated updatedEntity = null; + } else if (fieldsToReturn === undefined || fieldsToReturn.length === 0) { + // if no specific fields to return, we are done, return `true` to indicate a successful update + updatedEntity = true; } else { - // collect id field/values from the original filter - const idFields = requireIdFields(this.schema, model); - const filterIdValues: any = {}; - for (const key of idFields) { - if (combinedWhere[key] !== undefined && typeof combinedWhere[key] !== 'object') { - filterIdValues[key] = combinedWhere[key]; - } - } - - // check if we are updating any id fields - const updatingIdFields = idFields.some((idField) => idField in updateFields); - - if (Object.keys(filterIdValues).length === idFields.length && !updatingIdFields) { - // if we have all id fields in the original filter and ids are not being updated, - // we can simply return the id values as the update result - updatedEntity = filterIdValues; + if (!updatingIdFields) { + // not updating id fields, we can directly return original id values + updatedEntity = await loadThisEntity(); } else { // otherwise we need to re-query the updated entity - - // replace id fields in the filter with updated values if they are being updated - const readFilter: any = { ...combinedWhere }; - for (const idField of idFields) { - if (idField in updateFields && updateFields[idField] !== undefined) { - // if id fields are being updated, use the new values - readFilter[idField] = updateFields[idField]; - } - } const selectQuery = kysely .selectFrom(model) .select(fieldsToReturn as any) @@ -1425,14 +1455,6 @@ export abstract class BaseOperationHandler { return ['increment', 'decrement', 'multiply', 'divide', 'set'].some((key) => key in value); } - private isIdFilter(model: string, filter: any) { - if (!filter || typeof filter !== 'object') { - return false; - } - const idFields = requireIdFields(this.schema, model); - return idFields.length === Object.keys(filter).length && idFields.every((field) => field in filter); - } - private async processBaseModelUpdate( kysely: ToKysely, model: string, @@ -1461,6 +1483,7 @@ export abstract class BaseOperationHandler { undefined, undefined, throwIfNotFound, + requireIdFields(this.schema, model), ); return { baseEntity, remainingFields }; } @@ -1895,31 +1918,22 @@ export abstract class BaseOperationHandler { const m2m = getManyToManyRelation(this.schema, fromRelation.model, fromRelation.field); if (m2m) { - // handle many-to-many relation - const results: (unknown | undefined)[] = []; - for (const d of _data) { - const ids = await this.getEntityIds(kysely, model, d); - if (!ids) { - throw createNotFoundError(model); - } - const r = await this.handleManyToManyRelation( - kysely, - 'connect', - fromRelation.model, - fromRelation.field, - fromRelation.ids, - m2m.otherModel!, - m2m.otherField!, - ids, - m2m.joinTable, - ); - results.push(r); - } - - // validate connect result - if (_data.length > results.filter((r) => !!r).length) { + // handle many-to-many relation: batch fetch all entity IDs in one query + const allIds = await this.getEntitiesIds(kysely, model, _data); + if (allIds.length !== _data.length) { throw createNotFoundError(model); } + await this.handleManyToManyRelation( + kysely, + 'connect', + fromRelation.model, + fromRelation.field, + fromRelation.ids, + m2m.otherModel!, + m2m.otherField!, + allIds, + m2m.joinTable, + ); } else { const { ownedByModel, keyPairs } = getRelationForeignKeyFieldPairs( this.schema, @@ -2031,13 +2045,9 @@ export abstract class BaseOperationHandler { const m2m = getManyToManyRelation(this.schema, fromRelation.model, fromRelation.field); if (m2m) { - // handle many-to-many relation - for (const d of disconnectConditions) { - const ids = await this.getEntityIds(kysely, model, d); - if (!ids) { - // not found - return; - } + // handle many-to-many relation: batch fetch all entity IDs in one query + const allIds = await this.getEntitiesIds(kysely, model, disconnectConditions); + if (allIds.length > 0) { await this.handleManyToManyRelation( kysely, 'disconnect', @@ -2046,7 +2056,7 @@ export abstract class BaseOperationHandler { fromRelation.ids, m2m.otherModel, m2m.otherField, - ids, + allIds, m2m.joinTable, ); } @@ -2132,32 +2142,24 @@ export abstract class BaseOperationHandler { // reset for the parent await this.resetManyToManyRelation(kysely, fromRelation.model, fromRelation.field, fromRelation.ids); - // connect new entities - const results: (unknown | undefined)[] = []; - for (const d of _data) { - const ids = await this.getEntityIds(kysely, model, d); - if (!ids) { + if (_data.length > 0) { + // batch fetch all entity IDs in one query + const allIds = await this.getEntitiesIds(kysely, model, _data); + if (allIds.length !== _data.length) { throw createNotFoundError(model); } - results.push( - await this.handleManyToManyRelation( - kysely, - 'connect', - fromRelation.model, - fromRelation.field, - fromRelation.ids, - m2m.otherModel, - m2m.otherField, - ids, - m2m.joinTable, - ), + await this.handleManyToManyRelation( + kysely, + 'connect', + fromRelation.model, + fromRelation.field, + fromRelation.ids, + m2m.otherModel, + m2m.otherField, + allIds, + m2m.joinTable, ); } - - // validate connect result - if (_data.length > results.filter((r) => !!r).length) { - throw createNotFoundError(model); - } } else { const { ownedByModel, keyPairs } = getRelationForeignKeyFieldPairs( this.schema, @@ -2487,6 +2489,18 @@ export abstract class BaseOperationHandler { } } + protected async safeTransactionIf( + condition: boolean, + callback: (tx: AnyKysely) => Promise, + isolationLevel?: IsolationLevel, + ) { + if (condition) { + return this.safeTransaction(callback, isolationLevel); + } else { + return callback(this.kysely); + } + } + // Given a unique filter of a model, load the entity and return its id fields private getEntityIds(kysely: AnyKysely, model: string, uniqueFilter: any) { return this.readUnique(kysely, model, { @@ -2495,6 +2509,14 @@ export abstract class BaseOperationHandler { }); } + // Given multiple unique filters, load all matching entities and return their id fields in one query + private getEntitiesIds(kysely: AnyKysely, model: string, uniqueFilters: any[]) { + return this.read(kysely, model, { + where: { OR: uniqueFilters }, + select: this.makeIdSelect(model), + } as any); + } + /** * Normalize input args to strip `undefined` fields */ @@ -2537,27 +2559,28 @@ export abstract class BaseOperationHandler { } protected mutationNeedsReadBack(model: string, args: any) { + const idFields = requireIdFields(this.schema, model); if (this.hasPolicyEnabled) { // TODO: refactor this check // policy enforcement always requires read back - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } if (!this.dialect.supportsReturning) { // if the dialect doesn't support RETURNING, we always need read back - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } if (args.include && typeof args.include === 'object' && Object.keys(args.include).length > 0) { // includes present, need read back to fetch relations - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } const modelDef = this.requireModel(model); if (modelDef.baseModel || modelDef.isDelegate) { // polymorphic model, need read back - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } const allFields = Object.keys(modelDef.fields); @@ -2588,7 +2611,7 @@ export abstract class BaseOperationHandler { if (allFieldsSelected.some((f) => relationFields.includes(f) || computedFields.includes(f))) { // relation or computed field selected, need read back - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } else { return { needReadBack: false, selectedFields: allFieldsSelected }; } diff --git a/packages/orm/src/client/crud/operations/create.ts b/packages/orm/src/client/crud/operations/create.ts index af3c85994..89f07270a 100644 --- a/packages/orm/src/client/crud/operations/create.ts +++ b/packages/orm/src/client/crud/operations/create.ts @@ -26,8 +26,10 @@ export class CreateOperationHandler extends BaseOperat // analyze if we need to read back the created record, or just return the create result const { needReadBack, selectedFields } = this.mutationNeedsReadBack(this.model, args); - // TODO: avoid using transaction for simple create - const result = await this.safeTransaction(async (tx) => { + // analyze if the create involves nested creates + const needsNestedCreate = this.needsNestedCreate(args.data); + + const result = await this.safeTransactionIf(needReadBack || needsNestedCreate, async (tx) => { const createResult = await this.create(tx, this.model, args.data, undefined, false, selectedFields); if (needReadBack) { @@ -58,7 +60,10 @@ export class CreateOperationHandler extends BaseOperat return { count: 0 }; } - return this.safeTransaction((tx) => this.createMany(tx, this.model, args, false)); + // analyze if the create involves nested creates + const needsNestedCreate = this.needsNestedCreate(args.data); + + return this.safeTransactionIf(needsNestedCreate, (tx) => this.createMany(tx, this.model, args, false)); } private async runCreateManyAndReturn(args?: any) { @@ -69,8 +74,10 @@ export class CreateOperationHandler extends BaseOperat // analyze if we need to read back the created record, or just return the create result const { needReadBack, selectedFields } = this.mutationNeedsReadBack(this.model, args); - // TODO: avoid using transaction for simple create - return this.safeTransaction(async (tx) => { + // analyze if the create involves nested creates + const needsNestedCreate = this.needsNestedCreate(args.data); + + return this.safeTransactionIf(needReadBack || needsNestedCreate, async (tx) => { const createResult = await this.createMany(tx, this.model, args, true, undefined, selectedFields); if (needReadBack) { @@ -90,4 +97,23 @@ export class CreateOperationHandler extends BaseOperat } }); } + + private needsNestedCreate(data: any) { + const modelDef = this.requireModel(this.model); + if (modelDef.baseModel) { + // involve delegate base models + return true; + } + + // has relation manipulation in the payload + const hasRelation = Object.entries(data).some(([field, value]) => { + const fieldDef = this.getField(this.model, field); + return fieldDef?.relation && value !== undefined; + }); + if (hasRelation) { + return true; + } + + return false; + } } diff --git a/packages/orm/src/client/crud/operations/delete.ts b/packages/orm/src/client/crud/operations/delete.ts index 295eba799..cc16a7be0 100644 --- a/packages/orm/src/client/crud/operations/delete.ts +++ b/packages/orm/src/client/crud/operations/delete.ts @@ -20,8 +20,10 @@ export class DeleteOperationHandler extends BaseOperat // analyze if we need to read back the deleted record, or just return delete result const { needReadBack, selectedFields } = this.mutationNeedsReadBack(this.model, args); - // TODO: avoid using transaction for simple delete - const result = await this.safeTransaction(async (tx) => { + // analyze if the delete involves nested deletes + const needsNestedDelete = this.needsNestedDelete(); + + const result = await this.safeTransactionIf(needReadBack || needsNestedDelete, async (tx) => { let preDeleteRead: any = undefined; if (needReadBack) { preDeleteRead = await this.readUnique(tx, this.model, { @@ -51,9 +53,33 @@ export class DeleteOperationHandler extends BaseOperat } async runDeleteMany(args?: any) { - return await this.safeTransaction(async (tx) => { + // analyze if the delete involves nested deletes + const needsNestedDelete = this.needsNestedDelete(); + + return await this.safeTransactionIf(needsNestedDelete, async (tx) => { const result = await this.delete(tx, this.model, args?.where, args?.limit); return { count: Number(result.numAffectedRows ?? 0) }; }); } + + private needsNestedDelete() { + const modelDef = this.requireModel(this.model); + if (modelDef.baseModel) { + return true; + } + + // Check if any relation points to a delegate sub-model with cascade delete, + // which would trigger processDelegateRelationDelete in BaseOperationHandler.delete() + for (const fieldDef of Object.values(modelDef.fields)) { + if (fieldDef.relation?.opposite) { + const oppositeModelDef = this.requireModel(fieldDef.type); + const oppositeRelation = this.requireField(fieldDef.type, fieldDef.relation.opposite); + if (oppositeModelDef.baseModel && oppositeRelation.relation?.onDelete === 'Cascade') { + return true; + } + } + } + + return false; + } } diff --git a/packages/orm/src/client/crud/operations/update.ts b/packages/orm/src/client/crud/operations/update.ts index 424945708..4b1d9b528 100644 --- a/packages/orm/src/client/crud/operations/update.ts +++ b/packages/orm/src/client/crud/operations/update.ts @@ -2,7 +2,7 @@ import { match } from 'ts-pattern'; import type { GetModels, SchemaDef } from '../../../schema'; import type { WhereInput } from '../../crud-types'; import { createRejectedByPolicyError, RejectedByPolicyReason } from '../../errors'; -import { getIdValues } from '../../query-utils'; +import { getIdValues, requireIdFields } from '../../query-utils'; import { BaseOperationHandler } from './base'; export class UpdateOperationHandler extends BaseOperationHandler { @@ -28,7 +28,10 @@ export class UpdateOperationHandler extends BaseOperat // analyze if we need to read back the update record, or just return the updated result const { needReadBack, selectedFields } = this.needReadBack(args); - const result = await this.safeTransaction(async (tx) => { + // analyze if the update involves nested updates + const needsNestedUpdate = this.needsNestedUpdate(args.data); + + const result = await this.safeTransactionIf(needReadBack || needsNestedUpdate, async (tx) => { const updateResult = await this.update( tx, this.model, @@ -76,10 +79,11 @@ export class UpdateOperationHandler extends BaseOperat return result; } } - private async runUpdateMany(args: any) { - // TODO: avoid using transaction for simple update - return this.safeTransaction(async (tx) => { + // analyze if the update involves nested updates + const needsNestedUpdate = this.needsNestedUpdate(args.data); + + return this.safeTransactionIf(needsNestedUpdate, async (tx) => { return this.updateMany(tx, this.model, args.where, args.data, args.limit, false); }); } @@ -92,37 +96,43 @@ export class UpdateOperationHandler extends BaseOperat // analyze if we need to read back the updated record, or just return the update result const { needReadBack, selectedFields } = this.needReadBack(args); - const { readBackResult, updateResult } = await this.safeTransaction(async (tx) => { - const updateResult = await this.updateMany( - tx, - this.model, - args.where, - args.data, - args.limit, - true, - undefined, - undefined, - selectedFields, - ); + // analyze if the update involves nested updates + const needsNestedUpdate = this.needsNestedUpdate(args.data); - if (needReadBack) { - const readBackResult = await this.read( + const { readBackResult, updateResult } = await this.safeTransactionIf( + needReadBack || needsNestedUpdate, + async (tx) => { + const updateResult = await this.updateMany( tx, this.model, - { - select: args.select, - omit: args.omit, - where: { - OR: updateResult.map((item) => getIdValues(this.schema, this.model, item) as any), - }, - } as any, // TODO: fix type + args.where, + args.data, + args.limit, + true, + undefined, + undefined, + selectedFields, ); - return { readBackResult, updateResult }; - } else { - return { readBackResult: updateResult, updateResult }; - } - }); + if (needReadBack) { + const readBackResult = await this.read( + tx, + this.model, + { + select: args.select, + omit: args.omit, + where: { + OR: updateResult.map((item) => getIdValues(this.schema, this.model, item) as any), + }, + } as any, // TODO: fix type + ); + + return { readBackResult, updateResult }; + } else { + return { readBackResult: updateResult, updateResult }; + } + }, + ); if (readBackResult.length < updateResult.length && this.hasPolicyEnabled) { // some of the updated entities cannot be read back @@ -140,6 +150,7 @@ export class UpdateOperationHandler extends BaseOperat // analyze if we need to read back the updated record, or just return the update result const { needReadBack, selectedFields } = this.needReadBack(args); + // upsert is intrinsically multi-step and is always run in a transaction const result = await this.safeTransaction(async (tx) => { let mutationResult: unknown = await this.update( tx, @@ -191,9 +202,11 @@ export class UpdateOperationHandler extends BaseOperat return baseResult; } + const idFields = requireIdFields(this.schema, this.model); + if (!this.dialect.supportsReturning) { // if dialect doesn't support "returning", we always need to read back - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } // further check if we're not updating any non-relation fields, because if so, @@ -206,14 +219,33 @@ export class UpdateOperationHandler extends BaseOperat // update/updateMany payload if (args.data && !Object.keys(args.data).some((field) => nonRelationFields.includes(field))) { - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } // upsert payload if (args.update && !Object.keys(args.update).some((field: string) => nonRelationFields.includes(field))) { - return { needReadBack: true, selectedFields: undefined }; + return { needReadBack: true, selectedFields: idFields }; } return baseResult; } + + private needsNestedUpdate(data: any) { + const modelDef = this.requireModel(this.model); + if (modelDef.baseModel) { + // involve delegate base models + return true; + } + + // has relation manipulation in the payload + const hasRelation = Object.entries(data).some(([field, value]) => { + const fieldDef = this.getField(this.model, field); + return fieldDef?.relation && value !== undefined; + }); + if (hasRelation) { + return true; + } + + return false; + } } diff --git a/packages/orm/src/client/crud/validator/validator.ts b/packages/orm/src/client/crud/validator/validator.ts index 1acba6f15..001302152 100644 --- a/packages/orm/src/client/crud/validator/validator.ts +++ b/packages/orm/src/client/crud/validator/validator.ts @@ -25,11 +25,23 @@ import { ZodSchemaFactory } from '../../zod/factory'; type GetSchemaFunc = (model: GetModels) => ZodType; +export type InputValidatorOptions = { + /** + * Whether validation is enabled. Defaults to `true`. + */ + enabled?: boolean; +}; + export class InputValidator { readonly zodFactory: ZodSchemaFactory; + private readonly enabled: boolean; - constructor(private readonly client: ClientContract) { + constructor( + private readonly client: ClientContract, + options?: InputValidatorOptions, + ) { this.zodFactory = new ZodSchemaFactory(client); + this.enabled = options?.enabled !== false; } // #region Entry points @@ -183,6 +195,9 @@ export class InputValidator { // TODO: turn it into a Zod schema and cache validateProcedureInput(proc: string, input: unknown): unknown { + if (!this.enabled) { + return input; + } const procDef = (this.client.$schema.procedures ?? {})[proc] as ProcedureDef | undefined; invariant(procDef, `Procedure "${proc}" not found in schema`); @@ -270,6 +285,9 @@ export class InputValidator { // #region Validation helpers private validate(model: GetModels, operation: string, getSchema: GetSchemaFunc, args: unknown) { + if (!this.enabled) { + return args as T; + } const schema = getSchema(model); const { error, data } = schema.safeParse(args); if (error) { diff --git a/packages/orm/src/client/diagnostics.ts b/packages/orm/src/client/diagnostics.ts new file mode 100644 index 000000000..1493b17b6 --- /dev/null +++ b/packages/orm/src/client/diagnostics.ts @@ -0,0 +1,49 @@ +/** + * Zod schema cache statistics. + */ +export interface ZodCacheStats { + /** + * Number of cached Zod schemas. + */ + size: number; + + /** + * Keys of the cached Zod schemas. + */ + keys: string[]; +} + +/** + * Information about a query, used for diagnostics. + */ +export interface QueryInfo { + /** + * Time when the query started. + */ + startedAt: Date; + + /** + * Duration of the query in milliseconds. + */ + durationMs: number; + + /** + * SQL statement of the query. + */ + sql: string; +} + +/** + * ZenStackClient diagnostics. + */ +export interface Diagnostics { + /** + * Statistics about the Zod schemas (used for query args validation) cache. + */ + zodCache: ZodCacheStats; + + /** + * Slow queries. + */ + slowQueries: QueryInfo[]; +} diff --git a/packages/orm/src/client/executor/name-mapper.ts b/packages/orm/src/client/executor/name-mapper.ts index 6a7535fe0..369526cd6 100644 --- a/packages/orm/src/client/executor/name-mapper.ts +++ b/packages/orm/src/client/executor/name-mapper.ts @@ -37,8 +37,8 @@ import { getEnum, getField, getModel, + getModelFields, isEnum, - requireModel, stripAlias, } from '../query-utils'; @@ -66,7 +66,7 @@ export class QueryNameMapper extends OperationNodeTransformer { this.modelToTableMap.set(modelName, mappedName); } - for (const fieldDef of this.getModelFields(modelDef)) { + for (const fieldDef of getModelFields(this.schema, modelName)) { const mappedName = this.getMappedName(fieldDef); if (mappedName) { this.fieldToColumnMap.set(`${modelName}.${fieldDef.name}`, mappedName); @@ -431,7 +431,7 @@ export class QueryNameMapper extends OperationNodeTransformer { if (!modelDef) { continue; } - if (this.getModelFields(modelDef).some((f) => f.name === name)) { + if (getModelFields(this.schema, scope.model).some((f) => f.name === name)) { return scope; } } @@ -560,8 +560,7 @@ export class QueryNameMapper extends OperationNodeTransformer { } private createSelectAllFields(model: string, alias: OperationNode | undefined) { - const modelDef = requireModel(this.schema, model); - return this.getModelFields(modelDef).map((fieldDef) => { + return getModelFields(this.schema, model).map((fieldDef) => { const columnName = this.mapFieldName(model, fieldDef.name); const columnRef = ReferenceNode.create( ColumnNode.create(columnName), @@ -576,9 +575,6 @@ export class QueryNameMapper extends OperationNodeTransformer { }); } - private getModelFields(modelDef: ModelDef) { - return Object.values(modelDef.fields).filter((f) => !f.relation && !f.computed && !f.originModel); - } private processSelections(selections: readonly SelectionNode[]) { const result: SelectionNode[] = []; @@ -627,9 +623,8 @@ export class QueryNameMapper extends OperationNodeTransformer { } // expand select all to a list of selections with name mapping - const modelDef = requireModel(this.schema, scope.model); - return this.getModelFields(modelDef).map((fieldDef) => { - const columnName = this.mapFieldName(modelDef.name, fieldDef.name); + return getModelFields(this.schema, scope.model).map((fieldDef) => { + const columnName = this.mapFieldName(scope.model!, fieldDef.name); const columnRef = ReferenceNode.create(ColumnNode.create(columnName)); // process enum value mapping @@ -660,7 +655,7 @@ export class QueryNameMapper extends OperationNodeTransformer { if (!modelDef) { return false; } - return this.getModelFields(modelDef).some((fieldDef) => { + return getModelFields(this.schema, model).some((fieldDef) => { const enumDef = getEnum(this.schema, fieldDef.type); if (!enumDef) { return false; diff --git a/packages/orm/src/client/executor/zenstack-query-executor.ts b/packages/orm/src/client/executor/zenstack-query-executor.ts index 52afde140..186af02c3 100644 --- a/packages/orm/src/client/executor/zenstack-query-executor.ts +++ b/packages/orm/src/client/executor/zenstack-query-executor.ts @@ -31,7 +31,7 @@ import { } from 'kysely'; import { match } from 'ts-pattern'; import type { ModelDef, SchemaDef, TypeDefDef } from '../../schema'; -import { type ClientImpl } from '../client-impl'; +import type { ClientImpl } from '../client-impl'; import { TransactionIsolationLevel, type ClientContract } from '../contract'; import { getCrudDialect } from '../crud/dialects'; import type { BaseCrudDialect } from '../crud/dialects/base-dialect'; @@ -70,6 +70,8 @@ type CallAfterMutationHooksArgs = { afterMutationEntities?: Record[]; }; +const DEFAULT_MAX_SLOW_RECORDS = 100; + export class ZenStackQueryExecutor extends DefaultQueryExecutor { // #region constructor, fields and props @@ -124,6 +126,10 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor { return (this.client.$options.plugins ?? []).some((plugin) => plugin.onEntityMutation?.afterEntityMutation); } + private get hasOnKyselyHooks() { + return (this.client.$options.plugins ?? []).some((plugin) => plugin.onKyselyQuery); + } + // #endregion // #region main entry point @@ -133,11 +139,20 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor { // if the query is a raw query, we need to carry over the parameters const queryParams = (compiledQuery as any).$raw ? compiledQuery.parameters : undefined; + // needs to ensure transaction if we: + // - have plugins with Kysely hooks, as they may spawn more queries (check: should creating tx be plugin's responsibility?) + // - have entity mutation plugins + const needEnsureTx = this.hasOnKyselyHooks || this.hasEntityMutationPlugins; + const result = await this.provideConnection(async (connection) => { let startedTx = false; try { // mutations are wrapped in tx if not already in one - if (this.isMutationNode(compiledQuery.query) && !this.driver.isTransactionConnection(connection)) { + if ( + this.isMutationNode(compiledQuery.query) && + !this.driver.isTransactionConnection(connection) && + needEnsureTx + ) { await this.driver.beginTransaction(connection, { isolationLevel: TransactionIsolationLevel.ReadCommitted, }); @@ -673,8 +688,17 @@ In such cases, ZenStack cannot reliably determine the IDs of the mutated entitie compiledQuery = { ...compiledQuery, parameters: parameters }; } + const trackSlowQuery = this.options.diagnostics !== undefined; + const startTimestamp = trackSlowQuery ? performance.now() : undefined; + const startedAt = trackSlowQuery ? new Date() : undefined; + try { const result = await connection.executeQuery(compiledQuery); + + if (startTimestamp !== undefined) { + this.trackSlowQuery(compiledQuery, startTimestamp, startedAt!); + } + return this.ensureProperQueryResult(compiledQuery.query, result); } catch (err) { throw createDBQueryError( @@ -686,6 +710,38 @@ In such cases, ZenStack cannot reliably determine the IDs of the mutated entitie } } + private trackSlowQuery(compiledQuery: CompiledQuery, startTimestamp: number, startedAt: Date) { + const durationMs = performance.now() - startTimestamp; + const thresholdMs = this.options.diagnostics?.slowQueryThresholdMs; + if (thresholdMs === undefined || durationMs < thresholdMs) { + return; + } + + const slowQueries = this.client.slowQueries; + const maxRecords = this.options.diagnostics?.slowQueryMaxRecords ?? DEFAULT_MAX_SLOW_RECORDS; + if (maxRecords <= 0) { + return; + } + + const queryInfo = { startedAt, durationMs, sql: compiledQuery.sql }; + + if (slowQueries.length >= maxRecords) { + // find and remove the entry with the lowest duration + let minIndex = 0; + for (let i = 1; i < slowQueries.length; i++) { + if (slowQueries[i]!.durationMs < slowQueries[minIndex]!.durationMs) { + minIndex = i; + } + } + // only replace if the new query is slower than the minimum + if (durationMs > slowQueries[minIndex]!.durationMs) { + slowQueries[minIndex] = queryInfo; + } + } else { + slowQueries.push(queryInfo); + } + } + private ensureProperQueryResult(query: RootOperationNode, result: QueryResult) { let finalResult = result; diff --git a/packages/orm/src/client/helpers/schema-db-pusher.ts b/packages/orm/src/client/helpers/schema-db-pusher.ts index 4886687ef..f84a29004 100644 --- a/packages/orm/src/client/helpers/schema-db-pusher.ts +++ b/packages/orm/src/client/helpers/schema-db-pusher.ts @@ -12,7 +12,7 @@ import { type SchemaDef, } from '../../schema'; import type { ToKysely } from '../query-builder'; -import { requireModel } from '../query-utils'; +import { isUnsupportedField, requireModel } from '../query-utils'; /** * This class is for testing purposes only. It should never be used in production. @@ -117,6 +117,11 @@ export class SchemaDbPusher { continue; } + if (isUnsupportedField(fieldDef)) { + // Unsupported fields cannot be represented in the ORM's schema pusher + continue; + } + if (fieldDef.relation) { table = this.addForeignKeyConstraint(table, modelDef.name, fieldName, fieldDef); } else if (!this.isComputedField(fieldDef)) { diff --git a/packages/orm/src/client/options.ts b/packages/orm/src/client/options.ts index e2622d6cf..1461d637f 100644 --- a/packages/orm/src/client/options.ts +++ b/packages/orm/src/client/options.ts @@ -178,7 +178,8 @@ export type ClientOptions = QueryOptions & { plugins?: AnyPlugin[]; /** - * Logging configuration. + * Logging configuration. Extends Kysely's log config with a `'warning'` level + * for ZenStack-specific diagnostics (e.g., slow query warnings). */ log?: KyselyConfig['log']; @@ -193,8 +194,11 @@ export type ClientOptions = QueryOptions & { fixPostgresTimezone?: boolean; /** - * Whether to enable input validations expressed with attributes like `@email`, `@regex`, - * `@@validate`, etc. Defaults to `true`. + * Whether to enable query args validation. Defaults to `true`. + * + * **USE WITH CAUTION**, as setting it to `false` will allow malformed input to pass through, causing + * incorrect SQL generation or runtime errors. If you use validation attributes like `@email`, `@regex`, + * etc., in ZModel, they will be ignored too. */ validateInput?: boolean; @@ -208,9 +212,25 @@ export type ClientOptions = QueryOptions & { useCompactAliasNames?: boolean; /** - * Whether to skip validation for computed fields. + * Whether to skip validation for whether all computed fields are properly defined. */ skipValidationForComputedFields?: boolean; + + /** + * Diagnostics related options. + */ + diagnostics?: { + /** + * Threshold in milliseconds for determining slow queries. If not specified, no query will be considered slow. + */ + slowQueryThresholdMs?: number; + + /** + * Maximum number of slow query records to keep in memory. Defaults to `100`. When the number is exceeded, the + * entry with the lowest duration will be removed. Set to `Infinity` to keep unlimited records. + */ + slowQueryMaxRecords?: number; + }; } & (HasComputedFields extends true ? { /** @@ -232,13 +252,13 @@ export type ClientOptions = QueryOptions & { * Config for omitting fields in ORM query results. */ export type OmitConfig = { - [Model in GetModels]?: { + [Model in GetModels as Uncapitalize]?: { [Field in GetModelFields as Field extends ScalarFields ? Field : never]?: boolean; }; }; export type ComputedFieldsOptions = { - [Model in GetModels as 'computedFields' extends keyof GetModel ? Model : never]: { + [Model in GetModels as 'computedFields' extends keyof GetModel ? Uncapitalize : never]: { [Field in keyof Schema['models'][Model]['computedFields']]: Schema['models'][Model]['computedFields'][Field] extends infer Func ? Func extends (...args: any[]) => infer R ? ( diff --git a/packages/orm/src/client/plugin.ts b/packages/orm/src/client/plugin.ts index e531242e3..7535b6872 100644 --- a/packages/orm/src/client/plugin.ts +++ b/packages/orm/src/client/plugin.ts @@ -1,8 +1,9 @@ import type { OperationNode, QueryId, QueryResult, RootOperationNode, UnknownRow } from 'kysely'; import type { ZodType } from 'zod'; import type { ClientContract, ZModelFunction } from '.'; -import type { GetModels, SchemaDef } from '../schema'; +import type { GetModelFields, GetModels, NonRelationFields, SchemaDef } from '../schema'; import type { MaybePromise } from '../utils/type-utils'; +import type { MapModelFieldType } from './crud-types'; import type { AllCrudOperations, CoreCrudOperations } from './crud/operations/base'; type AllowedExtQueryArgKeys = CoreCrudOperations | '$create' | '$read' | '$update' | '$delete' | '$all'; @@ -20,6 +21,59 @@ export type ExtQueryArgsBase = { */ export type ExtClientMembersBase = Record; +/** + * Base shape of plugin-extended result fields. + * Keyed by model name, each value maps field names to their definitions. + * `needs` keys are constrained to non-relation fields of the corresponding model. + */ +export type ExtResultBase = { + [M in GetModels as Uncapitalize]?: Record< + string, + { + needs: Partial, true>>; + compute: (...args: any[]) => any; + } + >; +}; + +/** + * Mapped type that provides per-field contextual typing for `compute` callbacks + * based on the `needs` declaration. Uses a separate type parameter `R_` that captures + * the needs shape (model → field → { neededField: true }), then links each field's + * `compute` parameter to exactly the keys declared in its `needs`. + */ +export type ExtResultInferenceArgs = { + [K in keyof R_ & string]: { + [P in keyof R_[K]]?: { + needs?: { + // constraint for `needs` keys + [F in keyof R_[K][P]]: F extends NonRelationFields> ? true : never; + } & Partial>, true>>; // further intersects with all possible keys for intellisense + + // refine `computes`'s parameter type based on the inferred type of `needs` + compute: (data: ExtResultComputeData, R_[K][P]>) => unknown; + }; + }; +}; + +/** + * Reverse-maps an uncapitalized key back to the original model name in the schema. + * E.g., for a schema with model `myModel`, the key `myModel` maps back to `myModel` + * (not `MyModel` as `Capitalize` would produce). + */ +type ModelNameFromKey = { + [M in GetModels]: Uncapitalize extends K ? M : never; +}[GetModels]; + +/** + * Maps the needs shape `S` to an object with actual schema field types. + * For each key in `S` that is a valid non-relation field of model `M`, + * resolves the TypeScript type from the schema field definition. + */ +type ExtResultComputeData, S> = { + [F in keyof S & GetModelFields]: MapModelFieldType; +}; + /** * ZenStack runtime plugin. */ @@ -27,6 +81,7 @@ export interface RuntimePlugin< Schema extends SchemaDef, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends Record, + ExtResult extends ExtResultBase, > { /** * Plugin ID. @@ -81,19 +136,80 @@ export interface RuntimePlugin< * Extended client members (methods and properties). */ client?: ExtClientMembers; + + /** + * Extended result fields on query results. + * Keyed by model name, each value defines computed fields with `needs` and `compute`. + */ + result?: ExtResult; } -export type AnyPlugin = RuntimePlugin; +export type AnyPlugin = RuntimePlugin; /** - * Defines a ZenStack runtime plugin. + * Defines a ZenStack runtime plugin based on type of the given schema. + * + * @see {@link https://zenstack.dev/docs/orm/plugins/|Plugin Documentation} + * + * @example + * ```typescript + * definePlugin(schema, { + * id: 'my-plugin', + * result: { + * user: { + * fullName: { + * needs: { firstName: true, lastName: true }, + * compute: (user) => `${user.firstName} ${user.lastName}`, + * }, + * }, + * }, + * }); + * ``` */ export function definePlugin< Schema extends SchemaDef, const ExtQueryArgs extends ExtQueryArgsBase = {}, const ExtClientMembers extends Record = {}, ->(plugin: RuntimePlugin): RuntimePlugin { - return plugin; + const ExtResult extends ExtResultBase = {}, + R_ = {}, +>( + schema: Schema, + plugin: RuntimePlugin & { + result?: ExtResultInferenceArgs; + }, +): RuntimePlugin; + +/** + * Defines a ZenStack runtime plugin. + * + * @see {@link https://zenstack.dev/docs/orm/plugins/|Plugin Documentation} + * + * @example + * ```typescript + * definePlugin(schema, { + * id: 'my-plugin', + * result: { + * user: { + * fullName: { + * needs: { firstName: true, lastName: true }, + * compute: (user) => `${user.firstName} ${user.lastName}`, + * }, + * }, + * }, + * }); + * ``` + * */ +export function definePlugin< + Schema extends SchemaDef, + const ExtQueryArgs extends ExtQueryArgsBase = {}, + const ExtClientMembers extends Record = {}, + const ExtResult extends ExtResultBase = {}, +>( + plugin: RuntimePlugin, +): RuntimePlugin; + +export function definePlugin(...args: unknown[]) { + return args.length === 2 ? args[1] : args[0]; } // #region OnProcedure hooks diff --git a/packages/orm/src/client/query-utils.ts b/packages/orm/src/client/query-utils.ts index 0ea7ea58a..2e8b134b3 100644 --- a/packages/orm/src/client/query-utils.ts +++ b/packages/orm/src/client/query-utils.ts @@ -70,12 +70,12 @@ export function requireField(schema: SchemaDef, modelOrType: string, field: stri } /** - * Gets all model fields, by default non-relation, non-computed, non-inherited fields only. + * Gets all model fields, by default non-relation, non-computed, non-inherited, non-unsupported fields only. */ export function getModelFields( schema: SchemaDef, model: string, - options?: { relations?: boolean; computed?: boolean; inherited?: boolean }, + options?: { relations?: boolean; computed?: boolean; inherited?: boolean; unsupported?: boolean }, ) { const modelDef = requireModel(schema, model); return Object.values(modelDef.fields).filter((f) => { @@ -88,10 +88,20 @@ export function getModelFields( if (f.originModel && !options?.inherited) { return false; } + if (f.type === 'Unsupported' && !options?.unsupported) { + return false; + } return true; }); } +/** + * Checks if a field is of `Unsupported` type. + */ +export function isUnsupportedField(fieldDef: FieldDef) { + return fieldDef.type === 'Unsupported'; +} + export function getIdFields(schema: SchemaDef, model: GetModels) { const modelDef = getModel(schema, model); return modelDef?.idFields; diff --git a/packages/orm/src/client/result-processor.ts b/packages/orm/src/client/result-processor.ts index fc8ae1938..38d1aa103 100644 --- a/packages/orm/src/client/result-processor.ts +++ b/packages/orm/src/client/result-processor.ts @@ -22,19 +22,47 @@ export class ResultProcessor { } private doProcessResult(data: any, model: GetModels) { + // pre-resolve field definitions from the first row's keys + const firstRow = Array.isArray(data) ? data[0] : data; + if (!firstRow || typeof firstRow !== 'object') { + return data; + } + + const fields = this.resolveFields(firstRow, model); + if (Array.isArray(data)) { - data.forEach((row, i) => (data[i] = this.processRow(row, model))); + data.forEach((row, i) => (data[i] = this.processRow(row, fields))); return data; } else { - return this.processRow(data, model); + return this.processRow(data, fields); + } + } + + private resolveFields(row: any, model: GetModels): FieldDef[] { + if (!row || typeof row !== 'object') { + return []; + } + const result: FieldDef[] = []; + for (const key of Object.keys(row)) { + if (key === '_count' || key.startsWith(DELEGATE_JOINED_FIELD_PREFIX)) { + continue; + } + const fieldDef = getField(this.schema, model, key); + if (fieldDef) { + result.push(fieldDef); + } } + return result; } - private processRow(data: any, model: GetModels) { + private processRow(data: any, fields: FieldDef[]) { if (!data || typeof data !== 'object') { return data; } - for (const [key, value] of Object.entries(data)) { + + // handle special keys + for (const key of Object.keys(data)) { + const value = data[key]; if (value === undefined) { continue; } @@ -42,10 +70,7 @@ export class ResultProcessor { if (key === '_count') { // underlying database provider may return string for count data[key] = typeof value === 'string' ? JSON.parse(value) : value; - continue; - } - - if (key.startsWith(DELEGATE_JOINED_FIELD_PREFIX)) { + } else if (key.startsWith(DELEGATE_JOINED_FIELD_PREFIX)) { // merge delegate descendant fields if (value) { // descendant fields are packed as JSON @@ -59,34 +84,38 @@ export class ResultProcessor { delete data[key]; continue; } - const processedSubRow = this.processRow(subRow, subModel); + const subFields = this.resolveFields(subRow, subModel); + const processedSubRow = this.processRow(subRow, subFields); // merge the sub-row into the main row Object.assign(data, processedSubRow); } delete data[key]; - continue; } + } - const fieldDef = getField(this.schema, model, key); - if (!fieldDef) { + // process regular fields using pre-resolved field definitions + for (const fieldDef of fields) { + const value = data[fieldDef.name]; + if (value === undefined) { continue; } if (value === null) { // scalar list defaults to empty array - if (fieldDef.array && !fieldDef.relation && value === null) { - data[key] = []; + if (fieldDef.array && !fieldDef.relation) { + data[fieldDef.name] = []; } continue; } if (fieldDef.relation) { - data[key] = this.processRelation(value, fieldDef); + data[fieldDef.name] = this.processRelation(value, fieldDef); } else { - data[key] = this.processFieldValue(value, fieldDef); + data[fieldDef.name] = this.processFieldValue(value, fieldDef); } } + return data; } diff --git a/packages/orm/src/client/type-utils.ts b/packages/orm/src/client/type-utils.ts index 3a4589f71..68e79a6c0 100644 --- a/packages/orm/src/client/type-utils.ts +++ b/packages/orm/src/client/type-utils.ts @@ -1,8 +1,39 @@ -import type { GetModels, SchemaDef } from '@zenstackhq/schema'; +import type { FieldDef, GetModel, GetModels, IsDelegateModel, SchemaDef } from '@zenstackhq/schema'; import type { GetProcedureNames } from './crud-types'; import type { AllCrudOperations } from './crud/operations/base'; import type { FilterKind, QueryOptions, SlicingOptions } from './options'; +/** + * Checks if a model has any required Unsupported fields (non-optional, no default). + * Uses raw field access since `GetModelFields` excludes Unsupported fields. + */ +export type ModelHasRequiredUnsupportedField> = true extends { + [Key in Extract['fields'], string>]: GetModel< + Schema, + Model + >['fields'][Key] extends infer F extends FieldDef + ? F['type'] extends 'Unsupported' + ? F['optional'] extends true + ? false + : 'default' extends keyof F + ? false + : true + : false + : false; +}[Extract['fields'], string>] + ? true + : false; + +/** + * Checks if a model allows create operations (not a delegate model and has no required Unsupported fields). + */ +export type ModelAllowsCreate> = + IsDelegateModel extends true + ? false + : ModelHasRequiredUnsupportedField extends true + ? false + : true; + type IsNever = [T] extends [never] ? true : false; // #region Model slicing diff --git a/packages/orm/src/client/zod/factory.ts b/packages/orm/src/client/zod/factory.ts index 0f0eb61e8..7166f42f7 100644 --- a/packages/orm/src/client/zod/factory.ts +++ b/packages/orm/src/client/zod/factory.ts @@ -64,6 +64,15 @@ type FieldInfo = { array?: boolean; }; +function toFieldInfo(def: FieldDef): FieldInfo { + return { + name: def.name, + type: def.type, + optional: def.optional, + array: def.array, + }; +} + /** * Create a factory for generating Zod schemas to validate ORM query inputs. */ @@ -108,6 +117,7 @@ export class ZodSchemaFactory< private readonly allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))]; private readonly schema: Schema; private readonly options: Options; + private readonly extraValidationsEnabled = true; constructor(client: ClientContract); constructor(schema: Schema, options?: Options); @@ -121,12 +131,16 @@ export class ZodSchemaFactory< } } - private get plugins(): RuntimePlugin[] { + private get plugins(): RuntimePlugin[] { return this.options.plugins ?? []; } - private get extraValidationsEnabled() { - return this.options.validateInput !== false; + /** + * Returns model field entries, excluding Unsupported fields. + */ + private getModelFields(model: string): [string, FieldDef][] { + const modelDef = requireModel(this.schema, model); + return Object.entries(modelDef.fields).filter(([, def]) => def.type !== 'Unsupported'); } private shouldIncludeRelations(options?: CreateSchemaOptions): boolean { @@ -151,14 +165,11 @@ export class ZodSchemaFactory< return this.schemaCache.set(cacheKey, schema); } - // @ts-ignore - private printCacheStats(detailed = false) { - console.log('Schema cache size:', this.schemaCache.size); - if (detailed) { - for (const key of this.schemaCache.keys()) { - console.log(`\t${key}`); - } - } + get cacheStats() { + return { + size: this.schemaCache.size, + keys: [...this.schemaCache.keys()], + }; } // #endregion @@ -337,8 +348,6 @@ export class ZodSchemaFactory< withAggregations = false, options?: CreateSchemaOptions, ): ZodType { - const modelDef = requireModel(this.schema, model); - // unique field used in unique filters bypass filter slicing const uniqueFieldNames = unique ? getUniqueFields(this.schema, model) @@ -353,8 +362,7 @@ export class ZodSchemaFactory< const nextOpts = this.nextOptions(options); const fields: Record = {}; - for (const field of Object.keys(modelDef.fields)) { - const fieldDef = requireField(this.schema, model, field); + for (const [field, fieldDef] of this.getModelFields(model)) { let fieldSchema: ZodType | undefined; if (fieldDef.relation) { @@ -403,16 +411,26 @@ export class ZodSchemaFactory< if (enumDef) { // enum if (Object.keys(enumDef.values).length > 0) { - fieldSchema = this.makeEnumFilterSchema(model, fieldDef, withAggregations, ignoreSlicing); + fieldSchema = this.makeEnumFilterSchema( + model, + toFieldInfo(fieldDef), + withAggregations, + ignoreSlicing, + ); } } else if (fieldDef.array) { // array field - fieldSchema = this.makeArrayFilterSchema(model, fieldDef); + fieldSchema = this.makeArrayFilterSchema(model, toFieldInfo(fieldDef)); } else if (this.isTypeDefType(fieldDef.type)) { - fieldSchema = this.makeTypedJsonFilterSchema(model, fieldDef); + fieldSchema = this.makeTypedJsonFilterSchema(model, toFieldInfo(fieldDef)); } else { // primitive field - fieldSchema = this.makePrimitiveFilterSchema(model, fieldDef, withAggregations, ignoreSlicing); + fieldSchema = this.makePrimitiveFilterSchema( + model, + toFieldInfo(fieldDef), + withAggregations, + ignoreSlicing, + ); } } @@ -437,12 +455,22 @@ export class ZodSchemaFactory< if (enumDef) { // enum if (Object.keys(enumDef.values).length > 0) { - fieldSchema = this.makeEnumFilterSchema(model, def, false, true); + fieldSchema = this.makeEnumFilterSchema( + model, + toFieldInfo(def), + false, + true, + ); } else { fieldSchema = z.never(); } } else { - fieldSchema = this.makePrimitiveFilterSchema(model, def, false, true); + fieldSchema = this.makePrimitiveFilterSchema( + model, + toFieldInfo(def), + false, + true, + ); } return [key, fieldSchema]; }), @@ -514,18 +542,28 @@ export class ZodSchemaFactory< for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) { if (this.isTypeDefType(fieldDef.type)) { // recursive typed JSON - use same model/field for nested typed JSON - fieldSchemas[fieldName] = this.makeTypedJsonFilterSchema(contextModel, fieldDef).optional(); + fieldSchemas[fieldName] = this.makeTypedJsonFilterSchema( + contextModel, + toFieldInfo(fieldDef), + ).optional(); } else { // enum, array, primitives const enumDef = getEnum(this.schema, fieldDef.type); if (enumDef) { - fieldSchemas[fieldName] = this.makeEnumFilterSchema(contextModel, fieldDef, false).optional(); + fieldSchemas[fieldName] = this.makeEnumFilterSchema( + contextModel, + toFieldInfo(fieldDef), + false, + ).optional(); } else if (fieldDef.array) { - fieldSchemas[fieldName] = this.makeArrayFilterSchema(contextModel, fieldDef).optional(); + fieldSchemas[fieldName] = this.makeArrayFilterSchema( + contextModel, + toFieldInfo(fieldDef), + ).optional(); } else { fieldSchemas[fieldName] = this.makePrimitiveFilterSchema( contextModel, - fieldDef, + toFieldInfo(fieldDef), false, ).optional(); } @@ -877,10 +915,8 @@ export class ZodSchemaFactory< @cache() private makeSelectSchema(model: string, options?: CreateSchemaOptions) { - const modelDef = requireModel(this.schema, model); const fields: Record = {}; - for (const field of Object.keys(modelDef.fields)) { - const fieldDef = requireField(this.schema, model, field); + for (const [field, fieldDef] of this.getModelFields(model)) { if (fieldDef.relation) { if (!this.shouldIncludeRelations(options)) { continue; @@ -901,6 +937,8 @@ export class ZodSchemaFactory< } } + this.addExtResultFields(model, fields); + return z.strictObject(fields); } @@ -992,10 +1030,8 @@ export class ZodSchemaFactory< @cache() private makeOmitSchema(model: string) { - const modelDef = requireModel(this.schema, model); const fields: Record = {}; - for (const field of Object.keys(modelDef.fields)) { - const fieldDef = requireField(this.schema, model, field); + for (const [field, fieldDef] of this.getModelFields(model)) { if (!fieldDef.relation) { if (this.options.allowQueryTimeOmitOverride !== false) { // if override is allowed, use boolean @@ -1006,9 +1042,26 @@ export class ZodSchemaFactory< } } } + + this.addExtResultFields(model, fields); + return z.strictObject(fields); } + private addExtResultFields(model: string, fields: Record) { + for (const plugin of this.plugins) { + const resultConfig = plugin.result; + if (resultConfig) { + const modelConfig = resultConfig[lowerCaseFirst(model)]; + if (modelConfig) { + for (const field of Object.keys(modelConfig)) { + fields[field] = z.boolean().optional(); + } + } + } + } + } + @cache() private makeIncludeSchema(model: string, options?: CreateSchemaOptions) { const modelDef = requireModel(this.schema, model); @@ -1043,12 +1096,10 @@ export class ZodSchemaFactory< WithAggregation: boolean, options?: CreateSchemaOptions, ) { - const modelDef = requireModel(this.schema, model); const fields: Record = {}; const sort = z.union([z.literal('asc'), z.literal('desc')]); const nextOpts = this.nextOptions(options); - for (const field of Object.keys(modelDef.fields)) { - const fieldDef = requireField(this.schema, model, field); + for (const [field, fieldDef] of this.getModelFields(model)) { if (fieldDef.relation) { // relations if (withRelation && this.shouldIncludeRelations(options)) { @@ -1098,8 +1149,9 @@ export class ZodSchemaFactory< @cache() private makeDistinctSchema(model: string) { - const modelDef = requireModel(this.schema, model); - const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation); + const nonRelationFields = this.getModelFields(model) + .filter(([, def]) => !def.relation) + .map(([name]) => name); return nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields as any), true) : z.never(); } @@ -1170,20 +1222,18 @@ export class ZodSchemaFactory< const uncheckedVariantFields: Record = {}; const checkedVariantFields: Record = {}; const modelDef = requireModel(this.schema, model); + const modelFields = this.getModelFields(model); const hasRelation = - !skipRelations && - Object.entries(modelDef.fields).some(([f, def]) => !withoutFields.includes(f) && def.relation); + !skipRelations && modelFields.some(([f, def]) => !withoutFields.includes(f) && def.relation); const nextOpts = this.nextOptions(options); - Object.keys(modelDef.fields).forEach((field) => { + modelFields.forEach(([field, fieldDef]) => { if (withoutFields.includes(field)) { return; } - const fieldDef = requireField(this.schema, model, field); - - // skip computed fields and discriminator fields, they cannot be set on create + // skip computed fields and discriminator fields if (fieldDef.computed || fieldDef.isDiscriminator) { return; } @@ -1302,21 +1352,28 @@ export class ZodSchemaFactory< const fieldDef = requireField(this.schema, model, field); const fieldType = fieldDef.type; const array = !!fieldDef.array; + const canCreateModel = this.canCreateModel(fieldType); const fields: Record = { - create: this.makeCreateDataSchema( + connect: this.makeConnectDataSchema(fieldType, array, options).optional(), + }; + + if (canCreateModel) { + fields['create'] = this.makeCreateDataSchema( fieldDef.type, !!fieldDef.array, withoutFields, false, options, - ).optional(), - - connect: this.makeConnectDataSchema(fieldType, array, options).optional(), - - connectOrCreate: this.makeConnectOrCreateDataSchema(fieldType, array, withoutFields, options).optional(), - }; + ).optional(); + fields['connectOrCreate'] = this.makeConnectOrCreateDataSchema( + fieldType, + array, + withoutFields, + options, + ).optional(); + } - if (array) { + if (array && canCreateModel) { fields['createMany'] = this.makeCreateManyPayloadSchema(fieldType, withoutFields, options).optional(); } @@ -1346,19 +1403,21 @@ export class ZodSchemaFactory< ]) .optional(); - let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options); - if (!fieldDef.array) { - // to-one relation, can upsert without where clause - upsertWhere = upsertWhere.optional(); + if (canCreateModel) { + let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options); + if (!fieldDef.array) { + // to-one relation, can upsert without where clause + upsertWhere = upsertWhere.optional(); + } + fields['upsert'] = this.orArray( + z.strictObject({ + where: upsertWhere, + create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options), + update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options), + }), + true, + ).optional(); } - fields['upsert'] = this.orArray( - z.strictObject({ - where: upsertWhere, - create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options), - update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options), - }), - true, - ).optional(); if (array) { // to-many relation specifics @@ -1524,21 +1583,19 @@ export class ZodSchemaFactory< const uncheckedVariantFields: Record = {}; const checkedVariantFields: Record = {}; const modelDef = requireModel(this.schema, model); + const modelFields = this.getModelFields(model); const hasRelation = - !skipRelations && - Object.entries(modelDef.fields).some(([key, value]) => value.relation && !withoutFields.includes(key)); + !skipRelations && modelFields.some(([key, value]) => value.relation && !withoutFields.includes(key)); const nextOpts = this.nextOptions(options); - Object.keys(modelDef.fields).forEach((field) => { + modelFields.forEach(([field, fieldDef]) => { if (withoutFields.includes(field)) { return; } - const fieldDef = requireField(this.schema, model, field); - + // skip computed fields and discriminator fields if (fieldDef.computed || fieldDef.isDiscriminator) { - // skip computed fields and discriminator fields, they cannot be updated return; } @@ -1698,13 +1755,12 @@ export class ZodSchemaFactory< @cache() private makeCountAggregateInputSchema(model: string) { - const modelDef = requireModel(this.schema, model); return z.union([ z.literal(true), z.strictObject({ _all: z.literal(true).optional(), - ...Object.keys(modelDef.fields).reduce( - (acc, field) => { + ...this.getModelFields(model).reduce( + (acc, [field]) => { acc[field] = z.literal(true).optional(); return acc; }, @@ -1741,11 +1797,9 @@ export class ZodSchemaFactory< @cache() private makeSumAvgInputSchema(model: string) { - const modelDef = requireModel(this.schema, model); return z.strictObject( - Object.keys(modelDef.fields).reduce( - (acc, field) => { - const fieldDef = requireField(this.schema, model, field); + this.getModelFields(model).reduce( + (acc, [field, fieldDef]) => { if (this.isNumericField(fieldDef)) { acc[field] = z.literal(true).optional(); } @@ -1758,11 +1812,9 @@ export class ZodSchemaFactory< @cache() private makeMinMaxInputSchema(model: string) { - const modelDef = requireModel(this.schema, model); return z.strictObject( - Object.keys(modelDef.fields).reduce( - (acc, field) => { - const fieldDef = requireField(this.schema, model, field); + this.getModelFields(model).reduce( + (acc, [field, fieldDef]) => { if (!fieldDef.relation && !fieldDef.array) { acc[field] = z.literal(true).optional(); } @@ -1782,8 +1834,9 @@ export class ZodSchemaFactory< model: Model, options?: CreateSchemaOptions, ): ZodType> { - const modelDef = requireModel(this.schema, model); - const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation); + const nonRelationFields = this.getModelFields(model) + .filter(([, def]) => !def.relation) + .map(([name]) => name); const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields as [string, ...string[]]), true) @@ -2185,10 +2238,20 @@ export class ZodSchemaFactory< } } - /** - * Checks if a model is included in the slicing configuration. - * Returns true if the model is allowed, false if it's excluded. - */ + private canCreateModel(model: string) { + const modelDef = requireModel(this.schema, model); + if (modelDef.isDelegate) { + return false; + } + const hasRequiredUnsupportedFields = Object.values(modelDef.fields).some( + (fieldDef) => fieldDef.type === 'Unsupported' && !fieldDef.optional && !fieldHasDefaultValue(fieldDef), + ); + if (hasRequiredUnsupportedFields) { + return false; + } + return true; + } + private isModelAllowed(targetModel: string): boolean { const slicing = this.options.slicing; if (!slicing) { diff --git a/packages/plugins/policy/package.json b/packages/plugins/policy/package.json index 712aa1a9f..22a953a22 100644 --- a/packages/plugins/policy/package.json +++ b/packages/plugins/policy/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/plugin-policy", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Policy Plugin", "type": "module", "scripts": { diff --git a/packages/plugins/policy/src/options.ts b/packages/plugins/policy/src/options.ts new file mode 100644 index 000000000..7858b4e72 --- /dev/null +++ b/packages/plugins/policy/src/options.ts @@ -0,0 +1,8 @@ +export type PolicyPluginOptions = { + /** + * Dangerously bypasses access-policy enforcement for raw SQL queries. + * Raw queries remain in the current transaction, but the policy plugin will + * not inspect or reject them. + */ + dangerouslyAllowRawSql?: boolean; +}; diff --git a/packages/plugins/policy/src/plugin.ts b/packages/plugins/policy/src/plugin.ts index 3f67309f3..61bf7b73a 100644 --- a/packages/plugins/policy/src/plugin.ts +++ b/packages/plugins/policy/src/plugin.ts @@ -1,9 +1,14 @@ import { type OnKyselyQueryArgs, type RuntimePlugin } from '@zenstackhq/orm'; import type { SchemaDef } from '@zenstackhq/orm/schema'; +import type { PolicyPluginOptions } from './options'; import { check } from './functions'; import { PolicyHandler } from './policy-handler'; -export class PolicyPlugin implements RuntimePlugin { +export type { PolicyPluginOptions } from './options'; + +export class PolicyPlugin implements RuntimePlugin { + constructor(private readonly options: PolicyPluginOptions = {}) {} + get id() { return 'policy' as const; } @@ -23,7 +28,7 @@ export class PolicyPlugin implements RuntimePlugin { } onKyselyQuery({ query, client, proceed }: OnKyselyQueryArgs) { - const handler = new PolicyHandler(client); + const handler = new PolicyHandler(client, this.options); return handler.handle(query, proceed); } } diff --git a/packages/plugins/policy/src/policy-handler.ts b/packages/plugins/policy/src/policy-handler.ts index 968703957..ba634d89d 100644 --- a/packages/plugins/policy/src/policy-handler.ts +++ b/packages/plugins/policy/src/policy-handler.ts @@ -23,6 +23,7 @@ import { OperatorNode, ParensNode, PrimitiveValueListNode, + RawNode, ReferenceNode, ReturningNode, SelectAllNode, @@ -42,6 +43,7 @@ import { import { match } from 'ts-pattern'; import { ColumnCollector } from './column-collector'; import { ExpressionTransformer } from './expression-transformer'; +import type { PolicyPluginOptions } from './options'; import type { Policy, PolicyOperation } from './types'; import { buildIsFalse, @@ -67,19 +69,21 @@ export class PolicyHandler extends OperationNodeTransf private readonly dialect: BaseCrudDialect; private readonly eb = expressionBuilder(); - constructor(private readonly client: ClientContract) { + constructor( + private readonly client: ClientContract, + private readonly options: PolicyPluginOptions = {}, + ) { super(); this.dialect = getCrudDialect(this.client.$schema, this.client.$options); } - get kysely() { - return this.client.$qb; - } - // #region main entry point async handle(node: RootOperationNode, proceed: ProceedKyselyQueryFunction) { if (!this.isCrudQueryNode(node)) { + if (this.options.dangerouslyAllowRawSql && RawNode.is(node as never)) { + return proceed(node); + } // non-CRUD queries are not allowed throw createRejectedByPolicyError( undefined, diff --git a/packages/schema/README.md b/packages/schema/README.md new file mode 100644 index 000000000..70f407f40 --- /dev/null +++ b/packages/schema/README.md @@ -0,0 +1,9 @@ +# @zenstackhq/schema + +Runtime schema representation for ZenStack. Defines the TypeScript types and accessor utilities for the compiled schema that `zenstack generate` produces from ZModel files. This schema object describes models, fields, relations, expressions, and other metadata used by packages like `@zenstackhq/orm` and `@zenstackhq/server` at runtime. + +## Installation + +```bash +npm install @zenstackhq/schema +``` diff --git a/packages/schema/package.json b/packages/schema/package.json index eeee4da61..6f0607cbe 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/schema", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Runtime Schema", "type": "module", "scripts": { diff --git a/packages/schema/src/schema.ts b/packages/schema/src/schema.ts index e21b5e30e..2475991ce 100644 --- a/packages/schema/src/schema.ts +++ b/packages/schema/src/schema.ts @@ -63,6 +63,8 @@ export type UpdatedAtInfo = { ignore?: readonly string[]; }; +export type FieldDefault = MappedBuiltinType | Expression | readonly unknown[]; + export type FieldDef = { name: string; type: string; @@ -72,7 +74,7 @@ export type FieldDef = { unique?: boolean; updatedAt?: boolean | UpdatedAtInfo; attributes?: readonly AttributeApplication[]; - default?: MappedBuiltinType | Expression | readonly unknown[]; + default?: FieldDefault; omit?: boolean; relation?: RelationInfo; foreignKeyFor?: readonly string[]; @@ -150,10 +152,15 @@ export type GetTypeDefs = Extract> = Schema['typeDefs'] extends Record ? Schema['typeDefs'][TypeDef] : never; -export type GetModelFields> = Extract< - keyof GetModel['fields'], - string ->; +export type GetModelFields> = keyof { + [Key in Extract['fields'], string> as FieldIsUnsupported< + Schema, + Model, + Key + > extends true + ? never + : Key]: never; +}; export type GetModelField< Schema extends SchemaDef, @@ -281,11 +288,21 @@ export type FieldIsComputed< Field extends GetModelFields, > = GetModelField['computed'] extends true ? true : false; +export type FieldIsUnsupported< + Schema extends SchemaDef, + Model extends GetModels, + Field extends string, +> = Field extends keyof GetModel['fields'] + ? GetModel['fields'][Field]['type'] extends 'Unsupported' + ? true + : false + : never; + export type FieldHasDefault< Schema extends SchemaDef, Model extends GetModels, Field extends GetModelFields, -> = GetModelField['default'] extends object | number | string | boolean +> = 'default' extends keyof GetModelField ? true : GetModelField['updatedAt'] extends true | UpdatedAtInfo ? true diff --git a/packages/sdk/README.md b/packages/sdk/README.md new file mode 100644 index 000000000..ef14bdfe5 --- /dev/null +++ b/packages/sdk/README.md @@ -0,0 +1,20 @@ +# @zenstackhq/sdk + +The ZenStack SDK for code generation and schema processing. Provides utilities for working with the ZModel AST, generating TypeScript schema output, building CLI plugins, and interacting with Prisma schema artifacts. This package is primarily used internally by the CLI and plugin authors. + +## Key Capabilities + +- ZModel AST traversal and model utilities +- TypeScript schema code generation from ZModel +- CLI plugin interface for extending `zenstack generate` +- Prisma schema interop utilities + +## Installation + +```bash +npm install @zenstackhq/sdk +``` + +## Learn More + +- [ZenStack Documentation](https://zenstack.dev/docs) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5275702ce..dd1a18c32 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack SDK", "type": "module", "scripts": { diff --git a/packages/sdk/src/ts-schema-generator.ts b/packages/sdk/src/ts-schema-generator.ts index b10068a3f..fda31fe97 100644 --- a/packages/sdk/src/ts-schema-generator.ts +++ b/packages/sdk/src/ts-schema-generator.ts @@ -64,13 +64,12 @@ export type TsSchemaGeneratorOptions = { export class TsSchemaGenerator { private usedExpressionUtils = false; + private usedAttributeApplication = false; + private usedFieldDefault = false; async generate(model: Model, options: TsSchemaGeneratorOptions) { fs.mkdirSync(options.outDir, { recursive: true }); - // Reset the flag for each generation - this.usedExpressionUtils = false; - // the schema itself this.generateSchema(model, options); @@ -95,6 +94,11 @@ export class TsSchemaGenerator { } for (const { lite, file } of targets) { + // Reset per-target import flags so each target tracks its own usage + this.usedExpressionUtils = false; + this.usedAttributeApplication = false; + this.usedFieldDefault = false; + const statements: ts.Statement[] = []; this.generateSchemaStatements(model, statements, lite); this.generateBannerComments(statements); @@ -130,6 +134,24 @@ export class TsSchemaGenerator { undefined, ts.factory.createNamedImports([ ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('SchemaDef')), + ...(this.usedAttributeApplication + ? [ + ts.factory.createImportSpecifier( + true, + undefined, + ts.factory.createIdentifier('AttributeApplication'), + ), + ] + : []), + ...(this.usedFieldDefault + ? [ + ts.factory.createImportSpecifier( + true, + undefined, + ts.factory.createIdentifier('FieldDefault'), + ), + ] + : []), ...(this.usedExpressionUtils ? [ ts.factory.createImportSpecifier( @@ -285,6 +307,22 @@ export class TsSchemaGenerator { return ts.factory.createAsExpression(expr, ts.factory.createTypeReferenceNode('const')); } + private createAttributesTypeAssertion(expr: ts.Expression): ts.Expression { + this.usedAttributeApplication = true; + return ts.factory.createAsExpression( + expr, + ts.factory.createTypeOperatorNode( + ts.SyntaxKind.ReadonlyKeyword, + ts.factory.createArrayTypeNode(ts.factory.createTypeReferenceNode('AttributeApplication')), + ), + ); + } + + private createDefaultTypeAssertion(expr: ts.Expression): ts.Expression { + this.usedFieldDefault = true; + return ts.factory.createAsExpression(expr, ts.factory.createTypeReferenceNode('FieldDefault')); + } + private createProviderObject(model: Model): ts.Expression { const dsProvider = this.getDataSourceProvider(model); const defaultSchema = this.getDataSourceDefaultSchema(model); @@ -374,9 +412,11 @@ export class TsSchemaGenerator { ? [ ts.factory.createPropertyAssignment( 'attributes', - ts.factory.createArrayLiteralExpression( - allAttributes.map((attr) => this.createAttributeObject(attr)), - true, + this.createAttributesTypeAssertion( + ts.factory.createArrayLiteralExpression( + allAttributes.map((attr) => this.createAttributeObject(attr)), + true, + ), ), ), ] @@ -458,9 +498,11 @@ export class TsSchemaGenerator { ? [ ts.factory.createPropertyAssignment( 'attributes', - ts.factory.createArrayLiteralExpression( - allAttributes.map((attr) => this.createAttributeObject(attr)), - true, + this.createAttributesTypeAssertion( + ts.factory.createArrayLiteralExpression( + allAttributes.map((attr) => this.createAttributeObject(attr)), + true, + ), ), ), ] @@ -608,8 +650,10 @@ export class TsSchemaGenerator { objectFields.push( ts.factory.createPropertyAssignment( 'attributes', - ts.factory.createArrayLiteralExpression( - field.attributes.map((attr) => this.createAttributeObject(attr)), + this.createAttributesTypeAssertion( + ts.factory.createArrayLiteralExpression( + field.attributes.map((attr) => this.createAttributeObject(attr)), + ), ), ), ); @@ -617,62 +661,45 @@ export class TsSchemaGenerator { const defaultValue = this.getFieldMappedDefault(field); if (defaultValue !== undefined) { + let defaultExpr: ts.Expression; if (defaultValue === null) { - objectFields.push( - ts.factory.createPropertyAssignment('default', this.createExpressionUtilsCall('_null')), - ); + defaultExpr = this.createExpressionUtilsCall('_null'); } else if (typeof defaultValue === 'object' && !Array.isArray(defaultValue)) { if ('call' in defaultValue) { - objectFields.push( - ts.factory.createPropertyAssignment( - 'default', - this.createExpressionUtilsCall('call', [ - ts.factory.createStringLiteral(defaultValue.call), - ...(defaultValue.args.length > 0 - ? [ - ts.factory.createArrayLiteralExpression( - defaultValue.args.map((arg) => - this.createExpressionUtilsCall('literal', [ - this.createLiteralNode(arg), - ]), - ), - ), - ] - : []), - ]), - ), - ); + defaultExpr = this.createExpressionUtilsCall('call', [ + ts.factory.createStringLiteral(defaultValue.call), + ...(defaultValue.args.length > 0 + ? [ + ts.factory.createArrayLiteralExpression( + defaultValue.args.map((arg) => + this.createExpressionUtilsCall('literal', [ + this.createLiteralNode(arg), + ]), + ), + ), + ] + : []), + ]); } else if ('authMember' in defaultValue) { - objectFields.push( - ts.factory.createPropertyAssignment( - 'default', - this.createExpressionUtilsCall('member', [ - this.createExpressionUtilsCall('call', [ts.factory.createStringLiteral('auth')]), - ts.factory.createArrayLiteralExpression( - defaultValue.authMember.map((m) => ts.factory.createStringLiteral(m)), - ), - ]), + defaultExpr = this.createExpressionUtilsCall('member', [ + this.createExpressionUtilsCall('call', [ts.factory.createStringLiteral('auth')]), + ts.factory.createArrayLiteralExpression( + defaultValue.authMember.map((m) => ts.factory.createStringLiteral(m)), ), - ); + ]); } else { throw new Error(`Unsupported default value type for field ${field.name}`); } + } else if (Array.isArray(defaultValue)) { + defaultExpr = ts.factory.createArrayLiteralExpression( + defaultValue.map((item) => this.createLiteralNode(item as any)), + ); } else { - if (Array.isArray(defaultValue)) { - objectFields.push( - ts.factory.createPropertyAssignment( - 'default', - ts.factory.createArrayLiteralExpression( - defaultValue.map((item) => this.createLiteralNode(item as any)), - ), - ), - ); - } else { - objectFields.push( - ts.factory.createPropertyAssignment('default', this.createLiteralNode(defaultValue)), - ); - } + defaultExpr = this.createLiteralNode(defaultValue); } + objectFields.push( + ts.factory.createPropertyAssignment('default', this.createDefaultTypeAssertion(defaultExpr)), + ); } if (hasAttribute(field, '@computed')) { @@ -688,9 +715,17 @@ export class TsSchemaGenerator { objectFields.push( ts.factory.createPropertyAssignment( 'foreignKeyFor', - ts.factory.createArrayLiteralExpression( - fkFor.map((fk) => ts.factory.createStringLiteral(fk)), - true, + ts.factory.createAsExpression( + ts.factory.createArrayLiteralExpression( + fkFor.map((fk) => ts.factory.createStringLiteral(fk)), + true, + ), + ts.factory.createTypeOperatorNode( + ts.SyntaxKind.ReadonlyKeyword, + ts.factory.createArrayTypeNode( + ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), + ), + ), ), ), ); @@ -1070,11 +1105,13 @@ export class TsSchemaGenerator { ? [ ts.factory.createPropertyAssignment( 'attributes', - ts.factory.createArrayLiteralExpression( - field.attributes?.map((attr) => - this.createAttributeObject(attr), - ) ?? [], - true, + this.createAttributesTypeAssertion( + ts.factory.createArrayLiteralExpression( + field.attributes?.map((attr) => + this.createAttributeObject(attr), + ) ?? [], + true, + ), ), ), ] @@ -1094,9 +1131,11 @@ export class TsSchemaGenerator { ? [ ts.factory.createPropertyAssignment( 'attributes', - ts.factory.createArrayLiteralExpression( - e.attributes.map((attr) => this.createAttributeObject(attr)), - true, + this.createAttributesTypeAssertion( + ts.factory.createArrayLiteralExpression( + e.attributes.map((attr) => this.createAttributeObject(attr)), + true, + ), ), ), ] diff --git a/packages/server/README.md b/packages/server/README.md new file mode 100644 index 000000000..03f0c75f7 --- /dev/null +++ b/packages/server/README.md @@ -0,0 +1,40 @@ +# @zenstackhq/server + +Automatic CRUD API handlers and server adapters for ZenStack. Exposes your ZenStack ORM as RESTful or RPC-style API endpoints with built-in OpenAPI spec generation. + +## Supported Frameworks + +- **Express** +- **Fastify** +- **Next.js** +- **Nuxt** +- **SvelteKit** +- **Hono** +- **Elysia** +- **TanStack Start** + +## API Styles + +- **REST** — Resource-oriented endpoints with [JSON:API](https://jsonapi.org/) support +- **RPC** — Procedure-call style endpoints + +## Installation + +```bash +npm install @zenstackhq/server +``` + +## Usage (Express example) + +```typescript +import express from 'express'; +import { ZenStackMiddleware } from '@zenstackhq/server/express'; +import { RPCApiHandler } from '@zenstackhq/server/api'; + +const app = express(); +app.use('/api/model', ZenStackMiddleware({...})); +``` + +## Learn More + +- [ZenStack Documentation](https://zenstack.dev/docs) diff --git a/packages/server/package.json b/packages/server/package.json index 1f2acd1ce..db0a14b3c 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack automatic CRUD API handlers and server adapters", "type": "module", "scripts": { @@ -8,6 +8,7 @@ "watch": "tsup-node --watch", "lint": "eslint src --ext ts", "test": "vitest run", + "update-baseline": "UPDATE_BASELINE=1 vitest run test/openapi", "pack": "pnpm pack" }, "keywords": [ @@ -124,6 +125,7 @@ "@zenstackhq/common-helpers": "workspace:*", "@zenstackhq/orm": "workspace:*", "decimal.js": "catalog:", + "openapi-types": "^12.1.3", "superjson": "^2.2.3", "ts-japi": "^1.12.1", "ts-pattern": "catalog:", @@ -131,6 +133,7 @@ "zod-validation-error": "catalog:" }, "devDependencies": { + "@readme/openapi-parser": "^6.0.0", "@sveltejs/kit": "catalog:", "@types/body-parser": "^1.19.6", "@types/express": "^5.0.0", diff --git a/packages/server/src/api/common/schemas.ts b/packages/server/src/api/common/schemas.ts index 44e30665c..e11c885e6 100644 --- a/packages/server/src/api/common/schemas.ts +++ b/packages/server/src/api/common/schemas.ts @@ -1,3 +1,27 @@ import z from 'zod'; export const loggerSchema = z.union([z.enum(['debug', 'info', 'warn', 'error']).array(), z.function()]); + +const fieldSlicingSchema = z.looseObject({ + includedFilterKinds: z.string().array().optional(), + excludedFilterKinds: z.string().array().optional(), +}); + +const modelSlicingSchema = z.looseObject({ + includedOperations: z.array(z.string()).optional(), + excludedOperations: z.array(z.string()).optional(), + fields: z.record(z.string(), fieldSlicingSchema).optional(), +}); + +const slicingSchema = z.looseObject({ + includedModels: z.array(z.string()).optional(), + excludedModels: z.array(z.string()).optional(), + models: z.record(z.string(), modelSlicingSchema).optional(), + includedProcedures: z.array(z.string()).optional(), + excludedProcedures: z.array(z.string()).optional(), +}); + +export const queryOptionsSchema = z.looseObject({ + omit: z.record(z.string(), z.record(z.string(), z.boolean())).optional(), + slicing: slicingSchema.optional(), +}); diff --git a/packages/server/src/api/common/spec-utils.ts b/packages/server/src/api/common/spec-utils.ts new file mode 100644 index 000000000..f469f79aa --- /dev/null +++ b/packages/server/src/api/common/spec-utils.ts @@ -0,0 +1,115 @@ +import { lowerCaseFirst } from '@zenstackhq/common-helpers'; +import type { QueryOptions } from '@zenstackhq/orm'; +import { ExpressionUtils, type AttributeApplication, type SchemaDef } from '@zenstackhq/orm/schema'; + +/** + * Checks if a model is included based on slicing options. + */ +export function isModelIncluded(modelName: string, queryOptions?: QueryOptions): boolean { + const slicing = queryOptions?.slicing; + if (!slicing) return true; + + const excluded = slicing.excludedModels as readonly string[] | undefined; + if (excluded?.includes(modelName)) return false; + + const included = slicing.includedModels as readonly string[] | undefined; + if (included && !included.includes(modelName)) return false; + + return true; +} + +/** + * Checks if a CRUD operation is included for a model based on slicing options. + */ +export function isOperationIncluded(modelName: string, op: string, queryOptions?: QueryOptions): boolean { + const slicing = queryOptions?.slicing; + if (!slicing?.models) return true; + + const modelKey = lowerCaseFirst(modelName); + const modelSlicing = (slicing.models as Record)[modelKey] ?? (slicing.models as any).$all; + if (!modelSlicing) return true; + + const excluded = modelSlicing.excludedOperations as readonly string[] | undefined; + if (excluded?.includes(op)) return false; + + const included = modelSlicing.includedOperations as readonly string[] | undefined; + if (included && !included.includes(op)) return false; + + return true; +} + +/** + * Checks if a procedure is included based on slicing options. + */ +export function isProcedureIncluded(procName: string, queryOptions?: QueryOptions): boolean { + const slicing = queryOptions?.slicing; + if (!slicing) return true; + + const excluded = slicing.excludedProcedures as readonly string[] | undefined; + if (excluded?.includes(procName)) return false; + + const included = slicing.includedProcedures as readonly string[] | undefined; + if (included && !included.includes(procName)) return false; + + return true; +} + +/** + * Checks if a field should be omitted from the output schema based on queryOptions.omit. + */ +export function isFieldOmitted(modelName: string, fieldName: string, queryOptions?: QueryOptions): boolean { + const omit = queryOptions?.omit as Record> | undefined; + return omit?.[modelName]?.[fieldName] === true; +} + +/** + * Returns the list of model names from the schema that pass the slicing filter. + */ +export function getIncludedModels(schema: SchemaDef, queryOptions?: QueryOptions): string[] { + return Object.keys(schema.models).filter((name) => isModelIncluded(name, queryOptions)); +} + +/** + * Checks if a filter kind is allowed for a specific field based on slicing options. + */ +export function isFilterKindIncluded( + modelName: string, + fieldName: string, + filterKind: string, + queryOptions?: QueryOptions, +): boolean { + const slicing = queryOptions?.slicing; + if (!slicing?.models) return true; + + const modelKey = lowerCaseFirst(modelName); + const modelSlicing = (slicing.models as Record)[modelKey] ?? (slicing.models as any).$all; + if (!modelSlicing?.fields) return true; + + const fieldSlicing = modelSlicing.fields[fieldName] ?? modelSlicing.fields.$all; + if (!fieldSlicing) return true; + + const excluded = fieldSlicing.excludedFilterKinds as readonly string[] | undefined; + if (excluded?.includes(filterKind)) return false; + + const included = fieldSlicing.includedFilterKinds as readonly string[] | undefined; + if (included && !included.includes(filterKind)) return false; + + return true; +} + +/** + * Extracts a "description" from `@@meta("description", "...")` or `@meta("description", "...")` attributes. + */ +export function getMetaDescription(attributes: readonly AttributeApplication[] | undefined): string | undefined { + if (!attributes) return undefined; + for (const attr of attributes) { + if (attr.name !== '@meta' && attr.name !== '@@meta') continue; + const nameArg = attr.args?.find((a) => a.name === 'name'); + if (!nameArg || ExpressionUtils.getLiteralValue(nameArg.value) !== 'description') continue; + const valueArg = attr.args?.find((a) => a.name === 'value'); + if (valueArg) { + return ExpressionUtils.getLiteralValue(valueArg.value) as string | undefined; + } + } + return undefined; +} diff --git a/packages/server/src/api/common/types.ts b/packages/server/src/api/common/types.ts new file mode 100644 index 000000000..3542bfc82 --- /dev/null +++ b/packages/server/src/api/common/types.ts @@ -0,0 +1,38 @@ +import type { QueryOptions } from '@zenstackhq/orm'; +import type { SchemaDef } from '@zenstackhq/orm/schema'; +import type { OpenAPIV3_1 } from 'openapi-types'; + +export type CommonHandlerOptions = { + /** Query options that affect the behavior of the OpenAPI provider. */ + queryOptions?: QueryOptions; +}; + +export type OpenApiSpecOptions = { + /** Spec title. Defaults to 'ZenStack Generated API' */ + title?: string; + + /** Spec version. Defaults to '1.0.0' */ + version?: string; + + /** Spec description. */ + description?: string; + + /** Spec summary. */ + summary?: string; + + /** + * When true, assumes that the schema includes access policies, and adds + * 403 responses to operations that can potentially be rejected. + */ + respectAccessPolicies?: boolean; +}; + +/** + * Interface for generating OpenAPI specifications. + */ +export interface OpenApiSpecGenerator { + /** + * Generates an OpenAPI v3.1 specification document. + */ + generateSpec(options?: OpenApiSpecOptions): Promise; +} diff --git a/packages/server/src/api/index.ts b/packages/server/src/api/index.ts index 09d9700eb..03c5d8819 100644 --- a/packages/server/src/api/index.ts +++ b/packages/server/src/api/index.ts @@ -1,2 +1,3 @@ +export type { OpenApiSpecGenerator, OpenApiSpecOptions } from './common/types'; export { RestApiHandler, type RestApiHandlerOptions } from './rest'; export { RPCApiHandler, type RPCApiHandlerOptions } from './rpc'; diff --git a/packages/server/src/api/rest/index.ts b/packages/server/src/api/rest/index.ts index c2723f061..cd8d0f66a 100644 --- a/packages/server/src/api/rest/index.ts +++ b/packages/server/src/api/rest/index.ts @@ -1,4 +1,4 @@ -import { clone, enumerate, lowerCaseFirst, paramCase } from '@zenstackhq/common-helpers'; +import { clone, enumerate, lowerCaseFirst, paramCase, safeJSONStringify } from '@zenstackhq/common-helpers'; import { ORMError, ORMErrorReason, type ClientContract } from '@zenstackhq/orm'; import type { FieldDef, ModelDef, SchemaDef } from '@zenstackhq/orm/schema'; import { Decimal } from 'decimal.js'; @@ -10,9 +10,11 @@ import z from 'zod'; import { fromError } from 'zod-validation-error/v4'; import type { ApiHandler, LogConfig, RequestContext, Response } from '../../types'; import { getProcedureDef, mapProcedureArgs } from '../common/procedures'; -import { loggerSchema } from '../common/schemas'; +import { loggerSchema, queryOptionsSchema } from '../common/schemas'; +import type { CommonHandlerOptions, OpenApiSpecGenerator, OpenApiSpecOptions } from '../common/types'; import { processSuperJsonRequestPayload } from '../common/utils'; import { getZodErrorMessage, log, registerCustomSerializers } from '../utils'; +import { RestApiSpecGenerator } from './openapi'; /** * Options for {@link RestApiHandler} @@ -64,7 +66,16 @@ export type RestApiHandlerOptions = { * Mapping from model names to unique field name to be used as resource's ID. */ externalIdMapping?: Record; -}; + + /** + * When `true`, enables nested route handling for all to-many relations: + * `/:parentType/:parentId/:relationName` (collection) and + * `/:parentType/:parentId/:relationName/:childId` (single). + * + * Defaults to `false`. + */ + nestedRoutes?: boolean; +} & CommonHandlerOptions; type RelationshipInfo = { type: string; @@ -84,10 +95,12 @@ type Match = { type: string; id: string; relationship: string; + childId?: string; }; enum UrlPatterns { SINGLE = 'single', + NESTED_SINGLE = 'nestedSingle', FETCH_RELATIONSHIP = 'fetchRelationship', RELATIONSHIP = 'relationship', COLLECTION = 'collection', @@ -127,7 +140,7 @@ registerCustomSerializers(); /** * RESTful-style API request handler (compliant with JSON:API) */ -export class RestApiHandler implements ApiHandler { +export class RestApiHandler implements ApiHandler, OpenApiSpecGenerator { // resource serializers private serializers = new Map(); @@ -262,6 +275,7 @@ export class RestApiHandler implements Api private modelNameMapping: Record; private reverseModelNameMapping: Record; private externalIdMapping: Record; + private nestedRoutes: boolean; constructor(private readonly options: RestApiHandlerOptions) { this.validateOptions(options); @@ -282,6 +296,8 @@ export class RestApiHandler implements Api Object.entries(this.externalIdMapping).map(([k, v]) => [lowerCaseFirst(k), v]), ); + this.nestedRoutes = options.nestedRoutes ?? false; + this.urlPatternMap = this.buildUrlPatternMap(segmentCharset); this.buildTypeMap(); @@ -298,6 +314,8 @@ export class RestApiHandler implements Api urlSegmentCharset: z.string().min(1).optional(), modelNameMapping: z.record(z.string(), z.string()).optional(), externalIdMapping: z.record(z.string(), z.string()).optional(), + queryOptions: queryOptionsSchema.optional(), + nestedRoutes: z.boolean().optional(), }); const parseResult = schema.safeParse(options); if (!parseResult.success) { @@ -322,6 +340,10 @@ export class RestApiHandler implements Api return { [UrlPatterns.SINGLE]: new UrlPattern(buildPath([':type', ':id']), options), + [UrlPatterns.NESTED_SINGLE]: new UrlPattern( + buildPath([':type', ':id', ':relationship', ':childId']), + options, + ), [UrlPatterns.FETCH_RELATIONSHIP]: new UrlPattern(buildPath([':type', ':id', ':relationship']), options), [UrlPatterns.RELATIONSHIP]: new UrlPattern( buildPath([':type', ':id', 'relationships', ':relationship']), @@ -335,6 +357,70 @@ export class RestApiHandler implements Api return this.modelNameMapping[modelName] ?? modelName; } + /** + * Resolves child model type and reverse relation from a parent relation name. + * e.g. given parentType='user', parentRelation='posts', returns { childType:'post', reverseRelation:'author' } + */ + private resolveNestedRelation( + parentType: string, + parentRelation: string, + ): { childType: string; reverseRelation: string; isCollection: boolean } | undefined { + const parentInfo = this.getModelInfo(parentType); + if (!parentInfo) return undefined; + const field: FieldDef | undefined = this.schema.models[parentInfo.name]?.fields[parentRelation]; + if (!field?.relation) return undefined; + const reverseRelation = field.relation.opposite; + if (!reverseRelation) return undefined; + return { childType: lowerCaseFirst(field.type), reverseRelation, isCollection: !!field.array }; + } + + private mergeFilters(left: any, right: any) { + if (!left) { + return right; + } + if (!right) { + return left; + } + return { AND: [left, right] }; + } + + /** + * Builds a WHERE filter for the child model that constrains results to those belonging to the given parent. + * @param parentType lowercased parent model name + * @param parentId parent resource ID string + * @param parentRelation relation field name on the parent model (e.g. 'posts') + */ + private buildNestedParentFilter(parentType: string, parentId: string, parentRelation: string) { + const parentInfo = this.getModelInfo(parentType); + if (!parentInfo) { + return { filter: undefined, error: this.makeUnsupportedModelError(parentType) }; + } + + const resolved = this.resolveNestedRelation(parentType, parentRelation); + if (!resolved) { + return { + filter: undefined, + error: this.makeError( + 'invalidPath', + `invalid nested route: cannot resolve relation "${parentType}.${parentRelation}"`, + ), + }; + } + + const { reverseRelation } = resolved; + const childInfo = this.getModelInfo(resolved.childType); + if (!childInfo) { + return { filter: undefined, error: this.makeUnsupportedModelError(resolved.childType) }; + } + + const reverseRelInfo = childInfo.relationships[reverseRelation]; + const relationFilter = reverseRelInfo?.isCollection + ? { [reverseRelation]: { some: this.makeIdFilter(parentInfo.idFields, parentId, false) } } + : { [reverseRelation]: { is: this.makeIdFilter(parentInfo.idFields, parentId, false) } }; + + return { filter: relationFilter, error: undefined }; + } + private matchUrlPattern(path: string, routeType: UrlPatterns): Match | undefined { const pattern = this.urlPatternMap[routeType]; if (!pattern) { @@ -396,6 +482,18 @@ export class RestApiHandler implements Api ); } + // /:type/:id/:relationship/:childId — nested single read + match = this.matchUrlPattern(path, UrlPatterns.NESTED_SINGLE); + if (match && this.nestedRoutes && this.resolveNestedRelation(match.type, match.relationship)?.isCollection) { + return await this.processNestedSingleRead( + client, + match.type, + match.id, + match.relationship, + match.childId!, + query, + ); + } match = this.matchUrlPattern(path, UrlPatterns.COLLECTION); if (match) { // collection read @@ -409,6 +507,18 @@ export class RestApiHandler implements Api if (!requestBody) { return this.makeError('invalidPayload'); } + // /:type/:id/:relationship — nested create + const nestedMatch = this.matchUrlPattern(path, UrlPatterns.FETCH_RELATIONSHIP); + if (nestedMatch && this.nestedRoutes && this.resolveNestedRelation(nestedMatch.type, nestedMatch.relationship)?.isCollection) { + return await this.processNestedCreate( + client, + nestedMatch.type, + nestedMatch.id, + nestedMatch.relationship, + query, + requestBody, + ); + } let match = this.matchUrlPattern(path, UrlPatterns.COLLECTION); if (match) { const body = requestBody as any; @@ -444,12 +554,8 @@ export class RestApiHandler implements Api if (!requestBody) { return this.makeError('invalidPayload'); } - let match = this.matchUrlPattern(path, UrlPatterns.SINGLE); - if (match) { - // resource update - return await this.processUpdate(client, match.type, match.id, query, requestBody); - } - match = this.matchUrlPattern(path, UrlPatterns.RELATIONSHIP); + // Check RELATIONSHIP before NESTED_SINGLE to avoid ambiguity on /:type/:id/relationships/:rel + let match = this.matchUrlPattern(path, UrlPatterns.RELATIONSHIP); if (match) { // relationship update return await this.processRelationshipCRUD( @@ -462,18 +568,53 @@ export class RestApiHandler implements Api requestBody, ); } - + // /:type/:id/:relationship — nested update (to-one) + const nestedToOnePatchMatch = this.matchUrlPattern(path, UrlPatterns.FETCH_RELATIONSHIP); + if ( + nestedToOnePatchMatch && + this.nestedRoutes && + this.resolveNestedRelation(nestedToOnePatchMatch.type, nestedToOnePatchMatch.relationship) && + !this.resolveNestedRelation(nestedToOnePatchMatch.type, nestedToOnePatchMatch.relationship) + ?.isCollection + ) { + return await this.processNestedUpdate( + client, + nestedToOnePatchMatch.type, + nestedToOnePatchMatch.id, + nestedToOnePatchMatch.relationship, + undefined, + query, + requestBody, + ); + } + // /:type/:id/:relationship/:childId — nested update (to-many) + const nestedPatchMatch = this.matchUrlPattern(path, UrlPatterns.NESTED_SINGLE); + if ( + nestedPatchMatch && + this.nestedRoutes && + this.resolveNestedRelation(nestedPatchMatch.type, nestedPatchMatch.relationship)?.isCollection + ) { + return await this.processNestedUpdate( + client, + nestedPatchMatch.type, + nestedPatchMatch.id, + nestedPatchMatch.relationship, + nestedPatchMatch.childId!, + query, + requestBody, + ); + } + match = this.matchUrlPattern(path, UrlPatterns.SINGLE); + if (match) { + // resource update + return await this.processUpdate(client, match.type, match.id, query, requestBody); + } return this.makeError('invalidPath'); } case 'DELETE': { - let match = this.matchUrlPattern(path, UrlPatterns.SINGLE); - if (match) { - // resource deletion - return await this.processDelete(client, match.type, match.id); - } - - match = this.matchUrlPattern(path, UrlPatterns.RELATIONSHIP); + // Check RELATIONSHIP before NESTED_SINGLE to avoid ambiguity on /:type/:id/relationships/:rel + let match = this.matchUrlPattern(path, UrlPatterns.RELATIONSHIP); if (match) { // relationship deletion (collection relationship only) return await this.processRelationshipCRUD( @@ -486,7 +627,26 @@ export class RestApiHandler implements Api requestBody, ); } - + // /:type/:id/:relationship/:childId — nested delete (one-to-many child) + const nestedDeleteMatch = this.matchUrlPattern(path, UrlPatterns.NESTED_SINGLE); + if ( + nestedDeleteMatch && + this.nestedRoutes && + this.resolveNestedRelation(nestedDeleteMatch.type, nestedDeleteMatch.relationship)?.isCollection + ) { + return await this.processNestedDelete( + client, + nestedDeleteMatch.type, + nestedDeleteMatch.id, + nestedDeleteMatch.relationship, + nestedDeleteMatch.childId!, + ); + } + match = this.matchUrlPattern(path, UrlPatterns.SINGLE); + if (match) { + // resource deletion + return await this.processDelete(client, match.type, match.id); + } return this.makeError('invalidPath'); } @@ -505,7 +665,13 @@ export class RestApiHandler implements Api } private handleGenericError(err: unknown): Response | PromiseLike { - return this.makeError('unknownError', err instanceof Error ? `${err.message}\n${err.stack}` : 'Unknown error'); + const resp = this.makeError('unknownError', err instanceof Error ? `${err.message}` : 'Unknown error'); + log( + this.options.log, + 'debug', + () => `sending error response: ${safeJSONStringify(resp)}${err instanceof Error ? '\n' + err.stack : ''}`, + ); + return resp; } private async processProcedureRequest({ @@ -582,29 +748,31 @@ export class RestApiHandler implements Api private makeProcBadInputErrorResponse(message: string): Response { const resp = this.makeError('invalidPayload', message, 400); - log(this.log, 'debug', () => `sending error response: ${JSON.stringify(resp)}`); + log(this.log, 'debug', () => `sending error response: ${safeJSONStringify(resp)}`); return resp; } private makeProcGenericErrorResponse(err: unknown): Response { const message = err instanceof Error ? err.message : 'unknown error'; const resp = this.makeError('unknownError', message, 500); - log(this.log, 'debug', () => `sending error response: ${JSON.stringify(resp)}`); + log( + this.log, + 'debug', + () => `sending error response: ${safeJSONStringify(resp)}${err instanceof Error ? '\n' + err.stack : ''}`, + ); return resp; } - private async processSingleRead( - client: ClientContract, + /** + * Builds the ORM `args` object (include, select) shared by single-read operations. + * Returns the args to pass to findUnique/findFirst and the resolved `include` list for serialization, + * or an error response if query params are invalid. + */ + private buildSingleReadArgs( type: string, - resourceId: string, query: Record | undefined, - ): Promise { - const typeInfo = this.getModelInfo(type); - if (!typeInfo) { - return this.makeUnsupportedModelError(type); - } - - const args: any = { where: this.makeIdFilter(typeInfo.idFields, resourceId) }; + ): { args: any; include: string[] | undefined; error?: Response } { + const args: any = {}; // include IDs of relation fields so that they can be serialized this.includeRelationshipIds(type, args, 'include'); @@ -614,7 +782,7 @@ export class RestApiHandler implements Api if (query?.['include']) { const { select, error, allIncludes } = this.buildRelationSelect(type, query['include'], query); if (error) { - return error; + return { args, include, error }; } if (select) { args.include = { ...args.include, ...select }; @@ -624,18 +792,34 @@ export class RestApiHandler implements Api // handle partial results for requested type const { select, error } = this.buildPartialSelect(type, query); - if (error) return error; + if (error) return { args, include, error }; if (select) { args.select = { ...select, ...args.select }; if (args.include) { - args.select = { - ...args.select, - ...args.include, - }; + args.select = { ...args.select, ...args.include }; args.include = undefined; } } + return { args, include }; + } + + private async processSingleRead( + client: ClientContract, + type: string, + resourceId: string, + query: Record | undefined, + ): Promise { + const typeInfo = this.getModelInfo(type); + if (!typeInfo) { + return this.makeUnsupportedModelError(type); + } + + const { args, include, error } = this.buildSingleReadArgs(type, query); + if (error) return error; + + args.where = this.makeIdFilter(typeInfo.idFields, resourceId); + const entity = await (client as any)[type].findUnique(args); if (entity) { @@ -870,7 +1054,13 @@ export class RestApiHandler implements Api if (limit === Infinity) { const entities = await (client as any)[type].findMany(args); - const body = await this.serializeItems(type, entities, { include }); + const mappedType = this.mapModelName(type); + const body = await this.serializeItems(type, entities, { + include, + linkers: { + document: new tsjapi.Linker(() => this.makeLinkUrl(`/${mappedType}`)), + }, + }); const total = entities.length; body.meta = this.addTotalCountToMeta(body.meta, total); @@ -892,6 +1082,7 @@ export class RestApiHandler implements Api const options: Partial = { include, linkers: { + document: new tsjapi.Linker(() => this.makeLinkUrl(`/${mappedType}`)), paginator: this.makePaginator(url, offset, limit, total), }, }; @@ -905,6 +1096,294 @@ export class RestApiHandler implements Api } } + /** + * Builds link URL for a nested resource using parent type, parent ID, relation name, and optional child ID. + * Uses the parent model name mapping for the parent segment; the relation name is used as-is. + */ + private makeNestedLinkUrl(parentType: string, parentId: string, parentRelation: string, childId?: string) { + const mappedParentType = this.mapModelName(parentType); + const base = `/${mappedParentType}/${parentId}/${parentRelation}`; + return childId ? `${base}/${childId}` : base; + } + + private async processNestedSingleRead( + client: ClientContract, + parentType: string, + parentId: string, + parentRelation: string, + childId: string, + query: Record | undefined, + ): Promise { + const resolved = this.resolveNestedRelation(parentType, parentRelation); + if (!resolved) { + return this.makeError('invalidPath'); + } + + const { filter: nestedFilter, error: nestedError } = this.buildNestedParentFilter( + parentType, + parentId, + parentRelation, + ); + if (nestedError) return nestedError; + + const childType = resolved.childType; + const typeInfo = this.getModelInfo(childType)!; + + const { args, include, error } = this.buildSingleReadArgs(childType, query); + if (error) return error; + + args.where = this.mergeFilters(this.makeIdFilter(typeInfo.idFields, childId), nestedFilter); + + const entity = await (client as any)[childType].findFirst(args); + if (!entity) return this.makeError('notFound'); + + const linkUrl = this.makeLinkUrl(this.makeNestedLinkUrl(parentType, parentId, parentRelation, childId)); + const nestedLinker = new tsjapi.Linker(() => linkUrl); + return { + status: 200, + body: await this.serializeItems(childType, entity, { + include, + linkers: { document: nestedLinker, resource: nestedLinker }, + }), + }; + } + + private async processNestedCreate( + client: ClientContract, + parentType: string, + parentId: string, + parentRelation: string, + _query: Record | undefined, + requestBody: unknown, + ): Promise { + const resolved = this.resolveNestedRelation(parentType, parentRelation); + if (!resolved) { + return this.makeError('invalidPath'); + } + + const parentInfo = this.getModelInfo(parentType)!; + const childType = resolved.childType; + const childInfo = this.getModelInfo(childType)!; + + const { attributes, relationships, error } = this.processRequestBody(requestBody); + if (error) return error; + + const createData: any = { ...attributes }; + + // Turn relationship payload into `connect` objects, rejecting the parent relation + if (relationships) { + for (const [key, data] of Object.entries(relationships)) { + if (!data?.data) { + return this.makeError('invalidRelationData'); + } + if (key === resolved.reverseRelation) { + return this.makeError( + 'invalidPayload', + `Relation "${key}" is controlled by the parent route and cannot be set in the request payload`, + ); + } + const relationInfo = childInfo.relationships[key]; + if (!relationInfo) { + return this.makeUnsupportedRelationshipError(childType, key, 400); + } + if (relationInfo.isCollection) { + createData[key] = { + connect: enumerate(data.data).map((item: any) => + this.makeIdConnect(relationInfo.idFields, item.id), + ), + }; + } else { + if (typeof data.data !== 'object') { + return this.makeError('invalidRelationData'); + } + createData[key] = { connect: this.makeIdConnect(relationInfo.idFields, data.data.id) }; + } + } + } + + // Reject scalar FK fields in attributes that would override the parent relation + const parentFkFields = Object.values(childInfo.fields).filter((f) => + f.foreignKeyFor?.includes(resolved.reverseRelation), + ); + if (parentFkFields.some((f) => Object.prototype.hasOwnProperty.call(createData, f.name))) { + return this.makeError( + 'invalidPayload', + `Relation "${resolved.reverseRelation}" is controlled by the parent route and cannot be set in the request payload`, + ); + } + + // Atomically create child nested in parent update; ORM throws NOT_FOUND if parent doesn't exist + await (client as any)[parentType].update({ + where: this.makeIdFilter(parentInfo.idFields, parentId), + data: { [parentRelation]: { create: createData } }, + }); + + // Fetch the created child — most recently created for this parent + const { filter: nestedFilter, error: filterError } = this.buildNestedParentFilter( + parentType, + parentId, + parentRelation, + ); + if (filterError) return filterError; + + const fetchArgs: any = { where: nestedFilter }; + this.includeRelationshipIds(childType, fetchArgs, 'include'); + if (childInfo.idFields[0]) { + fetchArgs.orderBy = { [childInfo.idFields[0].name]: 'desc' }; + } + + const entity = await (client as any)[childType].findFirst(fetchArgs); + if (!entity) return this.makeError('notFound'); + + const collectionPath = this.makeNestedLinkUrl(parentType, parentId, parentRelation); + const resourceLinker = new tsjapi.Linker((item: any) => + this.makeLinkUrl(`${collectionPath}/${this.getId(childInfo.name, item)}`), + ); + return { + status: 201, + body: await this.serializeItems(childType, entity, { + linkers: { document: resourceLinker, resource: resourceLinker }, + }), + }; + } + + /** + * Builds the ORM `data` payload for a nested update, shared by both to-many (childId present) + * and to-one (childId absent) variants. Returns either `{ updateData }` or `{ error }`. + */ + private buildNestedUpdatePayload( + childType: string, + typeInfo: ReturnType['getModelInfo']>, + rev: string, + requestBody: unknown, + ): { updateData: any; error?: never } | { updateData?: never; error: Response } { + const { attributes, relationships, error } = this.processRequestBody(requestBody); + if (error) return { error }; + + const updateData: any = { ...attributes }; + + // Reject attempts to change the parent relation via the nested endpoint + if (relationships && Object.prototype.hasOwnProperty.call(relationships, rev)) { + return { error: this.makeError('invalidPayload', `Relation "${rev}" cannot be changed via a nested route`) }; + } + const fkFields = Object.values(typeInfo!.fields).filter((f) => f.foreignKeyFor?.includes(rev)); + if (fkFields.some((f) => Object.prototype.hasOwnProperty.call(updateData, f.name))) { + return { error: this.makeError('invalidPayload', `Relation "${rev}" cannot be changed via a nested route`) }; + } + + // Turn relationship payload into connect/set objects + if (relationships) { + for (const [key, data] of Object.entries(relationships)) { + if (!data?.data) { + return { error: this.makeError('invalidRelationData') }; + } + const relationInfo = typeInfo!.relationships[key]; + if (!relationInfo) { + return { error: this.makeUnsupportedRelationshipError(childType, key, 400) }; + } + if (relationInfo.isCollection) { + updateData[key] = { + set: enumerate(data.data).map((item: any) => ({ + [this.makeDefaultIdKey(relationInfo.idFields)]: item.id, + })), + }; + } else { + if (typeof data.data !== 'object') { + return { error: this.makeError('invalidRelationData') }; + } + updateData[key] = { + connect: { [this.makeDefaultIdKey(relationInfo.idFields)]: data.data.id }, + }; + } + } + } + + return { updateData }; + } + + /** + * Handles PATCH /:type/:id/:relationship/:childId (to-many) and + * PATCH /:type/:id/:relationship (to-one, childId undefined). + */ + private async processNestedUpdate( + client: ClientContract, + parentType: string, + parentId: string, + parentRelation: string, + childId: string | undefined, + _query: Record | undefined, + requestBody: unknown, + ): Promise { + const resolved = this.resolveNestedRelation(parentType, parentRelation); + if (!resolved) { + return this.makeError('invalidPath'); + } + + const parentInfo = this.getModelInfo(parentType)!; + const childType = resolved.childType; + const typeInfo = this.getModelInfo(childType)!; + + const { updateData, error } = this.buildNestedUpdatePayload(childType, typeInfo, resolved.reverseRelation, requestBody); + if (error) return error; + + if (childId) { + // to-many: ORM requires a where filter to identify the child within the collection + await (client as any)[parentType].update({ + where: this.makeIdFilter(parentInfo.idFields, parentId), + data: { [parentRelation]: { update: { where: this.makeIdFilter(typeInfo.idFields, childId), data: updateData } } }, + }); + const fetchArgs: any = { where: this.makeIdFilter(typeInfo.idFields, childId) }; + this.includeRelationshipIds(childType, fetchArgs, 'include'); + const entity = await (client as any)[childType].findUnique(fetchArgs); + if (!entity) return this.makeError('notFound'); + const linkUrl = this.makeLinkUrl(this.makeNestedLinkUrl(parentType, parentId, parentRelation, childId)); + const nestedLinker = new tsjapi.Linker(() => linkUrl); + return { status: 200, body: await this.serializeItems(childType, entity, { linkers: { document: nestedLinker, resource: nestedLinker } }) }; + } else { + // to-one: no where filter needed; fetch via parent select + await (client as any)[parentType].update({ + where: this.makeIdFilter(parentInfo.idFields, parentId), + data: { [parentRelation]: { update: updateData } }, + }); + const childIncludeArgs: any = {}; + this.includeRelationshipIds(childType, childIncludeArgs, 'include'); + const fetchArgs: any = { + where: this.makeIdFilter(parentInfo.idFields, parentId), + select: { [parentRelation]: childIncludeArgs.include ? { include: childIncludeArgs.include } : true }, + }; + const parent = await (client as any)[parentType].findUnique(fetchArgs); + const entity = parent?.[parentRelation]; + if (!entity) return this.makeError('notFound'); + const linkUrl = this.makeLinkUrl(this.makeNestedLinkUrl(parentType, parentId, parentRelation)); + const nestedLinker = new tsjapi.Linker(() => linkUrl); + return { status: 200, body: await this.serializeItems(childType, entity, { linkers: { document: nestedLinker, resource: nestedLinker } }) }; + } + } + + private async processNestedDelete( + client: ClientContract, + parentType: string, + parentId: string, + parentRelation: string, + childId: string, + ): Promise { + const resolved = this.resolveNestedRelation(parentType, parentRelation); + if (!resolved) { + return this.makeError('invalidPath'); + } + + const parentInfo = this.getModelInfo(parentType)!; + const typeInfo = this.getModelInfo(resolved.childType)!; + + // Atomically delete child scoped to parent; ORM throws NOT_FOUND if parent or child-belongs-to-parent check fails + await (client as any)[parentType].update({ + where: this.makeIdFilter(parentInfo.idFields, parentId), + data: { [parentRelation]: { delete: this.makeIdFilter(typeInfo.idFields, childId) } }, + }); + + return { status: 200, body: { meta: {} } }; + } + private buildPartialSelect(type: string, query: Record | undefined) { const selectFieldsQuery = query?.[`fields[${type}]`]; if (!selectFieldsQuery) { @@ -2060,9 +2539,7 @@ export class RestApiHandler implements Api } } else { if (op === 'between') { - const parts = value - .split(',') - .map((v) => this.coerce(fieldDef, v)); + const parts = value.split(',').map((v) => this.coerce(fieldDef, v)); if (parts.length !== 2) { throw new InvalidValueError(`"between" expects exactly 2 comma-separated values`); } @@ -2201,4 +2678,11 @@ export class RestApiHandler implements Api } //#endregion + + async generateSpec(options?: OpenApiSpecOptions) { + const generator = new RestApiSpecGenerator(this.options); + return generator.generateSpec(options); + } } + +export { RestApiSpecGenerator } from './openapi'; diff --git a/packages/server/src/api/rest/openapi.ts b/packages/server/src/api/rest/openapi.ts new file mode 100644 index 000000000..9c5bae03f --- /dev/null +++ b/packages/server/src/api/rest/openapi.ts @@ -0,0 +1,1088 @@ +import { lowerCaseFirst } from '@zenstackhq/common-helpers'; +import type { AttributeApplication, EnumDef, FieldDef, ModelDef, SchemaDef, TypeDefDef } from '@zenstackhq/orm/schema'; +import type { OpenAPIV3_1 } from 'openapi-types'; +import { PROCEDURE_ROUTE_PREFIXES } from '../common/procedures'; +import { + getIncludedModels, + getMetaDescription, + isFieldOmitted, + isFilterKindIncluded, + isModelIncluded, + isOperationIncluded, + isProcedureIncluded, +} from '../common/spec-utils'; +import type { OpenApiSpecOptions } from '../common/types'; +import type { RestApiHandlerOptions } from '.'; + +type SchemaObject = OpenAPIV3_1.SchemaObject; +type ReferenceObject = OpenAPIV3_1.ReferenceObject; +type ParameterObject = OpenAPIV3_1.ParameterObject; + +function errorResponse(description: string): OpenAPIV3_1.ResponseObject { + return { + description, + content: { + 'application/vnd.api+json': { + schema: { $ref: '#/components/schemas/_errorResponse' }, + }, + }, + }; +} + +const ERROR_400 = errorResponse('Error occurred while processing the request'); +const ERROR_403 = errorResponse('Forbidden: insufficient permissions to perform this operation'); +const ERROR_404 = errorResponse('Resource not found'); +const ERROR_422 = errorResponse('Operation is unprocessable due to validation errors'); + +const SCALAR_STRING_OPS = ['$contains', '$icontains', '$search', '$startsWith', '$endsWith']; +const SCALAR_COMPARABLE_OPS = ['$lt', '$lte', '$gt', '$gte']; +const SCALAR_ARRAY_OPS = ['$has', '$hasEvery', '$hasSome', '$isEmpty']; + +export class RestApiSpecGenerator { + private specOptions?: OpenApiSpecOptions; + + constructor(private readonly handlerOptions: RestApiHandlerOptions) {} + + private get schema(): SchemaDef { + return this.handlerOptions.schema; + } + + private get modelNameMapping(): Record { + const mapping: Record = {}; + if (this.handlerOptions.modelNameMapping) { + for (const [k, v] of Object.entries(this.handlerOptions.modelNameMapping)) { + mapping[lowerCaseFirst(k)] = v; + } + } + return mapping; + } + + private get queryOptions() { + return this.handlerOptions?.queryOptions; + } + + generateSpec(options?: OpenApiSpecOptions): OpenAPIV3_1.Document { + this.specOptions = options; + return { + openapi: '3.1.0', + info: { + title: options?.title ?? 'ZenStack Generated API', + version: options?.version ?? '1.0.0', + ...(options?.description && { description: options.description }), + ...(options?.summary && { summary: options.summary }), + }, + tags: this.generateTags(), + paths: this.generatePaths(), + components: { + schemas: this.generateSchemas(), + parameters: this.generateSharedParams(), + }, + } as OpenAPIV3_1.Document; + } + + private generateTags(): OpenAPIV3_1.TagObject[] { + return getIncludedModels(this.schema, this.queryOptions).map((modelName) => ({ + name: lowerCaseFirst(modelName), + description: `${modelName} operations`, + })); + } + + private getModelPath(modelName: string): string { + const lower = lowerCaseFirst(modelName); + return this.modelNameMapping[lower] ?? lower; + } + + private generatePaths(): OpenAPIV3_1.PathsObject { + const paths: OpenAPIV3_1.PathsObject = {}; + + for (const modelName of getIncludedModels(this.schema, this.queryOptions)) { + const modelDef = this.schema.models[modelName]!; + const idFields = this.getIdFields(modelDef); + if (idFields.length === 0) continue; + + const modelPath = this.getModelPath(modelName); + const tag = lowerCaseFirst(modelName); + + // Collection: GET (list) + POST (create) + const collectionPath = this.buildCollectionPath(modelName, modelDef, tag); + if (Object.keys(collectionPath).length > 0) { + paths[`/${modelPath}`] = collectionPath; + } + + // Single resource: GET + PATCH + DELETE + const singlePath = this.buildSinglePath(modelDef, tag); + if (Object.keys(singlePath).length > 0) { + paths[`/${modelPath}/{id}`] = singlePath; + } + + // Relation paths + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (!fieldDef.relation) continue; + if (!isModelIncluded(fieldDef.type, this.queryOptions)) continue; + const relModelDef = this.schema.models[fieldDef.type]; + if (!relModelDef) continue; + const relIdFields = this.getIdFields(relModelDef); + if (relIdFields.length === 0) continue; + + // GET /{model}/{id}/{field} — fetch related + paths[`/${modelPath}/{id}/${fieldName}`] = this.buildFetchRelatedPath( + modelName, + fieldName, + fieldDef, + tag, + ); + + // Relationship management path + paths[`/${modelPath}/{id}/relationships/${fieldName}`] = this.buildRelationshipPath( + modelDef, + fieldName, + fieldDef, + tag, + ); + } + } + + // Procedure paths + if (this.schema.procedures) { + for (const [procName, procDef] of Object.entries(this.schema.procedures)) { + if (!isProcedureIncluded(procName, this.queryOptions)) continue; + const isMutation = !!procDef.mutation; + if (isMutation) { + paths[`/${PROCEDURE_ROUTE_PREFIXES}/${procName}`] = { + post: this.buildProcedureOperation(procName, 'post'), + } as OpenAPIV3_1.PathItemObject; + } else { + paths[`/${PROCEDURE_ROUTE_PREFIXES}/${procName}`] = { + get: this.buildProcedureOperation(procName, 'get'), + } as OpenAPIV3_1.PathItemObject; + } + } + } + + return paths; + } + + private buildCollectionPath(modelName: string, modelDef: ModelDef, tag: string): Record { + const filterParams = this.buildFilterParams(modelName, modelDef); + + const listOp = { + tags: [tag], + summary: `List ${modelName} resources`, + operationId: `list${modelName}`, + parameters: [ + { $ref: '#/components/parameters/include' }, + { $ref: '#/components/parameters/sort' }, + { $ref: '#/components/parameters/pageOffset' }, + { $ref: '#/components/parameters/pageLimit' }, + ...filterParams, + ], + responses: { + '200': { + description: `List of ${modelName} resources`, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}ListResponse` }, + }, + }, + }, + '400': ERROR_400, + }, + }; + + const createOp = { + tags: [tag], + summary: `Create a ${modelName} resource`, + operationId: `create${modelName}`, + requestBody: { + required: true, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}CreateRequest` }, + }, + }, + }, + responses: { + '201': { + description: `Created ${modelName} resource`, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}Response` }, + }, + }, + }, + '400': ERROR_400, + ...(this.mayDenyAccess(modelDef, 'create') && { '403': ERROR_403 }), + '422': ERROR_422, + }, + }; + + const result: Record = {}; + if (isOperationIncluded(modelName, 'findMany', this.queryOptions)) { + result['get'] = listOp; + } + if (isOperationIncluded(modelName, 'create', this.queryOptions)) { + result['post'] = createOp; + } + return result; + } + + private buildSinglePath(modelDef: ModelDef, tag: string): Record { + const modelName = modelDef.name; + const idParam = { $ref: '#/components/parameters/id' }; + const result: Record = {}; + + if (isOperationIncluded(modelName, 'findUnique', this.queryOptions)) { + result['get'] = { + tags: [tag], + summary: `Get a ${modelName} resource by ID`, + operationId: `get${modelName}`, + parameters: [idParam, { $ref: '#/components/parameters/include' }], + responses: { + '200': { + description: `${modelName} resource`, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}Response` }, + }, + }, + }, + '404': ERROR_404, + }, + }; + } + + if (isOperationIncluded(modelName, 'update', this.queryOptions)) { + result['patch'] = { + tags: [tag], + summary: `Update a ${modelName} resource`, + operationId: `update${modelName}`, + parameters: [idParam], + requestBody: { + required: true, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}UpdateRequest` }, + }, + }, + }, + responses: { + '200': { + description: `Updated ${modelName} resource`, + content: { + 'application/vnd.api+json': { + schema: { $ref: `#/components/schemas/${modelName}Response` }, + }, + }, + }, + '400': ERROR_400, + ...(this.mayDenyAccess(modelDef, 'update') && { '403': ERROR_403 }), + '404': ERROR_404, + '422': ERROR_422, + }, + }; + } + + if (isOperationIncluded(modelName, 'delete', this.queryOptions)) { + result['delete'] = { + tags: [tag], + summary: `Delete a ${modelName} resource`, + operationId: `delete${modelName}`, + parameters: [idParam], + responses: { + '200': { description: 'Deleted successfully' }, + ...(this.mayDenyAccess(modelDef, 'delete') && { '403': ERROR_403 }), + '404': ERROR_404, + }, + }; + } + + return result; + } + + private buildFetchRelatedPath( + modelName: string, + fieldName: string, + fieldDef: FieldDef, + tag: string, + ): Record { + const isCollection = !!fieldDef.array; + const params: any[] = [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/include' }]; + + if (isCollection && this.schema.models[fieldDef.type]) { + const relModelDef = this.schema.models[fieldDef.type]!; + params.push( + { $ref: '#/components/parameters/sort' }, + { $ref: '#/components/parameters/pageOffset' }, + { $ref: '#/components/parameters/pageLimit' }, + ...this.buildFilterParams(fieldDef.type, relModelDef), + ); + } + + return { + get: { + tags: [tag], + summary: `Fetch related ${fieldDef.type} for ${modelName}`, + operationId: `get${modelName}_${fieldName}`, + parameters: params, + responses: { + '200': { + description: `Related ${fieldDef.type} resource(s)`, + content: { + 'application/vnd.api+json': { + schema: isCollection + ? { $ref: `#/components/schemas/${fieldDef.type}ListResponse` } + : { $ref: `#/components/schemas/${fieldDef.type}Response` }, + }, + }, + }, + '404': ERROR_404, + }, + }, + }; + } + + private buildRelationshipPath( + modelDef: ModelDef, + fieldName: string, + fieldDef: FieldDef, + tag: string, + ): Record { + const modelName = modelDef.name; + const isCollection = !!fieldDef.array; + const idParam = { $ref: '#/components/parameters/id' }; + const relSchemaRef = isCollection + ? { $ref: '#/components/schemas/_toManyRelationshipWithLinks' } + : { $ref: '#/components/schemas/_toOneRelationshipWithLinks' }; + + const relRequestRef = isCollection + ? { $ref: '#/components/schemas/_toManyRelationshipRequest' } + : { $ref: '#/components/schemas/_toOneRelationshipRequest' }; + + const mayDeny = this.mayDenyAccess(modelDef, 'update'); + + const pathItem: Record = { + get: { + tags: [tag], + summary: `Fetch ${fieldName} relationship`, + operationId: `get${modelName}_relationships_${fieldName}`, + parameters: [idParam], + responses: { + '200': { + description: `${fieldName} relationship`, + content: { 'application/vnd.api+json': { schema: relSchemaRef } }, + }, + '404': ERROR_404, + }, + }, + put: { + tags: [tag], + summary: `Replace ${fieldName} relationship`, + operationId: `put${modelName}_relationships_${fieldName}`, + parameters: [idParam], + requestBody: { + required: true, + content: { 'application/vnd.api+json': { schema: relRequestRef } }, + }, + responses: { + '200': { description: 'Relationship updated' }, + '400': ERROR_400, + ...(mayDeny && { '403': ERROR_403 }), + }, + }, + patch: { + tags: [tag], + summary: `Update ${fieldName} relationship`, + operationId: `patch${modelName}_relationships_${fieldName}`, + parameters: [idParam], + requestBody: { + required: true, + content: { 'application/vnd.api+json': { schema: relRequestRef } }, + }, + responses: { + '200': { description: 'Relationship updated' }, + '400': ERROR_400, + ...(mayDeny && { '403': ERROR_403 }), + }, + }, + }; + + if (isCollection) { + pathItem['post'] = { + tags: [tag], + summary: `Add to ${fieldName} collection relationship`, + operationId: `post${modelName}_relationships_${fieldName}`, + parameters: [idParam], + requestBody: { + required: true, + content: { + 'application/vnd.api+json': { + schema: { $ref: '#/components/schemas/_toManyRelationshipRequest' }, + }, + }, + }, + responses: { + '200': { description: 'Added to relationship collection' }, + '400': ERROR_400, + ...(mayDeny && { '403': ERROR_403 }), + }, + }; + } + + return pathItem; + } + + private buildProcedureOperation(procName: string, method: 'get' | 'post'): Record { + const op: Record = { + tags: ['$procs'], + summary: `Execute procedure ${procName}`, + operationId: `proc_${procName}`, + responses: { + '200': { description: `Result of ${procName}` }, + '400': ERROR_400, + }, + }; + + if (method === 'get') { + op['parameters'] = [ + { + name: 'q', + in: 'query', + description: 'Procedure arguments as JSON', + schema: { type: 'string' }, + }, + ]; + } else { + op['requestBody'] = { + content: { + 'application/json': { + schema: { type: 'object' }, + }, + }, + }; + } + + return op; + } + + private buildFilterParams(modelName: string, modelDef: ModelDef): ParameterObject[] { + const params: ParameterObject[] = []; + const idFieldNames = new Set(modelDef.idFields); + + // id filter (Equality kind) + if (isFilterKindIncluded(modelName, 'id', 'Equality', this.queryOptions)) { + params.push({ + name: 'filter[id]', + in: 'query', + schema: { type: 'string' }, + description: `Filter by ${modelName} ID`, + }); + } + + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.relation) continue; + if (idFieldNames.has(fieldName)) continue; + + const type = fieldDef.type; + + // Equality filter + if (isFilterKindIncluded(modelName, fieldName, 'Equality', this.queryOptions)) { + params.push({ + name: `filter[${fieldName}]`, + in: 'query', + schema: { type: 'string' }, + description: `Filter by ${fieldName}`, + }); + } + + if (type === 'String' && isFilterKindIncluded(modelName, fieldName, 'Like', this.queryOptions)) { + for (const op of SCALAR_STRING_OPS) { + params.push({ + name: `filter[${fieldName}][${op}]`, + in: 'query', + schema: { type: 'string' }, + }); + } + } else if ( + (type === 'Int' || + type === 'Float' || + type === 'BigInt' || + type === 'Decimal' || + type === 'DateTime') && + isFilterKindIncluded(modelName, fieldName, 'Range', this.queryOptions) + ) { + for (const op of SCALAR_COMPARABLE_OPS) { + params.push({ + name: `filter[${fieldName}][${op}]`, + in: 'query', + schema: { type: 'string' }, + }); + } + } + + if (fieldDef.array && isFilterKindIncluded(modelName, fieldName, 'List', this.queryOptions)) { + for (const op of SCALAR_ARRAY_OPS) { + params.push({ + name: `filter[${fieldName}][${op}]`, + in: 'query', + schema: { type: 'string' }, + }); + } + } + } + + return params; + } + + private generateSchemas(): Record { + const schemas: Record = {}; + + // Shared JSON:API components + Object.assign(schemas, this.buildSharedSchemas()); + + // Per-enum schemas + if (this.schema.enums) { + for (const [_enumName, enumDef] of Object.entries(this.schema.enums)) { + schemas[_enumName] = this.buildEnumSchema(enumDef); + } + } + + // Per-typeDef schemas + if (this.schema.typeDefs) { + for (const [typeName, typeDef] of Object.entries(this.schema.typeDefs)) { + schemas[typeName] = this.buildTypeDefSchema(typeDef); + } + } + + // Per-model schemas + for (const modelName of getIncludedModels(this.schema, this.queryOptions)) { + const modelDef = this.schema.models[modelName]!; + const idFields = this.getIdFields(modelDef); + if (idFields.length === 0) continue; + + schemas[modelName] = this.buildModelReadSchema(modelName, modelDef); + schemas[`${modelName}CreateRequest`] = this.buildCreateRequestSchema(modelName, modelDef); + schemas[`${modelName}UpdateRequest`] = this.buildUpdateRequestSchema(modelDef); + schemas[`${modelName}Response`] = this.buildModelResponseSchema(modelName); + schemas[`${modelName}ListResponse`] = this.buildModelListResponseSchema(modelName); + } + + return schemas; + } + + private buildSharedSchemas(): Record { + const nullableString: SchemaObject = { oneOf: [{ type: 'string' }, { type: 'null' }] }; + return { + _jsonapi: { + type: 'object', + properties: { + version: { type: 'string' }, + meta: { type: 'object' }, + }, + }, + _meta: { + type: 'object', + additionalProperties: true, + }, + _links: { + type: 'object', + properties: { + self: { type: 'string' }, + related: { type: 'string' }, + }, + }, + _pagination: { + type: 'object', + properties: { + first: nullableString, + last: nullableString, + prev: nullableString, + next: nullableString, + }, + }, + _errors: { + type: 'array', + items: { + type: 'object', + properties: { + status: { type: 'integer' }, + code: { type: 'string' }, + title: { type: 'string' }, + detail: { type: 'string' }, + }, + required: ['status', 'title'], + }, + }, + _errorResponse: { + type: 'object', + properties: { + errors: { $ref: '#/components/schemas/_errors' }, + }, + required: ['errors'], + }, + _resourceIdentifier: { + type: 'object', + properties: { + type: { type: 'string' }, + id: { type: 'string' }, + }, + required: ['type', 'id'], + }, + _resource: { + type: 'object', + properties: { + type: { type: 'string' }, + id: { type: 'string' }, + attributes: { type: 'object' }, + relationships: { type: 'object' }, + links: { $ref: '#/components/schemas/_links' }, + meta: { $ref: '#/components/schemas/_meta' }, + }, + required: ['type', 'id'], + }, + _relationLinks: { + type: 'object', + properties: { + self: { type: 'string' }, + related: { type: 'string' }, + }, + }, + _pagedRelationLinks: { + type: 'object', + allOf: [{ $ref: '#/components/schemas/_relationLinks' }, { $ref: '#/components/schemas/_pagination' }], + }, + _toOneRelationship: { + type: 'object', + properties: { + data: { + oneOf: [{ $ref: '#/components/schemas/_resourceIdentifier' }, { type: 'null' }], + }, + }, + }, + _toManyRelationship: { + type: 'object', + properties: { + data: { + type: 'array', + items: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }, + }, + _toOneRelationshipWithLinks: { + type: 'object', + allOf: [ + { $ref: '#/components/schemas/_toOneRelationship' }, + { + properties: { + links: { $ref: '#/components/schemas/_relationLinks' }, + }, + }, + ], + }, + _toManyRelationshipWithLinks: { + type: 'object', + allOf: [ + { $ref: '#/components/schemas/_toManyRelationship' }, + { + properties: { + links: { $ref: '#/components/schemas/_pagedRelationLinks' }, + }, + }, + ], + }, + _toManyRelationshipRequest: { + type: 'object', + properties: { + data: { + type: 'array', + items: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }, + required: ['data'], + }, + _toOneRelationshipRequest: { + type: 'object', + properties: { + data: { + oneOf: [{ $ref: '#/components/schemas/_resourceIdentifier' }, { type: 'null' }], + }, + }, + required: ['data'], + }, + _toManyRelationshipResponse: { + type: 'object', + properties: { + data: { + type: 'array', + items: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + links: { $ref: '#/components/schemas/_pagedRelationLinks' }, + meta: { $ref: '#/components/schemas/_meta' }, + }, + }, + _toOneRelationshipResponse: { + type: 'object', + properties: { + data: { + oneOf: [{ $ref: '#/components/schemas/_resourceIdentifier' }, { type: 'null' }], + }, + links: { $ref: '#/components/schemas/_relationLinks' }, + meta: { $ref: '#/components/schemas/_meta' }, + }, + }, + }; + } + + private buildEnumSchema(enumDef: EnumDef): SchemaObject { + return { + type: 'string', + enum: Object.values(enumDef.values), + }; + } + + private buildTypeDefSchema(typeDef: TypeDefDef): SchemaObject { + const properties: Record = {}; + const required: string[] = []; + + for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) { + properties[fieldName] = this.fieldToSchema(fieldDef); + if (!fieldDef.optional && !fieldDef.array) { + required.push(fieldName); + } + } + + const result: SchemaObject = { type: 'object', properties }; + if (required.length > 0) { + result.required = required; + } + return result; + } + + private buildModelReadSchema(modelName: string, modelDef: ModelDef): SchemaObject { + const attrProperties: Record = {}; + const attrRequired: string[] = []; + const relProperties: Record = {}; + + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.omit) continue; + if (isFieldOmitted(modelName, fieldName, this.queryOptions)) continue; + if (fieldDef.relation && !isModelIncluded(fieldDef.type, this.queryOptions)) continue; + + if (fieldDef.relation) { + const relRef: SchemaObject | ReferenceObject = fieldDef.array + ? { $ref: '#/components/schemas/_toManyRelationshipWithLinks' } + : { $ref: '#/components/schemas/_toOneRelationshipWithLinks' }; + relProperties[fieldName] = fieldDef.optional ? { oneOf: [{ type: 'null' }, relRef] } : relRef; + } else { + const schema = this.fieldToSchema(fieldDef); + const fieldDescription = getMetaDescription(fieldDef.attributes); + if (fieldDescription && !('$ref' in schema)) { + schema.description = fieldDescription; + } + attrProperties[fieldName] = schema; + + if (!fieldDef.optional && !fieldDef.array) { + attrRequired.push(fieldName); + } + } + } + + const properties: Record = {}; + + if (Object.keys(attrProperties).length > 0) { + const attrSchema: SchemaObject = { type: 'object', properties: attrProperties }; + if (attrRequired.length > 0) attrSchema.required = attrRequired; + properties['attributes'] = attrSchema; + } + + if (Object.keys(relProperties).length > 0) { + properties['relationships'] = { type: 'object', properties: relProperties }; + } + + const result: SchemaObject = { type: 'object', properties }; + const description = getMetaDescription(modelDef.attributes); + if (description) { + result.description = description; + } + return result; + } + + private buildCreateRequestSchema(_modelName: string, modelDef: ModelDef): SchemaObject { + const idFieldNames = new Set(modelDef.idFields); + const attributes: Record = {}; + const attrRequired: string[] = []; + const relationships: Record = {}; + + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.updatedAt) continue; + if (fieldDef.foreignKeyFor) continue; + // Skip auto-generated id fields + if (idFieldNames.has(fieldName) && fieldDef.default !== undefined) continue; + if (fieldDef.relation && !isModelIncluded(fieldDef.type, this.queryOptions)) continue; + + if (fieldDef.relation) { + relationships[fieldName] = fieldDef.array + ? { + type: 'object', + properties: { + data: { + type: 'array', + items: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }, + } + : { + type: 'object', + properties: { + data: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }; + } else { + attributes[fieldName] = this.fieldToSchema(fieldDef); + if (!fieldDef.optional && fieldDef.default === undefined && !fieldDef.array) { + attrRequired.push(fieldName); + } + } + } + + const dataProperties: Record = { + type: { type: 'string' }, + }; + + if (Object.keys(attributes).length > 0) { + const attrSchema: SchemaObject = { type: 'object', properties: attributes }; + if (attrRequired.length > 0) attrSchema.required = attrRequired; + dataProperties['attributes'] = attrSchema; + } + + if (Object.keys(relationships).length > 0) { + dataProperties['relationships'] = { type: 'object', properties: relationships }; + } + + return { + type: 'object', + properties: { + data: { + type: 'object', + properties: dataProperties, + required: ['type'], + }, + }, + required: ['data'], + }; + } + + private buildUpdateRequestSchema(modelDef: ModelDef): SchemaObject { + const attributes: Record = {}; + const relationships: Record = {}; + + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.updatedAt) continue; + if (fieldDef.foreignKeyFor) continue; + if (fieldDef.relation && !isModelIncluded(fieldDef.type, this.queryOptions)) continue; + + if (fieldDef.relation) { + relationships[fieldName] = fieldDef.array + ? { + type: 'object', + properties: { + data: { + type: 'array', + items: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }, + } + : { + type: 'object', + properties: { + data: { $ref: '#/components/schemas/_resourceIdentifier' }, + }, + }; + } else { + attributes[fieldName] = this.fieldToSchema(fieldDef); + } + } + + const dataProperties: Record = { + type: { type: 'string' }, + id: { type: 'string' }, + }; + + if (Object.keys(attributes).length > 0) { + dataProperties['attributes'] = { type: 'object', properties: attributes }; + } + + if (Object.keys(relationships).length > 0) { + dataProperties['relationships'] = { type: 'object', properties: relationships }; + } + + return { + type: 'object', + properties: { + data: { + type: 'object', + properties: dataProperties, + required: ['type', 'id'], + }, + }, + required: ['data'], + }; + } + + private buildModelResponseSchema(modelName: string): SchemaObject { + return { + type: 'object', + properties: { + jsonapi: { $ref: '#/components/schemas/_jsonapi' }, + data: { + allOf: [{ $ref: `#/components/schemas/${modelName}` }, { $ref: '#/components/schemas/_resource' }], + }, + meta: { $ref: '#/components/schemas/_meta' }, + }, + }; + } + + private buildModelListResponseSchema(modelName: string): SchemaObject { + return { + type: 'object', + properties: { + jsonapi: { $ref: '#/components/schemas/_jsonapi' }, + data: { + type: 'array', + items: { + allOf: [ + { $ref: `#/components/schemas/${modelName}` }, + { $ref: '#/components/schemas/_resource' }, + ], + }, + }, + links: { + allOf: [{ $ref: '#/components/schemas/_pagination' }, { $ref: '#/components/schemas/_links' }], + }, + meta: { $ref: '#/components/schemas/_meta' }, + }, + }; + } + + private generateSharedParams(): Record { + return { + id: { + name: 'id', + in: 'path', + required: true, + schema: { type: 'string' }, + description: 'Resource ID', + }, + include: { + name: 'include', + in: 'query', + schema: { type: 'string' }, + description: 'Comma-separated list of relationships to include', + }, + sort: { + name: 'sort', + in: 'query', + schema: { type: 'string' }, + description: 'Comma-separated list of fields to sort by. Prefix with - for descending', + }, + pageOffset: { + name: 'page[offset]', + in: 'query', + schema: { type: 'integer', minimum: 0 }, + description: 'Page offset', + }, + pageLimit: { + name: 'page[limit]', + in: 'query', + schema: { type: 'integer', minimum: 1 }, + description: 'Page limit', + }, + }; + } + + private fieldToSchema(fieldDef: FieldDef): SchemaObject | ReferenceObject { + const baseSchema = this.typeToSchema(fieldDef.type); + if (fieldDef.array) { + return { type: 'array', items: baseSchema }; + } + if (fieldDef.optional) { + return { oneOf: [baseSchema, { type: 'null' }] }; + } + return baseSchema; + } + + private typeToSchema(type: string): SchemaObject | ReferenceObject { + switch (type) { + case 'String': + return { type: 'string' }; + case 'Int': + case 'BigInt': + return { type: 'integer' }; + case 'Float': + return { type: 'number' }; + case 'Decimal': + return { oneOf: [{ type: 'number' }, { type: 'string' }] }; + case 'Boolean': + return { type: 'boolean' }; + case 'DateTime': + return { type: 'string', format: 'date-time' }; + case 'Bytes': + return { type: 'string', format: 'byte' }; + case 'Json': + case 'Unsupported': + return {}; + default: + return { $ref: `#/components/schemas/${type}` }; + } + } + + private getIdFields(modelDef: ModelDef): FieldDef[] { + return modelDef.idFields.map((name) => modelDef.fields[name]).filter((f): f is FieldDef => f !== undefined); + } + + /** + * Checks if an operation on a model may be denied by access policies. + * Returns true when `respectAccessPolicies` is enabled and the model's + * policies for the given operation are NOT a constant allow (i.e., not + * simply `@@allow('...', true)` with no `@@deny` rules). + */ + private mayDenyAccess(modelDef: ModelDef, operation: string): boolean { + if (!this.specOptions?.respectAccessPolicies) return false; + + const policyAttrs = (modelDef.attributes ?? []).filter( + (attr) => attr.name === '@@allow' || attr.name === '@@deny', + ); + + // No policy rules at all means default-deny + if (policyAttrs.length === 0) return true; + + const getArgByName = (args: AttributeApplication['args'], name: string) => + args?.find((a) => a.name === name)?.value; + + const matchesOperation = (args: AttributeApplication['args']) => { + const val = getArgByName(args, 'operation'); + if (!val || val.kind !== 'literal' || typeof val.value !== 'string') return false; + const ops = val.value.split(',').map((s) => s.trim()); + return ops.includes(operation) || ops.includes('all'); + }; + + const hasEffectiveDeny = policyAttrs.some((attr) => { + if (attr.name !== '@@deny' || !matchesOperation(attr.args)) return false; + const condition = getArgByName(attr.args, 'condition'); + // @@deny('op', false) is a no-op — skip it + return !(condition?.kind === 'literal' && condition.value === false); + }); + if (hasEffectiveDeny) return true; + + const relevantAllow = policyAttrs.filter( + (attr) => attr.name === '@@allow' && matchesOperation(attr.args), + ); + + // If any allow rule has a constant `true` condition (and no deny), access is unconditional + const hasConstantAllow = relevantAllow.some((attr) => { + const condition = getArgByName(attr.args, 'condition'); + return condition?.kind === 'literal' && condition.value === true; + }); + + return !hasConstantAllow; + } +} diff --git a/packages/server/src/api/rpc/index.ts b/packages/server/src/api/rpc/index.ts index 7b3cbcb39..712170f9f 100644 --- a/packages/server/src/api/rpc/index.ts +++ b/packages/server/src/api/rpc/index.ts @@ -7,7 +7,8 @@ import z from 'zod'; import { fromError } from 'zod-validation-error/v4'; import type { ApiHandler, LogConfig, RequestContext, Response } from '../../types'; import { getProcedureDef, mapProcedureArgs, PROCEDURE_ROUTE_PREFIXES } from '../common/procedures'; -import { loggerSchema } from '../common/schemas'; +import { loggerSchema, queryOptionsSchema } from '../common/schemas'; +import type { CommonHandlerOptions } from '../common/types'; import { processSuperJsonRequestPayload, unmarshalQ } from '../common/utils'; import { log, registerCustomSerializers } from '../utils'; @@ -29,7 +30,7 @@ export type RPCApiHandlerOptions = { * Logging configuration */ log?: LogConfig; -}; +} & CommonHandlerOptions; /** * RPC style API request handler that mirrors the ZenStackClient API @@ -40,7 +41,11 @@ export class RPCApiHandler implements ApiH } private validateOptions(options: RPCApiHandlerOptions) { - const schema = z.strictObject({ schema: z.object(), log: loggerSchema.optional() }); + const schema = z.strictObject({ + schema: z.object(), + log: loggerSchema.optional(), + queryOptions: queryOptionsSchema.optional(), + }); const parseResult = schema.safeParse(options); if (!parseResult.success) { throw new Error(`Invalid options: ${fromError(parseResult.error)}`); @@ -240,7 +245,11 @@ export class RPCApiHandler implements ApiH if (!this.isValidModel(client, lowerCaseFirst(itemModel))) { return this.makeBadInputErrorResponse(`operation at index ${i} has unknown model: ${itemModel}`); } - if (itemArgs !== undefined && itemArgs !== null && (typeof itemArgs !== 'object' || Array.isArray(itemArgs))) { + if ( + itemArgs !== undefined && + itemArgs !== null && + (typeof itemArgs !== 'object' || Array.isArray(itemArgs)) + ) { return this.makeBadInputErrorResponse(`operation at index ${i} has invalid "args" field`); } diff --git a/packages/server/test/api/options-validation.test.ts b/packages/server/test/api/options-validation.test.ts index 53f7f3680..e902896f4 100644 --- a/packages/server/test/api/options-validation.test.ts +++ b/packages/server/test/api/options-validation.test.ts @@ -202,6 +202,16 @@ describe('API Handler Options Validation', () => { }).toThrow('Invalid options'); }); + it('should throw error when nestedRoutes is not a boolean', () => { + expect(() => { + new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + nestedRoutes: 'invalid' as any, + }); + }).toThrow('Invalid options'); + }); + it('should throw error when log is invalid type', () => { expect(() => { new RestApiHandler({ diff --git a/packages/server/test/api/rest.test.ts b/packages/server/test/api/rest.test.ts index ec0a6a8a9..52d7242b2 100644 --- a/packages/server/test/api/rest.test.ts +++ b/packages/server/test/api/rest.test.ts @@ -3549,4 +3549,640 @@ mutation procedure sum(a: Int, b: Int): Int expect(r.body).toMatchObject({ data: 3 }); }); }); + + describe('Nested routes', () => { + let nestedClient: ClientContract; + let nestedHandler: (any: any) => Promise<{ status: number; body: any }>; + + const nestedSchema = ` + model User { + id String @id @default(cuid()) + email String @unique + posts Post[] + } + + model Post { + id Int @id @default(autoincrement()) + title String + author User @relation(fields: [authorId], references: [id]) + authorId String + } + `; + + beforeEach(async () => { + nestedClient = await createTestClient(nestedSchema); + const api = new RestApiHandler({ + schema: nestedClient.$schema, + endpoint: 'http://localhost/api', + nestedRoutes: true, + }); + nestedHandler = (args) => api.handleRequest({ ...args, url: new URL(`http://localhost/${args.path}`) }); + }); + + it('scopes nested collection reads to parent', async () => { + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { + create: [{ title: 'u1-post-1' }, { title: 'u1-post-2' }], + }, + }, + }); + + await nestedClient.user.create({ + data: { + id: 'u2', + email: 'u2@test.com', + posts: { + create: [{ title: 'u2-post-1' }], + }, + }, + }); + + const r = await nestedHandler({ + method: 'get', + path: '/user/u1/posts', + client: nestedClient, + }); + + expect(r.status).toBe(200); + expect(r.body.data).toHaveLength(2); + expect(r.body.data.map((item: any) => item.attributes.title).sort()).toEqual(['u1-post-1', 'u1-post-2']); + }); + + it('returns 404 for nested collection read when parent does not exist', async () => { + const r = await nestedHandler({ + method: 'get', + path: '/user/nonexistent/posts', + client: nestedClient, + }); + expect(r.status).toBe(404); + }); + + it('scopes nested single reads to parent', async () => { + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + }, + }); + + const user2 = await nestedClient.user.create({ + data: { + id: 'u2', + email: 'u2@test.com', + posts: { + create: [{ title: 'u2-post-1' }], + }, + }, + include: { + posts: true, + }, + }); + + const postId = user2.posts[0]!.id; + + const denied = await nestedHandler({ + method: 'get', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + }); + expect(denied.status).toBe(404); + + const allowed = await nestedHandler({ + method: 'get', + path: `/user/u2/posts/${postId}`, + client: nestedClient, + }); + expect(allowed.status).toBe(200); + expect(allowed.body.data.attributes.title).toBe('u2-post-1'); + }); + + it('returns 404 for nested single read when parent does not exist', async () => { + const r = await nestedHandler({ + method: 'get', + path: '/user/nonexistent/posts/1', + client: nestedClient, + }); + expect(r.status).toBe(404); + }); + + it('returns 404 for nested create when parent does not exist', async () => { + const r = await nestedHandler({ + method: 'post', + path: '/user/nonexistent/posts', + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { title: 'orphan' }, + }, + }, + }); + expect(r.status).toBe(404); + }); + + it('binds nested creates to parent relation automatically', async () => { + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + }, + }); + + const created = await nestedHandler({ + method: 'post', + path: '/user/u1/posts', + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { + title: 'nested-created', + }, + }, + }, + }); + + expect(created.status).toBe(201); + + const dbPost = await nestedClient.post.findFirst({ + where: { + title: 'nested-created', + }, + }); + + expect(dbPost?.authorId).toBe('u1'); + }); + + it('rejects nested create when payload specifies the forced parent relation', async () => { + await nestedClient.user.create({ + data: { id: 'u1', email: 'u1@test.com' }, + }); + await nestedClient.user.create({ + data: { id: 'u2', email: 'u2@test.com' }, + }); + + const r = await nestedHandler({ + method: 'post', + path: '/user/u1/posts', + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { title: 'conflict' }, + relationships: { + author: { data: { type: 'User', id: 'u2' } }, + }, + }, + }, + }); + + expect(r.status).toBe(400); + }); + + it('rejects nested create when attributes contain scalar FK for the forced parent relation', async () => { + await nestedClient.user.create({ + data: { id: 'u1', email: 'u1@test.com' }, + }); + await nestedClient.user.create({ + data: { id: 'u2', email: 'u2@test.com' }, + }); + + const r = await nestedHandler({ + method: 'post', + path: '/user/u1/posts', + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { title: 'conflict', authorId: 'u2' }, + }, + }, + }); + + expect(r.status).toBe(400); + }); + + it('scopes nested collection reads with filter and pagination', async () => { + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { + create: [{ title: 'alpha' }, { title: 'beta' }, { title: 'gamma' }], + }, + }, + }); + + const filtered = await nestedHandler({ + method: 'get', + path: '/user/u1/posts', + query: { 'filter[title]': 'alpha' }, + client: nestedClient, + }); + expect(filtered.status).toBe(200); + expect(filtered.body.data).toHaveLength(1); + expect(filtered.body.data[0].attributes.title).toBe('alpha'); + + const paged = await nestedHandler({ + method: 'get', + path: '/user/u1/posts', + query: { 'page[limit]': '2', 'page[offset]': '0' }, + client: nestedClient, + }); + expect(paged.status).toBe(200); + expect(paged.body.data).toHaveLength(2); + }); + + it('updates a child scoped to parent (PATCH)', async () => { + const user1 = await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'original' }] }, + }, + include: { posts: true }, + }); + const postId = user1.posts[0]!.id; + + await nestedClient.user.create({ data: { id: 'u2', email: 'u2@test.com' } }); + + // Cannot update a post that belongs to a different parent + const denied = await nestedHandler({ + method: 'patch', + path: `/user/u2/posts/${postId}`, + client: nestedClient, + requestBody: { + data: { type: 'Post', attributes: { title: 'denied-update' } }, + }, + }); + expect(denied.status).toBe(404); + + // Can update a post that belongs to the correct parent + const allowed = await nestedHandler({ + method: 'patch', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + requestBody: { + data: { type: 'Post', attributes: { title: 'updated' } }, + }, + }); + expect(allowed.status).toBe(200); + expect(allowed.body.data.attributes.title).toBe('updated'); + }); + + it('rejects nested PATCH when payload tries to change the parent relation', async () => { + const user1 = await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'post' }] }, + }, + include: { posts: true }, + }); + const postId = user1.posts[0]!.id; + await nestedClient.user.create({ data: { id: 'u2', email: 'u2@test.com' } }); + + const r = await nestedHandler({ + method: 'patch', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { title: 'new' }, + relationships: { + author: { data: { type: 'User', id: 'u2' } }, + }, + }, + }, + }); + expect(r.status).toBe(400); + }); + + it('rejects nested PATCH when attributes contain camelCase FK field', async () => { + const user1 = await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'post' }] }, + }, + include: { posts: true }, + }); + const postId = user1.posts[0]!.id; + await nestedClient.user.create({ data: { id: 'u2', email: 'u2@test.com' } }); + + const r = await nestedHandler({ + method: 'patch', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + requestBody: { + data: { + type: 'Post', + attributes: { title: 'new', authorId: 'u2' }, + }, + }, + }); + expect(r.status).toBe(400); + }); + + it('deletes a child scoped to parent (DELETE)', async () => { + const user1 = await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'to-delete' }] }, + }, + include: { posts: true }, + }); + const postId = user1.posts[0]!.id; + await nestedClient.user.create({ data: { id: 'u2', email: 'u2@test.com' } }); + + // Cannot delete a post via the wrong parent + const denied = await nestedHandler({ + method: 'delete', + path: `/user/u2/posts/${postId}`, + client: nestedClient, + }); + expect(denied.status).toBe(404); + + // Can delete via the correct parent + const allowed = await nestedHandler({ + method: 'delete', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + }); + expect(allowed.status).toBe(200); + + const gone = await nestedClient.post.findFirst({ where: { id: postId } }); + expect(gone).toBeNull(); + }); + + it('falls back to fetchRelated for non-configured 3-segment paths', async () => { + const user1 = await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'p1' }] }, + }, + }); + + // 'author' is a relation on Post, not a nestedRoute → fetchRelated + const post = await nestedClient.post.findFirst({ where: { authorId: 'u1' } }); + const r = await nestedHandler({ + method: 'get', + path: `/post/${post!.id}/author`, + client: nestedClient, + }); + expect(r.status).toBe(200); + expect(r.body.data.id).toBe(user1.id); + }); + + it('supports PATCH /:type/:id/:relationship for to-one nested update', async () => { + await nestedClient.user.create({ data: { id: 'u1', email: 'u1@test.com' } }); + await nestedClient.user.create({ data: { id: 'u2', email: 'u2@test.com' } }); + const post = await nestedClient.post.create({ + data: { title: 'my-post', author: { connect: { id: 'u1' } } }, + }); + + // PATCH /post/:id/author — update the to-one related author's attributes + const updated = await nestedHandler({ + method: 'patch', + path: `/post/${post.id}/author`, + client: nestedClient, + requestBody: { + data: { type: 'user', id: 'u1', attributes: { email: 'u1-new@test.com' } }, + }, + }); + expect(updated.status).toBe(200); + expect(updated.body.data.attributes.email).toBe('u1-new@test.com'); + expect(updated.body.links.self).toBe(`http://localhost/api/post/${post.id}/author`); + expect(updated.body.data.links.self).toBe(`http://localhost/api/post/${post.id}/author`); + + // Verify the DB was actually updated + const dbUser = await nestedClient.user.findUnique({ where: { id: 'u1' } }); + expect(dbUser?.email).toBe('u1-new@test.com'); + + // Attempting to change the back-relation (posts) via the nested route should be rejected + const rejected = await nestedHandler({ + method: 'patch', + path: `/post/${post.id}/author`, + client: nestedClient, + requestBody: { + data: { + type: 'user', + id: 'u1', + relationships: { posts: { data: [{ type: 'post', id: String(post.id) }] } }, + }, + }, + }); + expect(rejected.status).toBe(400); + }); + + it('returns 400 for PATCH /:type/:id/:relationship to-one when nestedRoutes is not enabled', async () => { + const api = new RestApiHandler({ + schema: nestedClient.$schema, + endpoint: 'http://localhost/api', + // nestedRoutes not enabled + }); + const plainHandler = (args: any) => + api.handleRequest({ ...args, url: new URL(`http://localhost/${args.path}`) }); + + await nestedClient.user.create({ data: { id: 'u1', email: 'u1@test.com' } }); + const post = await nestedClient.post.create({ + data: { title: 'my-post', author: { connect: { id: 'u1' } } }, + }); + + const r = await plainHandler({ + method: 'patch', + path: `/post/${post.id}/author`, + client: nestedClient, + requestBody: { data: { type: 'user', id: 'u1', attributes: { email: 'x@test.com' } } }, + }); + expect(r.status).toBe(400); + }); + + it('returns nested self-links in JSON:API responses for all nested operations', async () => { + await nestedClient.user.create({ data: { id: 'u1', email: 'u1@test.com' } }); + + // POST /user/u1/posts — nested create + const created = await nestedHandler({ + method: 'post', + path: '/user/u1/posts', + client: nestedClient, + requestBody: { data: { type: 'post', attributes: { title: 'hello' } } }, + }); + expect(created.status).toBe(201); + const postId = created.body.data.id; + expect(created.body.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + expect(created.body.data.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + + // GET /user/u1/posts/:id — nested single read + const single = await nestedHandler({ + method: 'get', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + }); + expect(single.status).toBe(200); + expect(single.body.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + expect(single.body.data.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + + // PATCH /user/u1/posts/:id — nested update + const updated = await nestedHandler({ + method: 'patch', + path: `/user/u1/posts/${postId}`, + client: nestedClient, + requestBody: { data: { type: 'post', id: String(postId), attributes: { title: 'updated' } } }, + }); + expect(updated.status).toBe(200); + expect(updated.body.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + expect(updated.body.data.links.self).toBe(`http://localhost/api/user/u1/posts/${postId}`); + }); + + it('works with modelNameMapping on both parent and child segments', async () => { + const mappedApi = new RestApiHandler({ + schema: nestedClient.$schema, + endpoint: 'http://localhost/api', + modelNameMapping: { User: 'users', Post: 'posts' }, + nestedRoutes: true, + }); + const mappedHandler = (args: any) => + mappedApi.handleRequest({ ...args, url: new URL(`http://localhost/${args.path}`) }); + + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'mapped-post' }] }, + }, + }); + await nestedClient.user.create({ + data: { id: 'u2', email: 'u2@test.com' }, + }); + + const collection = await mappedHandler({ + method: 'get', + path: '/users/u1/posts', + client: nestedClient, + }); + expect(collection.status).toBe(200); + expect(collection.body.data).toHaveLength(1); + expect(collection.body.data[0].attributes.title).toBe('mapped-post'); + + // Parent with no posts → 200 with empty collection + const denied = await mappedHandler({ + method: 'get', + path: '/users/u2/posts', + client: nestedClient, + }); + expect(denied.status).toBe(200); + expect(denied.body.data).toHaveLength(0); + }); + + it('falls back to fetchRelated for mapped child names without nestedRoutes', async () => { + const mappedApi = new RestApiHandler({ + schema: nestedClient.$schema, + endpoint: 'http://localhost/api', + modelNameMapping: { User: 'users', Post: 'posts' }, + }); + const mappedHandler = (args: any) => + mappedApi.handleRequest({ ...args, url: new URL(`http://localhost/${args.path}`) }); + + await nestedClient.user.create({ + data: { + id: 'u1', + email: 'u1@test.com', + posts: { create: [{ title: 'mapped-fallback-post' }] }, + }, + }); + await nestedClient.user.create({ + data: { id: 'u2', email: 'u2@test.com' }, + }); + + const collection = await mappedHandler({ + method: 'get', + path: '/users/u1/posts', + client: nestedClient, + }); + expect(collection.status).toBe(200); + expect(collection.body.data).toHaveLength(1); + expect(collection.body.data[0].attributes.title).toBe('mapped-fallback-post'); + + const empty = await mappedHandler({ + method: 'get', + path: '/users/u2/posts', + client: nestedClient, + }); + expect(empty.status).toBe(200); + expect(empty.body.data).toHaveLength(0); + }); + + it('exercises mapped nested-route mutations and verifies link metadata', async () => { + const mappedApi = new RestApiHandler({ + schema: nestedClient.$schema, + endpoint: 'http://localhost/api', + modelNameMapping: { User: 'users', Post: 'posts' }, + nestedRoutes: true, + }); + const mappedHandler = (args: any) => + mappedApi.handleRequest({ ...args, url: new URL(`http://localhost/${args.path}`) }); + + await nestedClient.user.create({ data: { id: 'u1', email: 'u1@test.com' } }); + + // POST /users/u1/posts — nested create via mapped route + const created = await mappedHandler({ + method: 'post', + path: '/users/u1/posts', + client: nestedClient, + requestBody: { data: { type: 'posts', attributes: { title: 'mapped-create' } } }, + }); + expect(created.status).toBe(201); + const postId = created.body.data.id; + expect(created.body.links.self).toBe(`http://localhost/api/users/u1/posts/${postId}`); + expect(created.body.data.links.self).toBe(`http://localhost/api/users/u1/posts/${postId}`); + + // GET /users/u1/posts — list should contain the new post + const afterCreate = await mappedHandler({ + method: 'get', + path: '/users/u1/posts', + client: nestedClient, + }); + expect(afterCreate.status).toBe(200); + expect(afterCreate.body.data).toHaveLength(1); + expect(afterCreate.body.links.self).toBe('http://localhost/api/users/u1/posts'); + + // PATCH /users/u1/posts/:id — nested update via mapped route + const updated = await mappedHandler({ + method: 'patch', + path: `/users/u1/posts/${postId}`, + client: nestedClient, + requestBody: { + data: { type: 'posts', id: String(postId), attributes: { title: 'mapped-updated' } }, + }, + }); + expect(updated.status).toBe(200); + expect(updated.body.data.attributes.title).toBe('mapped-updated'); + expect(updated.body.links.self).toBe(`http://localhost/api/users/u1/posts/${postId}`); + expect(updated.body.data.links.self).toBe(`http://localhost/api/users/u1/posts/${postId}`); + + // DELETE /users/u1/posts/:id — nested delete via mapped route + const deleted = await mappedHandler({ + method: 'delete', + path: `/users/u1/posts/${postId}`, + client: nestedClient, + }); + expect(deleted.status).toBe(200); + + // GET /users/u1/posts — list should now be empty + const afterDelete = await mappedHandler({ + method: 'get', + path: '/users/u1/posts', + client: nestedClient, + }); + expect(afterDelete.status).toBe(200); + expect(afterDelete.body.data).toHaveLength(0); + }); + }); }); diff --git a/packages/server/test/openapi/baseline/rest.baseline.yaml b/packages/server/test/openapi/baseline/rest.baseline.yaml new file mode 100644 index 000000000..311a26a30 --- /dev/null +++ b/packages/server/test/openapi/baseline/rest.baseline.yaml @@ -0,0 +1,4171 @@ +openapi: 3.1.0 +info: + title: ZenStack Generated API + version: 1.0.0 +tags: + - name: user + description: User operations + - name: profile + description: Profile operations + - name: post + description: Post operations + - name: comment + description: Comment operations + - name: setting + description: Setting operations + - name: postLike + description: PostLike operations + - name: postLikeInfo + description: PostLikeInfo operations +paths: + /user: + get: + tags: + - user + summary: List User resources + operationId: listUser + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by User ID + - name: filter[createdAt] + in: query + schema: + type: string + description: Filter by createdAt + - name: filter[createdAt][$lt] + in: query + schema: + type: string + - name: filter[createdAt][$lte] + in: query + schema: + type: string + - name: filter[createdAt][$gt] + in: query + schema: + type: string + - name: filter[createdAt][$gte] + in: query + schema: + type: string + - name: filter[updatedAt] + in: query + schema: + type: string + description: Filter by updatedAt + - name: filter[updatedAt][$lt] + in: query + schema: + type: string + - name: filter[updatedAt][$lte] + in: query + schema: + type: string + - name: filter[updatedAt][$gt] + in: query + schema: + type: string + - name: filter[updatedAt][$gte] + in: query + schema: + type: string + - name: filter[email] + in: query + schema: + type: string + description: Filter by email + - name: filter[email][$contains] + in: query + schema: + type: string + - name: filter[email][$icontains] + in: query + schema: + type: string + - name: filter[email][$search] + in: query + schema: + type: string + - name: filter[email][$startsWith] + in: query + schema: + type: string + - name: filter[email][$endsWith] + in: query + schema: + type: string + - name: filter[address] + in: query + schema: + type: string + description: Filter by address + - name: filter[someJson] + in: query + schema: + type: string + description: Filter by someJson + responses: + "200": + description: List of User resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - user + summary: Create a User resource + operationId: createUser + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserCreateRequest" + responses: + "201": + description: Created User resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}: + get: + tags: + - user + summary: Get a User resource by ID + operationId: getUser + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: User resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - user + summary: Update a User resource + operationId: updateUser + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserUpdateRequest" + responses: + "200": + description: Updated User resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - user + summary: Delete a User resource + operationId: deleteUser + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/posts: + get: + tags: + - user + summary: Fetch related Post for User + operationId: getUser_posts + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Post ID + - name: filter[createdAt] + in: query + schema: + type: string + description: Filter by createdAt + - name: filter[createdAt][$lt] + in: query + schema: + type: string + - name: filter[createdAt][$lte] + in: query + schema: + type: string + - name: filter[createdAt][$gt] + in: query + schema: + type: string + - name: filter[createdAt][$gte] + in: query + schema: + type: string + - name: filter[updatedAt] + in: query + schema: + type: string + description: Filter by updatedAt + - name: filter[updatedAt][$lt] + in: query + schema: + type: string + - name: filter[updatedAt][$lte] + in: query + schema: + type: string + - name: filter[updatedAt][$gt] + in: query + schema: + type: string + - name: filter[updatedAt][$gte] + in: query + schema: + type: string + - name: filter[title] + in: query + schema: + type: string + description: Filter by title + - name: filter[title][$contains] + in: query + schema: + type: string + - name: filter[title][$icontains] + in: query + schema: + type: string + - name: filter[title][$search] + in: query + schema: + type: string + - name: filter[title][$startsWith] + in: query + schema: + type: string + - name: filter[title][$endsWith] + in: query + schema: + type: string + - name: filter[authorId] + in: query + schema: + type: string + description: Filter by authorId + - name: filter[authorId][$contains] + in: query + schema: + type: string + - name: filter[authorId][$icontains] + in: query + schema: + type: string + - name: filter[authorId][$search] + in: query + schema: + type: string + - name: filter[authorId][$startsWith] + in: query + schema: + type: string + - name: filter[authorId][$endsWith] + in: query + schema: + type: string + - name: filter[published] + in: query + schema: + type: string + description: Filter by published + - name: filter[publishedAt] + in: query + schema: + type: string + description: Filter by publishedAt + - name: filter[publishedAt][$lt] + in: query + schema: + type: string + - name: filter[publishedAt][$lte] + in: query + schema: + type: string + - name: filter[publishedAt][$gt] + in: query + schema: + type: string + - name: filter[publishedAt][$gte] + in: query + schema: + type: string + - name: filter[viewCount] + in: query + schema: + type: string + description: Filter by viewCount + - name: filter[viewCount][$lt] + in: query + schema: + type: string + - name: filter[viewCount][$lte] + in: query + schema: + type: string + - name: filter[viewCount][$gt] + in: query + schema: + type: string + - name: filter[viewCount][$gte] + in: query + schema: + type: string + responses: + "200": + description: Related Post resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostListResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/relationships/posts: + get: + tags: + - user + summary: Fetch posts relationship + operationId: getUser_relationships_posts + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: posts relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - user + summary: Replace posts relationship + operationId: putUser_relationships_posts + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - user + summary: Update posts relationship + operationId: patchUser_relationships_posts + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - user + summary: Add to posts collection relationship + operationId: postUser_relationships_posts + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Added to relationship collection + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/likes: + get: + tags: + - user + summary: Fetch related PostLike for User + operationId: getUser_likes + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by PostLike ID + - name: filter[superLike] + in: query + schema: + type: string + description: Filter by superLike + responses: + "200": + description: Related PostLike resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeListResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/relationships/likes: + get: + tags: + - user + summary: Fetch likes relationship + operationId: getUser_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: likes relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - user + summary: Replace likes relationship + operationId: putUser_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - user + summary: Update likes relationship + operationId: patchUser_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - user + summary: Add to likes collection relationship + operationId: postUser_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Added to relationship collection + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/profile: + get: + tags: + - user + summary: Fetch related Profile for User + operationId: getUser_profile + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related Profile resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /user/{id}/relationships/profile: + get: + tags: + - user + summary: Fetch profile relationship + operationId: getUser_relationships_profile + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: profile relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - user + summary: Replace profile relationship + operationId: putUser_relationships_profile + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - user + summary: Update profile relationship + operationId: patchUser_relationships_profile + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /profile: + get: + tags: + - profile + summary: List Profile resources + operationId: listProfile + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Profile ID + - name: filter[gender] + in: query + schema: + type: string + description: Filter by gender + - name: filter[gender][$contains] + in: query + schema: + type: string + - name: filter[gender][$icontains] + in: query + schema: + type: string + - name: filter[gender][$search] + in: query + schema: + type: string + - name: filter[gender][$startsWith] + in: query + schema: + type: string + - name: filter[gender][$endsWith] + in: query + schema: + type: string + - name: filter[userId] + in: query + schema: + type: string + description: Filter by userId + - name: filter[userId][$contains] + in: query + schema: + type: string + - name: filter[userId][$icontains] + in: query + schema: + type: string + - name: filter[userId][$search] + in: query + schema: + type: string + - name: filter[userId][$startsWith] + in: query + schema: + type: string + - name: filter[userId][$endsWith] + in: query + schema: + type: string + responses: + "200": + description: List of Profile resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - profile + summary: Create a Profile resource + operationId: createProfile + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileCreateRequest" + responses: + "201": + description: Created Profile resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /profile/{id}: + get: + tags: + - profile + summary: Get a Profile resource by ID + operationId: getProfile + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Profile resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - profile + summary: Update a Profile resource + operationId: updateProfile + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileUpdateRequest" + responses: + "200": + description: Updated Profile resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/ProfileResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - profile + summary: Delete a Profile resource + operationId: deleteProfile + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /profile/{id}/user: + get: + tags: + - profile + summary: Fetch related User for Profile + operationId: getProfile_user + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related User resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /profile/{id}/relationships/user: + get: + tags: + - profile + summary: Fetch user relationship + operationId: getProfile_relationships_user + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: user relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - profile + summary: Replace user relationship + operationId: putProfile_relationships_user + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - profile + summary: Update user relationship + operationId: patchProfile_relationships_user + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post: + get: + tags: + - post + summary: List Post resources + operationId: listPost + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Post ID + - name: filter[createdAt] + in: query + schema: + type: string + description: Filter by createdAt + - name: filter[createdAt][$lt] + in: query + schema: + type: string + - name: filter[createdAt][$lte] + in: query + schema: + type: string + - name: filter[createdAt][$gt] + in: query + schema: + type: string + - name: filter[createdAt][$gte] + in: query + schema: + type: string + - name: filter[updatedAt] + in: query + schema: + type: string + description: Filter by updatedAt + - name: filter[updatedAt][$lt] + in: query + schema: + type: string + - name: filter[updatedAt][$lte] + in: query + schema: + type: string + - name: filter[updatedAt][$gt] + in: query + schema: + type: string + - name: filter[updatedAt][$gte] + in: query + schema: + type: string + - name: filter[title] + in: query + schema: + type: string + description: Filter by title + - name: filter[title][$contains] + in: query + schema: + type: string + - name: filter[title][$icontains] + in: query + schema: + type: string + - name: filter[title][$search] + in: query + schema: + type: string + - name: filter[title][$startsWith] + in: query + schema: + type: string + - name: filter[title][$endsWith] + in: query + schema: + type: string + - name: filter[authorId] + in: query + schema: + type: string + description: Filter by authorId + - name: filter[authorId][$contains] + in: query + schema: + type: string + - name: filter[authorId][$icontains] + in: query + schema: + type: string + - name: filter[authorId][$search] + in: query + schema: + type: string + - name: filter[authorId][$startsWith] + in: query + schema: + type: string + - name: filter[authorId][$endsWith] + in: query + schema: + type: string + - name: filter[published] + in: query + schema: + type: string + description: Filter by published + - name: filter[publishedAt] + in: query + schema: + type: string + description: Filter by publishedAt + - name: filter[publishedAt][$lt] + in: query + schema: + type: string + - name: filter[publishedAt][$lte] + in: query + schema: + type: string + - name: filter[publishedAt][$gt] + in: query + schema: + type: string + - name: filter[publishedAt][$gte] + in: query + schema: + type: string + - name: filter[viewCount] + in: query + schema: + type: string + description: Filter by viewCount + - name: filter[viewCount][$lt] + in: query + schema: + type: string + - name: filter[viewCount][$lte] + in: query + schema: + type: string + - name: filter[viewCount][$gt] + in: query + schema: + type: string + - name: filter[viewCount][$gte] + in: query + schema: + type: string + responses: + "200": + description: List of Post resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - post + summary: Create a Post resource + operationId: createPost + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostCreateRequest" + responses: + "201": + description: Created Post resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}: + get: + tags: + - post + summary: Get a Post resource by ID + operationId: getPost + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Post resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - post + summary: Update a Post resource + operationId: updatePost + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostUpdateRequest" + responses: + "200": + description: Updated Post resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - post + summary: Delete a Post resource + operationId: deletePost + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/author: + get: + tags: + - post + summary: Fetch related User for Post + operationId: getPost_author + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related User resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/relationships/author: + get: + tags: + - post + summary: Fetch author relationship + operationId: getPost_relationships_author + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: author relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - post + summary: Replace author relationship + operationId: putPost_relationships_author + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - post + summary: Update author relationship + operationId: patchPost_relationships_author + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/comments: + get: + tags: + - post + summary: Fetch related Comment for Post + operationId: getPost_comments + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Comment ID + - name: filter[postId] + in: query + schema: + type: string + description: Filter by postId + - name: filter[postId][$lt] + in: query + schema: + type: string + - name: filter[postId][$lte] + in: query + schema: + type: string + - name: filter[postId][$gt] + in: query + schema: + type: string + - name: filter[postId][$gte] + in: query + schema: + type: string + - name: filter[content] + in: query + schema: + type: string + description: Filter by content + - name: filter[content][$contains] + in: query + schema: + type: string + - name: filter[content][$icontains] + in: query + schema: + type: string + - name: filter[content][$search] + in: query + schema: + type: string + - name: filter[content][$startsWith] + in: query + schema: + type: string + - name: filter[content][$endsWith] + in: query + schema: + type: string + responses: + "200": + description: Related Comment resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentListResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/relationships/comments: + get: + tags: + - post + summary: Fetch comments relationship + operationId: getPost_relationships_comments + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: comments relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - post + summary: Replace comments relationship + operationId: putPost_relationships_comments + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - post + summary: Update comments relationship + operationId: patchPost_relationships_comments + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - post + summary: Add to comments collection relationship + operationId: postPost_relationships_comments + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Added to relationship collection + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/likes: + get: + tags: + - post + summary: Fetch related PostLike for Post + operationId: getPost_likes + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by PostLike ID + - name: filter[superLike] + in: query + schema: + type: string + description: Filter by superLike + responses: + "200": + description: Related PostLike resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeListResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/relationships/likes: + get: + tags: + - post + summary: Fetch likes relationship + operationId: getPost_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: likes relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - post + summary: Replace likes relationship + operationId: putPost_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - post + summary: Update likes relationship + operationId: patchPost_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - post + summary: Add to likes collection relationship + operationId: postPost_relationships_likes + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Added to relationship collection + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/setting: + get: + tags: + - post + summary: Fetch related Setting for Post + operationId: getPost_setting + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related Setting resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /post/{id}/relationships/setting: + get: + tags: + - post + summary: Fetch setting relationship + operationId: getPost_relationships_setting + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: setting relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - post + summary: Replace setting relationship + operationId: putPost_relationships_setting + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - post + summary: Update setting relationship + operationId: patchPost_relationships_setting + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /comment: + get: + tags: + - comment + summary: List Comment resources + operationId: listComment + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Comment ID + - name: filter[postId] + in: query + schema: + type: string + description: Filter by postId + - name: filter[postId][$lt] + in: query + schema: + type: string + - name: filter[postId][$lte] + in: query + schema: + type: string + - name: filter[postId][$gt] + in: query + schema: + type: string + - name: filter[postId][$gte] + in: query + schema: + type: string + - name: filter[content] + in: query + schema: + type: string + description: Filter by content + - name: filter[content][$contains] + in: query + schema: + type: string + - name: filter[content][$icontains] + in: query + schema: + type: string + - name: filter[content][$search] + in: query + schema: + type: string + - name: filter[content][$startsWith] + in: query + schema: + type: string + - name: filter[content][$endsWith] + in: query + schema: + type: string + responses: + "200": + description: List of Comment resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - comment + summary: Create a Comment resource + operationId: createComment + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentCreateRequest" + responses: + "201": + description: Created Comment resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /comment/{id}: + get: + tags: + - comment + summary: Get a Comment resource by ID + operationId: getComment + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Comment resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - comment + summary: Update a Comment resource + operationId: updateComment + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentUpdateRequest" + responses: + "200": + description: Updated Comment resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/CommentResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - comment + summary: Delete a Comment resource + operationId: deleteComment + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /comment/{id}/post: + get: + tags: + - comment + summary: Fetch related Post for Comment + operationId: getComment_post + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related Post resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /comment/{id}/relationships/post: + get: + tags: + - comment + summary: Fetch post relationship + operationId: getComment_relationships_post + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: post relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - comment + summary: Replace post relationship + operationId: putComment_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - comment + summary: Update post relationship + operationId: patchComment_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /setting: + get: + tags: + - setting + summary: List Setting resources + operationId: listSetting + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by Setting ID + - name: filter[boost] + in: query + schema: + type: string + description: Filter by boost + - name: filter[boost][$lt] + in: query + schema: + type: string + - name: filter[boost][$lte] + in: query + schema: + type: string + - name: filter[boost][$gt] + in: query + schema: + type: string + - name: filter[boost][$gte] + in: query + schema: + type: string + - name: filter[postId] + in: query + schema: + type: string + description: Filter by postId + - name: filter[postId][$lt] + in: query + schema: + type: string + - name: filter[postId][$lte] + in: query + schema: + type: string + - name: filter[postId][$gt] + in: query + schema: + type: string + - name: filter[postId][$gte] + in: query + schema: + type: string + responses: + "200": + description: List of Setting resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - setting + summary: Create a Setting resource + operationId: createSetting + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingCreateRequest" + responses: + "201": + description: Created Setting resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /setting/{id}: + get: + tags: + - setting + summary: Get a Setting resource by ID + operationId: getSetting + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Setting resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - setting + summary: Update a Setting resource + operationId: updateSetting + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingUpdateRequest" + responses: + "200": + description: Updated Setting resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/SettingResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - setting + summary: Delete a Setting resource + operationId: deleteSetting + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /setting/{id}/post: + get: + tags: + - setting + summary: Fetch related Post for Setting + operationId: getSetting_post + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related Post resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /setting/{id}/relationships/post: + get: + tags: + - setting + summary: Fetch post relationship + operationId: getSetting_relationships_post + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: post relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - setting + summary: Replace post relationship + operationId: putSetting_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - setting + summary: Update post relationship + operationId: patchSetting_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike: + get: + tags: + - postLike + summary: List PostLike resources + operationId: listPostLike + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by PostLike ID + - name: filter[superLike] + in: query + schema: + type: string + description: Filter by superLike + responses: + "200": + description: List of PostLike resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - postLike + summary: Create a PostLike resource + operationId: createPostLike + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeCreateRequest" + responses: + "201": + description: Created PostLike resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}: + get: + tags: + - postLike + summary: Get a PostLike resource by ID + operationId: getPostLike + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: PostLike resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLike + summary: Update a PostLike resource + operationId: updatePostLike + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeUpdateRequest" + responses: + "200": + description: Updated PostLike resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - postLike + summary: Delete a PostLike resource + operationId: deletePostLike + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/post: + get: + tags: + - postLike + summary: Fetch related Post for PostLike + operationId: getPostLike_post + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related Post resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/relationships/post: + get: + tags: + - postLike + summary: Fetch post relationship + operationId: getPostLike_relationships_post + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: post relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - postLike + summary: Replace post relationship + operationId: putPostLike_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLike + summary: Update post relationship + operationId: patchPostLike_relationships_post + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/user: + get: + tags: + - postLike + summary: Fetch related User for PostLike + operationId: getPostLike_user + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related User resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/UserResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/relationships/user: + get: + tags: + - postLike + summary: Fetch user relationship + operationId: getPostLike_relationships_user + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: user relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - postLike + summary: Replace user relationship + operationId: putPostLike_relationships_user + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLike + summary: Update user relationship + operationId: patchPostLike_relationships_user + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/likeInfos: + get: + tags: + - postLike + summary: Fetch related PostLikeInfo for PostLike + operationId: getPostLike_likeInfos + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by PostLikeInfo ID + - name: filter[text] + in: query + schema: + type: string + description: Filter by text + - name: filter[text][$contains] + in: query + schema: + type: string + - name: filter[text][$icontains] + in: query + schema: + type: string + - name: filter[text][$search] + in: query + schema: + type: string + - name: filter[text][$startsWith] + in: query + schema: + type: string + - name: filter[text][$endsWith] + in: query + schema: + type: string + - name: filter[postId] + in: query + schema: + type: string + description: Filter by postId + - name: filter[postId][$lt] + in: query + schema: + type: string + - name: filter[postId][$lte] + in: query + schema: + type: string + - name: filter[postId][$gt] + in: query + schema: + type: string + - name: filter[postId][$gte] + in: query + schema: + type: string + - name: filter[userId] + in: query + schema: + type: string + description: Filter by userId + - name: filter[userId][$contains] + in: query + schema: + type: string + - name: filter[userId][$icontains] + in: query + schema: + type: string + - name: filter[userId][$search] + in: query + schema: + type: string + - name: filter[userId][$startsWith] + in: query + schema: + type: string + - name: filter[userId][$endsWith] + in: query + schema: + type: string + responses: + "200": + description: Related PostLikeInfo resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoListResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLike/{id}/relationships/likeInfos: + get: + tags: + - postLike + summary: Fetch likeInfos relationship + operationId: getPostLike_relationships_likeInfos + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: likeInfos relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - postLike + summary: Replace likeInfos relationship + operationId: putPostLike_relationships_likeInfos + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLike + summary: Update likeInfos relationship + operationId: patchPostLike_relationships_likeInfos + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - postLike + summary: Add to likeInfos collection relationship + operationId: postPostLike_relationships_likeInfos + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toManyRelationshipRequest" + responses: + "200": + description: Added to relationship collection + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLikeInfo: + get: + tags: + - postLikeInfo + summary: List PostLikeInfo resources + operationId: listPostLikeInfo + parameters: + - $ref: "#/components/parameters/include" + - $ref: "#/components/parameters/sort" + - $ref: "#/components/parameters/pageOffset" + - $ref: "#/components/parameters/pageLimit" + - name: filter[id] + in: query + schema: + type: string + description: Filter by PostLikeInfo ID + - name: filter[text] + in: query + schema: + type: string + description: Filter by text + - name: filter[text][$contains] + in: query + schema: + type: string + - name: filter[text][$icontains] + in: query + schema: + type: string + - name: filter[text][$search] + in: query + schema: + type: string + - name: filter[text][$startsWith] + in: query + schema: + type: string + - name: filter[text][$endsWith] + in: query + schema: + type: string + - name: filter[postId] + in: query + schema: + type: string + description: Filter by postId + - name: filter[postId][$lt] + in: query + schema: + type: string + - name: filter[postId][$lte] + in: query + schema: + type: string + - name: filter[postId][$gt] + in: query + schema: + type: string + - name: filter[postId][$gte] + in: query + schema: + type: string + - name: filter[userId] + in: query + schema: + type: string + description: Filter by userId + - name: filter[userId][$contains] + in: query + schema: + type: string + - name: filter[userId][$icontains] + in: query + schema: + type: string + - name: filter[userId][$search] + in: query + schema: + type: string + - name: filter[userId][$startsWith] + in: query + schema: + type: string + - name: filter[userId][$endsWith] + in: query + schema: + type: string + responses: + "200": + description: List of PostLikeInfo resources + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoListResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + post: + tags: + - postLikeInfo + summary: Create a PostLikeInfo resource + operationId: createPostLikeInfo + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoCreateRequest" + responses: + "201": + description: Created PostLikeInfo resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLikeInfo/{id}: + get: + tags: + - postLikeInfo + summary: Get a PostLikeInfo resource by ID + operationId: getPostLikeInfo + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: PostLikeInfo resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLikeInfo + summary: Update a PostLikeInfo resource + operationId: updatePostLikeInfo + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoUpdateRequest" + responses: + "200": + description: Updated PostLikeInfo resource + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeInfoResponse" + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + "422": + description: Operation is unprocessable due to validation errors + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + delete: + tags: + - postLikeInfo + summary: Delete a PostLikeInfo resource + operationId: deletePostLikeInfo + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: Deleted successfully + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLikeInfo/{id}/postLike: + get: + tags: + - postLikeInfo + summary: Fetch related PostLike for PostLikeInfo + operationId: getPostLikeInfo_postLike + parameters: + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/include" + responses: + "200": + description: Related PostLike resource(s) + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/PostLikeResponse" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + /postLikeInfo/{id}/relationships/postLike: + get: + tags: + - postLikeInfo + summary: Fetch postLike relationship + operationId: getPostLikeInfo_relationships_postLike + parameters: + - $ref: "#/components/parameters/id" + responses: + "200": + description: postLike relationship + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + "404": + description: Resource not found + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + put: + tags: + - postLikeInfo + summary: Replace postLike relationship + operationId: putPostLikeInfo_relationships_postLike + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" + patch: + tags: + - postLikeInfo + summary: Update postLike relationship + operationId: patchPostLikeInfo_relationships_postLike + parameters: + - $ref: "#/components/parameters/id" + requestBody: + required: true + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_toOneRelationshipRequest" + responses: + "200": + description: Relationship updated + "400": + description: Error occurred while processing the request + content: + application/vnd.api+json: + schema: + $ref: "#/components/schemas/_errorResponse" +components: + schemas: + _jsonapi: + type: object + properties: + version: + type: string + meta: + type: object + _meta: + type: object + additionalProperties: true + _links: + type: object + properties: + self: + type: string + related: + type: string + _pagination: + type: object + properties: + first: + oneOf: + - type: string + - type: "null" + last: + oneOf: + - type: string + - type: "null" + prev: + oneOf: + - type: string + - type: "null" + next: + oneOf: + - type: string + - type: "null" + _errors: + type: array + items: + type: object + properties: + status: + type: integer + code: + type: string + title: + type: string + detail: + type: string + required: + - status + - title + _errorResponse: + type: object + properties: + errors: + $ref: "#/components/schemas/_errors" + required: + - errors + _resourceIdentifier: + type: object + properties: + type: + type: string + id: + type: string + required: + - type + - id + _resource: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + relationships: + type: object + links: + $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + required: + - type + - id + _relationLinks: + type: object + properties: + self: + type: string + related: + type: string + _pagedRelationLinks: + type: object + allOf: + - $ref: "#/components/schemas/_relationLinks" + - $ref: "#/components/schemas/_pagination" + _toOneRelationship: + type: object + properties: + data: + oneOf: + - $ref: "#/components/schemas/_resourceIdentifier" + - type: "null" + _toManyRelationship: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + _toOneRelationshipWithLinks: + type: object + allOf: + - $ref: "#/components/schemas/_toOneRelationship" + - properties: + links: + $ref: "#/components/schemas/_relationLinks" + _toManyRelationshipWithLinks: + type: object + allOf: + - $ref: "#/components/schemas/_toManyRelationship" + - properties: + links: + $ref: "#/components/schemas/_pagedRelationLinks" + _toManyRelationshipRequest: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - data + _toOneRelationshipRequest: + type: object + properties: + data: + oneOf: + - $ref: "#/components/schemas/_resourceIdentifier" + - type: "null" + required: + - data + _toManyRelationshipResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + links: + $ref: "#/components/schemas/_pagedRelationLinks" + meta: + $ref: "#/components/schemas/_meta" + _toOneRelationshipResponse: + type: object + properties: + data: + oneOf: + - $ref: "#/components/schemas/_resourceIdentifier" + - type: "null" + links: + $ref: "#/components/schemas/_relationLinks" + meta: + $ref: "#/components/schemas/_meta" + Address: + type: object + properties: + city: + type: string + required: + - city + User: + type: object + properties: + attributes: + type: object + properties: + myId: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + email: + type: string + address: + oneOf: + - $ref: "#/components/schemas/Address" + - type: "null" + someJson: + oneOf: + - {} + - type: "null" + required: + - myId + - createdAt + - updatedAt + - email + relationships: + type: object + properties: + posts: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + likes: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + profile: + oneOf: + - type: "null" + - $ref: "#/components/schemas/_toOneRelationshipWithLinks" + UserCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + createdAt: + type: string + format: date-time + email: + type: string + address: + oneOf: + - $ref: "#/components/schemas/Address" + - type: "null" + someJson: + oneOf: + - {} + - type: "null" + required: + - email + relationships: + type: object + properties: + posts: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + likes: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + profile: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + UserUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + myId: + type: string + createdAt: + type: string + format: date-time + email: + type: string + address: + oneOf: + - $ref: "#/components/schemas/Address" + - type: "null" + someJson: + oneOf: + - {} + - type: "null" + relationships: + type: object + properties: + posts: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + likes: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + profile: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + UserResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/User" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + UserListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/User" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + Profile: + type: object + properties: + attributes: + type: object + properties: + id: + type: integer + gender: + type: string + userId: + type: string + required: + - id + - gender + - userId + relationships: + type: object + properties: + user: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + ProfileCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + gender: + type: string + required: + - gender + relationships: + type: object + properties: + user: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + ProfileUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + id: + type: integer + gender: + type: string + relationships: + type: object + properties: + user: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + ProfileResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/Profile" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + ProfileListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/Profile" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + Post: + type: object + properties: + attributes: + type: object + properties: + id: + type: integer + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + title: + type: string + authorId: + oneOf: + - type: string + - type: "null" + published: + type: boolean + publishedAt: + oneOf: + - type: string + format: date-time + - type: "null" + viewCount: + type: integer + required: + - id + - createdAt + - updatedAt + - title + - published + - viewCount + relationships: + type: object + properties: + author: + oneOf: + - type: "null" + - $ref: "#/components/schemas/_toOneRelationshipWithLinks" + comments: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + likes: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + setting: + oneOf: + - type: "null" + - $ref: "#/components/schemas/_toOneRelationshipWithLinks" + PostCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + createdAt: + type: string + format: date-time + title: + type: string + published: + type: boolean + publishedAt: + oneOf: + - type: string + format: date-time + - type: "null" + viewCount: + type: integer + required: + - title + relationships: + type: object + properties: + author: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + comments: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + likes: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + setting: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + PostUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + id: + type: integer + createdAt: + type: string + format: date-time + title: + type: string + published: + type: boolean + publishedAt: + oneOf: + - type: string + format: date-time + - type: "null" + viewCount: + type: integer + relationships: + type: object + properties: + author: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + comments: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + likes: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + setting: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + PostResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/Post" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + PostListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/Post" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + Comment: + type: object + properties: + attributes: + type: object + properties: + id: + type: integer + postId: + type: integer + content: + type: string + required: + - id + - postId + - content + relationships: + type: object + properties: + post: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + CommentCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + content: + type: string + required: + - content + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + CommentUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + id: + type: integer + content: + type: string + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + CommentResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/Comment" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + CommentListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/Comment" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + Setting: + type: object + properties: + attributes: + type: object + properties: + id: + type: integer + boost: + type: integer + postId: + type: integer + required: + - id + - boost + - postId + relationships: + type: object + properties: + post: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + SettingCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + boost: + type: integer + required: + - boost + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + SettingUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + id: + type: integer + boost: + type: integer + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + SettingResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/Setting" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + SettingListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/Setting" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + PostLike: + type: object + properties: + attributes: + type: object + properties: + postId: + type: integer + userId: + type: string + superLike: + type: boolean + required: + - postId + - userId + - superLike + relationships: + type: object + properties: + post: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + user: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + likeInfos: + $ref: "#/components/schemas/_toManyRelationshipWithLinks" + PostLikeCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + superLike: + type: boolean + required: + - superLike + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + user: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + likeInfos: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + PostLikeUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + superLike: + type: boolean + relationships: + type: object + properties: + post: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + user: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + likeInfos: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + PostLikeResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/PostLike" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + PostLikeListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/PostLike" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + PostLikeInfo: + type: object + properties: + attributes: + type: object + properties: + id: + type: integer + text: + type: string + postId: + type: integer + userId: + type: string + required: + - id + - text + - postId + - userId + relationships: + type: object + properties: + postLike: + $ref: "#/components/schemas/_toOneRelationshipWithLinks" + PostLikeInfoCreateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + attributes: + type: object + properties: + text: + type: string + required: + - text + relationships: + type: object + properties: + postLike: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + required: + - data + PostLikeInfoUpdateRequest: + type: object + properties: + data: + type: object + properties: + type: + type: string + id: + type: string + attributes: + type: object + properties: + id: + type: integer + text: + type: string + relationships: + type: object + properties: + postLike: + type: object + properties: + data: + $ref: "#/components/schemas/_resourceIdentifier" + required: + - type + - id + required: + - data + PostLikeInfoResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + allOf: + - $ref: "#/components/schemas/PostLikeInfo" + - $ref: "#/components/schemas/_resource" + meta: + $ref: "#/components/schemas/_meta" + PostLikeInfoListResponse: + type: object + properties: + jsonapi: + $ref: "#/components/schemas/_jsonapi" + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/PostLikeInfo" + - $ref: "#/components/schemas/_resource" + links: + allOf: + - $ref: "#/components/schemas/_pagination" + - $ref: "#/components/schemas/_links" + meta: + $ref: "#/components/schemas/_meta" + parameters: + id: + name: id + in: path + required: true + schema: + type: string + description: Resource ID + include: + name: include + in: query + schema: + type: string + description: Comma-separated list of relationships to include + sort: + name: sort + in: query + schema: + type: string + description: Comma-separated list of fields to sort by. Prefix with - for descending + pageOffset: + name: page[offset] + in: query + schema: + type: integer + minimum: 0 + description: Page offset + pageLimit: + name: page[limit] + in: query + schema: + type: integer + minimum: 1 + description: Page limit diff --git a/packages/server/test/openapi/rest-openapi.test.ts b/packages/server/test/openapi/rest-openapi.test.ts new file mode 100644 index 000000000..4f16c3556 --- /dev/null +++ b/packages/server/test/openapi/rest-openapi.test.ts @@ -0,0 +1,876 @@ +import { createTestClient } from '@zenstackhq/testtools'; +import fs from 'fs'; +import path from 'path'; +import { beforeAll, describe, expect, it } from 'vitest'; +import YAML from 'yaml'; +import { validate } from '@readme/openapi-parser'; +import { RestApiHandler } from '../../src/api/rest'; + +const UPDATE_BASELINE = process.env.UPDATE_BASELINE === '1'; + +function loadBaseline(name: string) { + return YAML.parse(fs.readFileSync(path.join(__dirname, 'baseline', name), 'utf-8'), { maxAliasCount: 10000 }); +} + +function saveBaseline(name: string, spec: any) { + fs.writeFileSync(path.join(__dirname, 'baseline', name), YAML.stringify(spec, { lineWidth: 0, indent: 4, aliasDuplicateObjects: false })); +} + +const schema = ` +type Address { + city String +} + +model User { + myId String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + email String @unique @email + posts Post[] + likes PostLike[] + profile Profile? + address Address? @json + someJson Json? +} + +model Profile { + id Int @id @default(autoincrement()) + gender String + user User @relation(fields: [userId], references: [myId]) + userId String @unique +} + +model Post { + id Int @id @default(autoincrement()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + title String @length(1, 10) + author User? @relation(fields: [authorId], references: [myId]) + authorId String? + published Boolean @default(false) + publishedAt DateTime? + viewCount Int @default(0) + comments Comment[] + likes PostLike[] + setting Setting? +} + +model Comment { + id Int @id @default(autoincrement()) + post Post @relation(fields: [postId], references: [id]) + postId Int + content String +} + +model Setting { + id Int @id @default(autoincrement()) + boost Int + post Post @relation(fields: [postId], references: [id]) + postId Int @unique +} + +model PostLike { + postId Int + userId String + superLike Boolean + post Post @relation(fields: [postId], references: [id]) + user User @relation(fields: [userId], references: [myId]) + likeInfos PostLikeInfo[] + @@id([postId, userId]) +} + +model PostLikeInfo { + id Int @id @default(autoincrement()) + text String + postId Int + userId String + postLike PostLike @relation(fields: [postId, userId], references: [postId, userId]) +} +`; + +describe('REST OpenAPI spec generation', () => { + let handler: RestApiHandler; + let spec: any; + + beforeAll(async () => { + const client = await createTestClient(schema); + handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + spec = await handler.generateSpec(); + }); + + it('document structure is valid', () => { + expect(spec.openapi).toBe('3.1.0'); + expect(spec.info).toBeDefined(); + expect(spec.info.title).toBe('ZenStack Generated API'); + expect(spec.info.version).toBe('1.0.0'); + expect(spec.paths).toBeDefined(); + expect(spec.components).toBeDefined(); + expect(spec.components.schemas).toBeDefined(); + }); + + it('model paths exist', () => { + expect(spec.paths['/user']).toBeDefined(); + expect(spec.paths['/user/{id}']).toBeDefined(); + expect(spec.paths['/post']).toBeDefined(); + expect(spec.paths['/post/{id}']).toBeDefined(); + expect(spec.paths['/comment']).toBeDefined(); + expect(spec.paths['/comment/{id}']).toBeDefined(); + }); + + it('HTTP methods on collection path', () => { + expect(spec.paths['/user'].get).toBeDefined(); + expect(spec.paths['/user'].post).toBeDefined(); + }); + + it('HTTP methods on single resource path', () => { + expect(spec.paths['/user/{id}'].get).toBeDefined(); + expect(spec.paths['/user/{id}'].patch).toBeDefined(); + expect(spec.paths['/user/{id}'].delete).toBeDefined(); + }); + + it('relation paths exist', () => { + expect(spec.paths['/user/{id}/posts']).toBeDefined(); + expect(spec.paths['/user/{id}/relationships/posts']).toBeDefined(); + expect(spec.paths['/post/{id}/comments']).toBeDefined(); + }); + + it('fetch related path has response schema', () => { + // Collection relation: should reference ListResponse + const collectionPath = spec.paths['/user/{id}/posts'] as any; + const collectionSchema = collectionPath.get.responses['200'].content['application/vnd.api+json'].schema; + expect(collectionSchema.$ref).toBe('#/components/schemas/PostListResponse'); + + // Singular relation: should reference Response + const singularPath = spec.paths['/post/{id}/setting'] as any; + const singularSchema = singularPath.get.responses['200'].content['application/vnd.api+json'].schema; + expect(singularSchema.$ref).toBe('#/components/schemas/SettingResponse'); + }); + + it('relationship path has correct methods', () => { + const relPath = spec.paths['/user/{id}/relationships/posts']; + expect(relPath.get).toBeDefined(); + expect(relPath.put).toBeDefined(); + expect(relPath.patch).toBeDefined(); + // posts is a collection, so should have POST + expect(relPath.post).toBeDefined(); + }); + + it('model schemas exist', () => { + expect(spec.components.schemas['User']).toBeDefined(); + expect(spec.components.schemas['UserCreateRequest']).toBeDefined(); + expect(spec.components.schemas['UserUpdateRequest']).toBeDefined(); + expect(spec.components.schemas['UserResponse']).toBeDefined(); + expect(spec.components.schemas['UserListResponse']).toBeDefined(); + expect(spec.components.schemas['Post']).toBeDefined(); + expect(spec.components.schemas['PostCreateRequest']).toBeDefined(); + }); + + it('field types in schemas', () => { + const userSchema = spec.components.schemas['User']; + const userAttrs = userSchema.properties.attributes.properties; + expect(userAttrs).toBeDefined(); + // email -> string + expect(userAttrs['email']).toMatchObject({ type: 'string' }); + // myId -> string + expect(userAttrs['myId']).toMatchObject({ type: 'string' }); + + const postSchema = spec.components.schemas['Post']; + const postAttrs = postSchema.properties.attributes.properties; + expect(postAttrs).toBeDefined(); + // viewCount -> integer + expect(postAttrs['viewCount']).toMatchObject({ type: 'integer' }); + // published -> boolean + expect(postAttrs['published']).toMatchObject({ type: 'boolean' }); + // createdAt -> date-time + expect(postAttrs['createdAt']).toMatchObject({ type: 'string', format: 'date-time' }); + }); + + it('required fields marked in create schema', () => { + const createReq = spec.components.schemas['CommentCreateRequest']; + expect(createReq).toBeDefined(); + const dataProps = createReq.properties?.data?.properties; + expect(dataProps).toBeDefined(); + // content is required, non-optional non-default + const attrRequired = createReq.properties?.data?.properties?.attributes?.required ?? []; + expect(attrRequired).toContain('content'); + }); + + it('shared component schemas exist', () => { + expect(spec.components.schemas['_jsonapi']).toBeDefined(); + expect(spec.components.schemas['_errors']).toBeDefined(); + expect(spec.components.schemas['_errorResponse']).toBeDefined(); + expect(spec.components.schemas['_resourceIdentifier']).toBeDefined(); + expect(spec.components.schemas['_toOneRelationship']).toBeDefined(); + expect(spec.components.schemas['_toManyRelationship']).toBeDefined(); + }); + + it('shared parameters exist', () => { + expect(spec.components.parameters['id']).toBeDefined(); + expect(spec.components.parameters['include']).toBeDefined(); + expect(spec.components.parameters['sort']).toBeDefined(); + expect(spec.components.parameters['pageOffset']).toBeDefined(); + expect(spec.components.parameters['pageLimit']).toBeDefined(); + }); + + it('filter parameters appear on list operations', () => { + const listOp = spec.paths['/post'].get; + expect(listOp).toBeDefined(); + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + expect(paramNames).toContain('filter[viewCount]'); + expect(paramNames).toContain('filter[published]'); + expect(paramNames).toContain('filter[title]'); + // String ops + expect(paramNames).toContain('filter[title][$contains]'); + // Numeric ops + expect(paramNames).toContain('filter[viewCount][$lt]'); + expect(paramNames).toContain('filter[viewCount][$gt]'); + }); + + it('modelNameMapping is reflected in paths', async () => { + const client = await createTestClient(schema); + const mappedHandler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + modelNameMapping: { User: 'users', Post: 'posts' }, + }); + const mappedSpec = await mappedHandler.generateSpec(); + expect(mappedSpec.paths?.['/users']).toBeDefined(); + expect(mappedSpec.paths?.['/posts']).toBeDefined(); + // Original paths should not exist + expect(mappedSpec.paths?.['/user']).toBeUndefined(); + expect(mappedSpec.paths?.['/post']).toBeUndefined(); + }); + + it('compound ID model paths exist', () => { + // PostLike has @@id([postId, userId]) + expect(spec.paths['/postLike']).toBeDefined(); + expect(spec.paths['/postLike/{id}']).toBeDefined(); + }); + + it('custom openApiOptions are reflected in info', async () => { + const client = await createTestClient(schema); + const customHandler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const customSpec = await customHandler.generateSpec({ + title: 'My Custom API', + version: '2.0.0', + description: 'A custom description', + }); + expect(customSpec.info.title).toBe('My Custom API'); + expect(customSpec.info.version).toBe('2.0.0'); + expect((customSpec.info as any).description).toBe('A custom description'); + }); +}); + +describe('REST OpenAPI spec generation - queryOptions', () => { + it('omit excludes fields from read schema', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { omit: { User: { email: true } } }, + }); + const s = await handler.generateSpec(); + const userSchema = s.components?.schemas?.['User'] as any; + const userAttrs = userSchema.properties.attributes.properties; + expect(userAttrs['myId']).toBeDefined(); + expect(userAttrs['email']).toBeUndefined(); + }); + + it('slicing excludedModels removes model from spec', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { slicing: { excludedModels: ['Post'] as any } }, + }); + const s = await handler.generateSpec(); + expect(s.paths?.['/user']).toBeDefined(); + expect(s.paths?.['/post']).toBeUndefined(); + expect(s.components?.schemas?.['Post']).toBeUndefined(); + + // Relation paths to excluded model should not exist + expect(s.paths?.['/user/{id}/posts']).toBeUndefined(); + expect(s.paths?.['/user/{id}/relationships/posts']).toBeUndefined(); + + // Relation fields to excluded model should not appear in read schema + const userSchema = s.components?.schemas?.['User'] as any; + const userRels = userSchema.properties.relationships?.properties ?? {}; + expect(userRels['posts']).toBeUndefined(); + const userAttrs = userSchema.properties.attributes.properties; + expect(userAttrs['email']).toBeDefined(); + }); + + it('slicing includedModels limits models in spec', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { slicing: { includedModels: ['User'] as any } }, + }); + const s = await handler.generateSpec(); + expect(s.paths?.['/user']).toBeDefined(); + expect(s.paths?.['/post']).toBeUndefined(); + }); + + it('slicing excludedOperations removes HTTP methods from paths', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { excludedOperations: ['create', 'delete'] }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + + // Collection path: GET (findMany) should exist, POST (create) should not + expect((s.paths as any)['/post'].get).toBeDefined(); + expect((s.paths as any)['/post'].post).toBeUndefined(); + + // Single path: GET (findUnique) and PATCH (update) should exist, DELETE should not + expect((s.paths as any)['/post/{id}'].get).toBeDefined(); + expect((s.paths as any)['/post/{id}'].patch).toBeDefined(); + expect((s.paths as any)['/post/{id}'].delete).toBeUndefined(); + }); + + it('slicing excludedOperations on all CRUD ops removes paths entirely', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { excludedOperations: ['findMany', 'create', 'findUnique', 'update', 'delete'] }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + + // Both collection and single paths should be absent (empty path objects are not emitted) + expect(s.paths?.['/post']).toBeUndefined(); + expect(s.paths?.['/post/{id}']).toBeUndefined(); + }); + + it('slicing includedOperations limits HTTP methods in paths', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { includedOperations: ['findMany', 'findUnique'] }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + + // Collection: only GET + expect((s.paths as any)['/post'].get).toBeDefined(); + expect((s.paths as any)['/post'].post).toBeUndefined(); + + // Single: only GET + expect((s.paths as any)['/post/{id}'].get).toBeDefined(); + expect((s.paths as any)['/post/{id}'].patch).toBeUndefined(); + expect((s.paths as any)['/post/{id}'].delete).toBeUndefined(); + }); + + it('slicing $all excludedOperations applies to all models', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + $all: { excludedOperations: ['delete'] }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + + // DELETE should be absent on all models + expect((s.paths as any)['/user/{id}'].delete).toBeUndefined(); + expect((s.paths as any)['/post/{id}'].delete).toBeUndefined(); + expect((s.paths as any)['/comment/{id}'].delete).toBeUndefined(); + + // Other methods should still exist + expect((s.paths as any)['/user/{id}'].get).toBeDefined(); + expect((s.paths as any)['/user/{id}'].patch).toBeDefined(); + }); + + it('slicing excludedFilterKinds removes filter params for a field', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { + fields: { + title: { excludedFilterKinds: ['Like'] }, + viewCount: { excludedFilterKinds: ['Range'] }, + }, + }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + const listOp = (s.paths as any)['/post'].get; + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + + // Equality filters should still exist + expect(paramNames).toContain('filter[title]'); + expect(paramNames).toContain('filter[viewCount]'); + + // Like filters for title should be excluded + expect(paramNames).not.toContain('filter[title][$contains]'); + expect(paramNames).not.toContain('filter[title][$startsWith]'); + + // Range filters for viewCount should be excluded + expect(paramNames).not.toContain('filter[viewCount][$lt]'); + expect(paramNames).not.toContain('filter[viewCount][$gt]'); + }); + + it('slicing includedFilterKinds limits filter params for a field', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { + fields: { + title: { includedFilterKinds: ['Equality'] }, + }, + }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + const listOp = (s.paths as any)['/post'].get; + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + + // Equality filter should exist + expect(paramNames).toContain('filter[title]'); + + // Like filters should be excluded (not in includedFilterKinds) + expect(paramNames).not.toContain('filter[title][$contains]'); + expect(paramNames).not.toContain('filter[title][$startsWith]'); + }); + + it('slicing $all field applies filter kind restriction to all fields', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { + fields: { + $all: { includedFilterKinds: ['Equality'] }, + }, + }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + const listOp = (s.paths as any)['/post'].get; + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + + // Equality filters should exist + expect(paramNames).toContain('filter[title]'); + expect(paramNames).toContain('filter[viewCount]'); + + // Like and Range filters should be excluded + expect(paramNames).not.toContain('filter[title][$contains]'); + expect(paramNames).not.toContain('filter[viewCount][$lt]'); + }); + + it('slicing field-specific overrides $all for filter kinds', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { + fields: { + $all: { includedFilterKinds: ['Equality'] }, + title: { includedFilterKinds: ['Equality', 'Like'] }, + }, + }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + const listOp = (s.paths as any)['/post'].get; + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + + // title should have both Equality and Like + expect(paramNames).toContain('filter[title]'); + expect(paramNames).toContain('filter[title][$contains]'); + + // viewCount should only have Equality (from $all) + expect(paramNames).toContain('filter[viewCount]'); + expect(paramNames).not.toContain('filter[viewCount][$lt]'); + }); + + it('slicing excludedFilterKinds on Equality removes basic filter param', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + queryOptions: { + slicing: { + models: { + post: { + fields: { + title: { excludedFilterKinds: ['Equality'] }, + }, + }, + }, + } as any, + }, + }); + const s = await handler.generateSpec(); + const listOp = (s.paths as any)['/post'].get; + const paramNames = listOp.parameters.map((p: any) => ('name' in p ? p.name : p.$ref)); + + // Basic equality filter should be excluded + expect(paramNames).not.toContain('filter[title]'); + + // Like filters should still exist + expect(paramNames).toContain('filter[title][$contains]'); + }); +}); + +describe('REST OpenAPI spec generation - @meta description', () => { + const metaSchema = ` +model User { + id String @id @default(cuid()) + email String @unique @meta("description", "The user's email address") + @@meta("description", "A user of the system") +} + +model Post { + id Int @id @default(autoincrement()) + title String +} +`; + + it('model @@meta description is used as schema description', async () => { + const client = await createTestClient(metaSchema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await handler.generateSpec(); + + const userSchema = s.components?.schemas?.['User'] as any; + expect(userSchema.description).toBe('A user of the system'); + + // Post has no @@meta description + const postSchema = s.components?.schemas?.['Post'] as any; + expect(postSchema.description).toBeUndefined(); + }); + + it('field @meta description is used as field schema description', async () => { + const client = await createTestClient(metaSchema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await handler.generateSpec(); + + const userSchema = s.components?.schemas?.['User'] as any; + const userAttrs = userSchema.properties.attributes.properties; + expect(userAttrs['email'].description).toBe("The user's email address"); + + // id has no @meta description + expect(userAttrs['id'].description).toBeUndefined(); + }); +}); + +describe('REST OpenAPI spec generation - baseline', () => { + it('matches baseline', async () => { + const client = await createTestClient(schema); + const handler = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const spec = await handler.generateSpec(); + const baselineFile = 'rest.baseline.yaml'; + + if (UPDATE_BASELINE) { + saveBaseline(baselineFile, spec); + return; + } + + const baseline = loadBaseline(baselineFile); + expect(spec).toEqual(baseline); + + await validate(spec); + }); +}); + +describe('REST OpenAPI spec generation - with enum schema', () => { + it('enum schemas exist in components', async () => { + const enumSchema = ` +model Post { + id Int @id @default(autoincrement()) + title String + status PostStatus @default(DRAFT) +} + +enum PostStatus { + DRAFT + PUBLISHED + ARCHIVED +} +`; + const client = await createTestClient(enumSchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec(); + expect(s.components?.schemas?.['PostStatus']).toBeDefined(); + expect((s.components?.schemas?.['PostStatus'] as any).type).toBe('string'); + expect((s.components?.schemas?.['PostStatus'] as any).enum).toContain('DRAFT'); + expect((s.components?.schemas?.['PostStatus'] as any).enum).toContain('PUBLISHED'); + }); + + describe('respectAccessPolicies', () => { + it('no 403 when respectAccessPolicies is off', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('read', true) + @@allow('create', value > 0) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec(); + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeUndefined(); + }); + + it('adds 403 for operations with non-constant-allow policies', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('read', true) + @@allow('create', value > 0) + @@allow('update', value > 0) + @@allow('delete', value > 0) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // create has a non-constant condition → 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeDefined(); + // update has a non-constant condition → 403 + expect(s.paths?.['/item/{id}']?.patch?.responses?.['403']).toBeDefined(); + // delete has a non-constant condition → 403 + expect(s.paths?.['/item/{id}']?.delete?.responses?.['403']).toBeDefined(); + }); + + it('no 403 for constant-allow operations', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('all', true) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // all operations are constant-allow → no 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeUndefined(); + expect(s.paths?.['/item/{id}']?.patch?.responses?.['403']).toBeUndefined(); + expect(s.paths?.['/item/{id}']?.delete?.responses?.['403']).toBeUndefined(); + }); + + it('403 when deny rule exists even with constant allow', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('create', true) + @@deny('create', value < 0) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // deny rule overrides → 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeDefined(); + }); + + it('no 403 when deny condition is literal false', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('create', true) + @@deny('create', false) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // @@deny('create', false) is a no-op → no 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeUndefined(); + }); + + it('403 when no policy rules at all (default-deny)', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // no rules = default deny → 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeDefined(); + expect(s.paths?.['/item/{id}']?.patch?.responses?.['403']).toBeDefined(); + expect(s.paths?.['/item/{id}']?.delete?.responses?.['403']).toBeDefined(); + }); + + it('per-operation granularity: only non-constant ops get 403', async () => { + const policySchema = ` +model Item { + id Int @id @default(autoincrement()) + value Int + + @@allow('create,read', true) + @@allow('update,delete', value > 0) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + // create is constant-allow → no 403 + expect(s.paths?.['/item']?.post?.responses?.['403']).toBeUndefined(); + // update/delete are non-constant → 403 + expect(s.paths?.['/item/{id}']?.patch?.responses?.['403']).toBeDefined(); + expect(s.paths?.['/item/{id}']?.delete?.responses?.['403']).toBeDefined(); + }); + + it('relationship mutations get 403 when update may be denied', async () => { + const policySchema = ` +model Parent { + id Int @id @default(autoincrement()) + children Child[] + + @@allow('read', true) + @@allow('update', false) +} + +model Child { + id Int @id @default(autoincrement()) + parent Parent @relation(fields: [parentId], references: [id]) + parentId Int + + @@allow('all', true) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + const relPath = s.paths?.['/parent/{id}/relationships/children'] as any; + expect(relPath.put.responses['403']).toBeDefined(); + expect(relPath.patch.responses['403']).toBeDefined(); + expect(relPath.post.responses['403']).toBeDefined(); + // GET should not have 403 + expect(relPath.get.responses['403']).toBeUndefined(); + }); + + it('relationship mutations have no 403 when update is constant-allow', async () => { + const policySchema = ` +model Parent { + id Int @id @default(autoincrement()) + children Child[] + + @@allow('all', true) +} + +model Child { + id Int @id @default(autoincrement()) + parent Parent @relation(fields: [parentId], references: [id]) + parentId Int + + @@allow('all', true) +} +`; + const client = await createTestClient(policySchema); + const h = new RestApiHandler({ + schema: client.$schema, + endpoint: 'http://localhost/api', + }); + const s = await h.generateSpec({ respectAccessPolicies: true }); + const relPath = s.paths?.['/parent/{id}/relationships/children'] as any; + expect(relPath.put.responses['403']).toBeUndefined(); + expect(relPath.patch.responses['403']).toBeUndefined(); + expect(relPath.post.responses['403']).toBeUndefined(); + }); + }); +}); diff --git a/packages/testtools/README.md b/packages/testtools/README.md new file mode 100644 index 000000000..e07595f27 --- /dev/null +++ b/packages/testtools/README.md @@ -0,0 +1,3 @@ +# @zenstackhq/testtools + +Testing utilities for ZenStack development. diff --git a/packages/testtools/package.json b/packages/testtools/package.json index db5387253..665644014 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Test Tools", "type": "module", "scripts": { diff --git a/packages/zod/README.md b/packages/zod/README.md new file mode 100644 index 000000000..7a7cf70e4 --- /dev/null +++ b/packages/zod/README.md @@ -0,0 +1,9 @@ +# @zenstackhq/zod + +[Zod](https://zod.dev/) schema integration for ZenStack. Generates validation schemas that validate objects based on models and types defined in ZModel. + +## Installation + +```bash +npm install @zenstackhq/zod +``` diff --git a/packages/zod/package.json b/packages/zod/package.json index 8b9cf703b..40ce2e9d3 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/zod", - "version": "3.4.6", + "version": "3.5.0", "description": "ZenStack Zod integration", "type": "module", "scripts": { diff --git a/packages/zod/src/factory.ts b/packages/zod/src/factory.ts index dece3e27e..62620c114 100644 --- a/packages/zod/src/factory.ts +++ b/packages/zod/src/factory.ts @@ -15,8 +15,10 @@ import { SchemaFactoryError } from './error'; import type { GetModelCreateFieldsShape, GetModelFieldsShape, + GetModelSchemaShapeWithOptions, GetModelUpdateFieldsShape, GetTypeDefFieldsShape, + ModelSchemaOptions, } from './types'; import { addBigIntValidation, @@ -30,6 +32,44 @@ export function createSchemaFactory(schema: Schema) { return new SchemaFactory(schema); } +/** Internal untyped representation of the options object used at runtime. */ +type RawOptions = { + select?: Record; + include?: Record; + omit?: Record; +}; + +/** + * Recursive Zod schema that validates a `RawOptions` object at runtime, + * enforcing the same mutual-exclusion rules that the TypeScript union type + * enforces at compile time: + * - `select` and `include` cannot be used together. + * - `select` and `omit` cannot be used together. + * Nested relation options are validated with the same rules. + */ +const rawOptionsSchema: z.ZodType = z.lazy(() => + z + .object({ + select: z.record(z.string(), z.union([z.boolean(), rawOptionsSchema])).optional(), + include: z.record(z.string(), z.union([z.boolean(), rawOptionsSchema])).optional(), + omit: z.record(z.string(), z.boolean()).optional(), + }) + .superRefine((val, ctx) => { + if (val.select && val.include) { + ctx.addIssue({ + code: 'custom', + message: '`select` and `include` cannot be used together', + }); + } + if (val.select && val.omit) { + ctx.addIssue({ + code: 'custom', + message: '`select` and `omit` cannot be used together', + }); + } + }), +); + class SchemaFactory { private readonly schema: SchemaAccessor; @@ -39,29 +79,64 @@ class SchemaFactory { makeModelSchema>( model: Model, - ): z.ZodObject, z.core.$strict> { + ): z.ZodObject, z.core.$strict>; + + makeModelSchema, Options extends ModelSchemaOptions>( + model: Model, + options: Options, + ): z.ZodObject, z.core.$strict>; + + makeModelSchema, Options extends ModelSchemaOptions>( + model: Model, + options?: Options, + ): z.ZodObject, z.core.$strict> { const modelDef = this.schema.requireModel(model); - const fields: Record = {}; - for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { - if (fieldDef.relation) { - const relatedModelName = fieldDef.type; - const lazySchema: z.ZodType = z.lazy(() => this.makeModelSchema(relatedModelName as GetModels)); - // relation fields are always optional - fields[fieldName] = this.applyDescription( - this.applyCardinality(lazySchema, fieldDef).optional(), - fieldDef.attributes, - ); - } else { - fields[fieldName] = this.applyDescription(this.makeScalarFieldSchema(fieldDef), fieldDef.attributes); + if (!options) { + // ── No-options path (original behaviour) ───────────────────────── + const fields: Record = {}; + + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.relation) { + const relatedModelName = fieldDef.type; + const lazySchema: z.ZodType = z.lazy(() => + this.makeModelSchema(relatedModelName as GetModels), + ); + // relation fields are always optional + fields[fieldName] = this.applyDescription( + this.applyCardinality(lazySchema, fieldDef).optional(), + fieldDef.attributes, + ); + } else { + fields[fieldName] = this.applyDescription( + this.makeScalarFieldSchema(fieldDef), + fieldDef.attributes, + ); + } } + + const shape = z.strictObject(fields); + return this.applyDescription( + addCustomValidation(shape, modelDef.attributes), + modelDef.attributes, + ) as unknown as z.ZodObject, z.core.$strict>; } + // ── Options path ───────────────────────────────────────────────────── + const rawOptions = rawOptionsSchema.parse(options); + const fields = this.buildFieldsWithOptions(model as string, rawOptions); const shape = z.strictObject(fields); - return this.applyDescription( - addCustomValidation(shape, modelDef.attributes), - modelDef.attributes, - ) as unknown as z.ZodObject, z.core.$strict>; + // @@validate conditions only reference scalar fields of the same model + // (the ZModel compiler rejects relation fields). When `select` or `omit` + // produces a partial shape some of those scalar fields may be absent; + // we skip any rule that references a missing field so it can't produce + // a false negative against a partial payload. + const presentFields = this.buildPresentFields(model as string, rawOptions); + const withValidation = addCustomValidation(shape, modelDef.attributes, presentFields); + return this.applyDescription(withValidation, modelDef.attributes) as unknown as z.ZodObject< + GetModelSchemaShapeWithOptions, + z.core.$strict + >; } makeModelCreateSchema>( @@ -114,6 +189,149 @@ class SchemaFactory { ) as unknown as z.ZodObject, z.core.$strict>; } + // ------------------------------------------------------------------------- + // Options-aware field building + // ------------------------------------------------------------------------- + + /** + * Internal loose options shape used at runtime (we've already validated the + * type-level constraints via the overload signatures). + */ + private buildFieldsWithOptions(model: string, options: RawOptions): Record { + const { select, include, omit } = options; + const modelDef = this.schema.requireModel(model); + const fields: Record = {}; + + if (select) { + // ── select branch ──────────────────────────────────────────────── + // Only include fields that are explicitly listed with a truthy value. + for (const [key, value] of Object.entries(select)) { + if (!value) continue; // false → skip + + const fieldDef = modelDef.fields[key]; + if (!fieldDef) { + throw new SchemaFactoryError(`Field "${key}" does not exist on model "${model}"`); + } + + if (fieldDef.relation) { + const subOptions = typeof value === 'object' ? (value as RawOptions) : undefined; + const relSchema = this.makeRelationFieldSchema(fieldDef, subOptions); + fields[key] = this.applyDescription( + this.applyCardinality(relSchema, fieldDef).optional(), + fieldDef.attributes, + ); + } else { + if (typeof value === 'object') { + throw new SchemaFactoryError( + `Field "${key}" on model "${model}" is a scalar field and cannot have nested options`, + ); + } + fields[key] = this.applyDescription(this.makeScalarFieldSchema(fieldDef), fieldDef.attributes); + } + } + } else { + // ── include + omit branch ──────────────────────────────────────── + // Validate omit keys up-front. + if (omit) { + for (const key of Object.keys(omit)) { + const fieldDef = modelDef.fields[key]; + if (!fieldDef) { + throw new SchemaFactoryError(`Field "${key}" does not exist on model "${model}"`); + } + if (fieldDef.relation) { + throw new SchemaFactoryError( + `Field "${key}" on model "${model}" is a relation field and cannot be used in "omit"`, + ); + } + } + } + + // Start with all scalar fields, applying omit exclusions. + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.relation) continue; + + if (omit?.[fieldName] === true) continue; + fields[fieldName] = this.applyDescription(this.makeScalarFieldSchema(fieldDef), fieldDef.attributes); + } + + // Validate include keys and add relation fields. + if (include) { + for (const [key, value] of Object.entries(include)) { + if (!value) continue; // false → skip + + const fieldDef = modelDef.fields[key]; + if (!fieldDef) { + throw new SchemaFactoryError(`Field "${key}" does not exist on model "${model}"`); + } + if (!fieldDef.relation) { + throw new SchemaFactoryError( + `Field "${key}" on model "${model}" is not a relation field and cannot be used in "include"`, + ); + } + + const subOptions = typeof value === 'object' ? (value as RawOptions) : undefined; + const relSchema = this.makeRelationFieldSchema(fieldDef, subOptions); + fields[key] = this.applyDescription( + this.applyCardinality(relSchema, fieldDef).optional(), + fieldDef.attributes, + ); + } + } + } + + return fields; + } + + /** + * Returns the set of scalar field names that will be present in the + * resulting schema after applying `options`. Used by `addCustomValidation` + * to skip `@@validate` rules that reference an absent field. + * + * Only scalar fields matter here because `@@validate` conditions are + * restricted by the ZModel compiler to scalar fields of the same model. + */ + private buildPresentFields(model: string, options: RawOptions): ReadonlySet { + const { select, omit } = options; + const modelDef = this.schema.requireModel(model); + const fields = new Set(); + + if (select) { + // Only scalar fields explicitly selected with a truthy value. + for (const [key, value] of Object.entries(select)) { + if (!value) continue; + const fieldDef = modelDef.fields[key]; + if (fieldDef && !fieldDef.relation) { + fields.add(key); + } + } + } else { + // All scalar fields minus explicitly omitted ones. + for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) { + if (fieldDef.relation) continue; + if (omit?.[fieldName] === true) continue; + fields.add(fieldName); + } + } + + return fields; + } + + /** + * Build the inner Zod schema for a relation field, optionally with nested + * query options. Does NOT apply cardinality/optional wrappers — the caller + * does that. + */ + private makeRelationFieldSchema(fieldDef: FieldDef, subOptions?: RawOptions): z.ZodType { + const relatedModelName = fieldDef.type as GetModels; + if (subOptions) { + // Recurse: build the related model's schema with its own options. + return this.makeModelSchema(relatedModelName, subOptions as ModelSchemaOptions>); + } + // No sub-options: use a lazy reference to the default schema so that + // circular models don't cause infinite recursion at build time. + return z.lazy(() => this.makeModelSchema(relatedModelName)); + } + private makeScalarFieldSchema(fieldDef: FieldDef): z.ZodType { const { type, attributes } = fieldDef; diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index 55f241ea1..4323894e8 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -1,2 +1,3 @@ export { createSchemaFactory } from './factory'; +export type { ModelSchemaOptions, GetModelSchemaShapeWithOptions } from './types'; export * as ZodUtils from './utils'; diff --git a/packages/zod/src/types.ts b/packages/zod/src/types.ts index b8d1b05b0..2a61531b0 100644 --- a/packages/zod/src/types.ts +++ b/packages/zod/src/types.ts @@ -14,6 +14,7 @@ import type { GetTypeDefs, ModelFieldIsOptional, SchemaDef, + TypeDefFieldIsArray, TypeDefFieldIsOptional, } from '@zenstackhq/schema'; import type Decimal from 'decimal.js'; @@ -24,7 +25,7 @@ export type GetModelFieldsShape as FieldIsRelation extends true ? never : Field]: ZodOptionalAndNullableIf< - MapModelFieldToZod, + ZodArrayIf, FieldIsArray>, ModelFieldIsOptional >; } & { @@ -58,7 +59,10 @@ export type GetModelCreateFieldsShape extends true ? never : Field]: ZodOptionalIf< - ZodOptionalAndNullableIf, ModelFieldIsOptional>, + ZodOptionalAndNullableIf< + ZodArrayIf, FieldIsArray>, + ModelFieldIsOptional + >, FieldHasDefault >; }; @@ -71,13 +75,16 @@ export type GetModelUpdateFieldsShape extends true ? never : Field]: z.ZodOptional< - ZodOptionalAndNullableIf, ModelFieldIsOptional> + ZodOptionalAndNullableIf< + ZodArrayIf, FieldIsArray>, + ModelFieldIsOptional + > >; }; export type GetTypeDefFieldsShape> = { [Field in GetTypeDefFields]: ZodOptionalAndNullableIf< - MapTypeDefFieldToZod, + ZodArrayIf, TypeDefFieldIsArray>, TypeDefFieldIsOptional >; }; @@ -135,3 +142,218 @@ type ZodOptionalAndNullableIf = type ZodOptionalIf = Condition extends true ? z.ZodOptional : T; type ZodNullableIf = Condition extends true ? z.ZodNullable : T; type ZodArrayIf = Condition extends true ? z.ZodArray : T; + +// ------------------------------------------------------------------------- +// Query options types (ORM-style include / select / omit) +// ------------------------------------------------------------------------- + +/** + * The non-relation scalar fields of a model (excludes relation fields and + * foreign-key fields that back a relation). + */ +type ScalarModelFields> = { + [Field in GetModelFields as FieldIsRelation extends true + ? never + : Field]: Field; +}; + +/** + * The relation fields of a model. + */ +type RelationModelFields> = { + [Field in GetModelFields as FieldIsRelation extends true + ? Field + : never]: Field; +}; + +/** + * For a relation field, resolve the related model name. + */ +type RelatedModel< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, +> = GetModelFieldType extends GetModels ? GetModelFieldType : never; + +/** + * ORM-style query options accepted by `makeModelSchema`. + * + * Exactly mirrors the `select` / `include` / `omit` vocabulary: + * - `select` — pick specific fields (scalars and/or relations). Mutually + * exclusive with `include` and `omit`. + * - `include` — start with all scalar fields, then add the named relation + * fields. Can be combined with `omit`. + * - `omit` — remove named scalar fields from the default scalar set. + * Can be combined with `include`, mutually exclusive with + * `select`. + */ +export type ModelSchemaOptions> = + | { + /** + * Pick only the listed fields. Values can be `true` (include with + * default shape) or a nested options object (for relation fields). + */ + select: { + [Field in GetModelFields]?: FieldIsRelation extends true + ? boolean | ModelSchemaOptions> + : boolean; + }; + include?: never; + omit?: never; + } + | { + select?: never; + /** + * Add the listed relation fields on top of the scalar fields. + * Values can be `true` / `{}` (default shape) or a nested options + * object. + */ + include?: { + [Field in keyof RelationModelFields]?: Field extends GetModelFields + ? boolean | ModelSchemaOptions> + : never; + }; + /** + * Remove the listed scalar fields from the output. + */ + omit?: { + [Field in keyof ScalarModelFields]?: boolean; + }; + }; + +// ---- Output shape helpers ------------------------------------------------ + +/** + * Narrows `Field` so it can safely index `GetModelFieldsShape`. The mapped + * type uses a `as`-remapping clause, so TypeScript widens the key set and + * `Field extends GetModelFields<…>` alone is not enough for indexing. + */ +type FieldInShape< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, +> = Field & keyof GetModelFieldsShape; + +/** + * Zod shape produced when a relation field is included via `include: { field: + * true }` or `select: { field: true }` — identical to how the existing + * `makeModelSchema` (no-options) represents relation fields: optional, carries + * array-ness and nullability from the field definition. + */ +type RelationFieldZodDefault< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, +> = GetModelFieldsShape[FieldInShape]; + +/** + * Zod shape for a relation field included with nested options. We recurse + * into `GetModelSchemaShapeWithOptions` for the related model, then re-apply + * the same optional/array/nullable wrappers as the default relation field. + */ +type RelationFieldZodWithOptions< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, + Options, +> = + RelatedModel extends GetModels + ? ZodNullableIf< + z.ZodOptional< + ZodArrayIf< + z.ZodObject< + GetModelSchemaShapeWithOptions, Options>, + z.core.$strict + >, + FieldIsArray + > + >, + ModelFieldIsOptional + > + : never; + +/** + * Resolve the Zod type for a single field given a select-entry value (`true` + * or a nested options object). + */ +type SelectEntryToZod< + Schema extends SchemaDef, + Model extends GetModels, + Field extends GetModelFields, + Value, +> = Value extends boolean + ? // `true` or widened `boolean` — use the default shape for this field. + // Handling `boolean` (not just literal `true`) prevents the type from + // collapsing to `never` when callers use a boolean variable instead of + // a literal (e.g. `const pick: boolean = true`). + GetModelFieldsShape[FieldInShape] + : Value extends object + ? // nested options — must be a relation field + RelationFieldZodWithOptions + : never; + +/** + * Build the Zod shape for the `select` branch: only the listed fields, + * recursing into relations when given nested options. + */ +type BuildSelectShape, S extends Record> = { + [Field in keyof S & GetModelFields as S[Field] extends false ? never : Field]: SelectEntryToZod< + Schema, + Model, + Field, + S[Field] + >; +}; + +/** + * Build the Zod shape for the `include` + `omit` branch: + * - All scalar fields, minus any that appear in `omit` with value `true`. + * - Plus the relation fields listed in `include`. + */ +type BuildIncludeOmitShape< + Schema extends SchemaDef, + Model extends GetModels, + I extends Record | undefined, + O extends Record | undefined, +> = + // scalar fields, omitting those explicitly excluded + { + [Field in GetModelFields as FieldIsRelation extends true + ? never + : O extends object + ? Field extends keyof O + ? O[Field] extends true + ? never + : Field + : Field + : Field]: GetModelFieldsShape[FieldInShape]; + } & (I extends object // included relation fields + ? { + [Field in keyof I & GetModelFields as I[Field] extends false + ? never + : Field]: I[Field] extends object + ? RelationFieldZodWithOptions + : RelationFieldZodDefault; + } + : // no include — empty, so the intersection is a no-op + {}); + +/** + * The top-level conditional that maps options → Zod shape. + * + * - No options / undefined → existing `GetModelFieldsShape` (no change). + * - `{ select: S }` → `BuildSelectShape`. + * - `{ include?, omit? }` → `BuildIncludeOmitShape`. + */ +export type GetModelSchemaShapeWithOptions< + Schema extends SchemaDef, + Model extends GetModels, + Options, +> = Options extends { select: infer S extends Record } + ? BuildSelectShape + : Options extends { + include?: infer I extends Record | undefined; + omit?: infer O extends Record | undefined; + } + ? BuildIncludeOmitShape + : GetModelFieldsShape; diff --git a/packages/zod/src/utils.ts b/packages/zod/src/utils.ts index 5874d1664..d5c9cf81a 100644 --- a/packages/zod/src/utils.ts +++ b/packages/zod/src/utils.ts @@ -261,9 +261,59 @@ export function addListValidation( return result; } +/** + * Recursively collects all field names referenced by `kind: 'field'` nodes + * inside an expression tree. + */ +export function collectFieldRefs(expr: Expression): Set { + const refs = new Set(); + function walk(e: Expression): void { + switch (e.kind) { + case 'field': + refs.add(e.field); + break; + case 'unary': + walk(e.operand); + break; + case 'binary': + walk(e.left); + walk(e.right); + break; + case 'call': + e.args?.forEach(walk); + break; + case 'array': + e.items.forEach(walk); + break; + case 'member': + walk(e.receiver); + break; + // literal / null / this / binding — no field refs + } + } + walk(expr); + return refs; +} + +/** + * Applies `@@validate` rules from `attributes` to `schema` as Zod refinements. + * + * When `presentFields` is provided, only rules whose every field reference is + * present in the set are applied. Rules that reference a field absent from the + * set are silently skipped — they cannot be evaluated correctly against a + * partial payload (e.g. when `select` or `omit` has been used). + * + * Omit `presentFields` (or pass `undefined`) to apply all rules + * unconditionally, which is the correct behaviour for full-model schemas. + * + * Note: `@@validate` conditions are restricted by the ZModel compiler to + * scalar fields of the same model only — relation fields are a compile error. + * A flat field-name set is therefore sufficient. + */ export function addCustomValidation( schema: z.ZodSchema, attributes: readonly AttributeApplication[] | undefined, + presentFields?: ReadonlySet, ): z.ZodSchema { const attrs = attributes?.filter((a) => a.name === '@@validate'); if (!attrs || attrs.length === 0) { @@ -276,6 +326,15 @@ export function addCustomValidation( if (!expr) { continue; } + + // Skip rules that reference a field absent from the partial shape. + if (presentFields !== undefined) { + const refs = collectFieldRefs(expr); + if ([...refs].some((ref) => !presentFields.has(ref))) { + continue; + } + } + const message = getArgValue(attr.args?.[1]?.value); const pathExpr = attr.args?.[2]?.value; let path: string[] | undefined = undefined; diff --git a/packages/zod/test/factory.test.ts b/packages/zod/test/factory.test.ts index e8368a385..d9b38ebba 100644 --- a/packages/zod/test/factory.test.ts +++ b/packages/zod/test/factory.test.ts @@ -31,6 +31,7 @@ const validPost = { title: 'My First Post', published: true, authorId: null, + tags: ['announcement', 'update'], }; describe('SchemaFactory - makeModelSchema', () => { @@ -103,6 +104,19 @@ describe('SchemaFactory - makeModelSchema', () => { // optional scalar (foreign key) expectTypeOf().toEqualTypeOf(); + // scalar array + expectTypeOf().toEqualTypeOf(); + + const _createPostSchema = factory.makeModelCreateSchema('Post'); + type PostCreate = z.infer; + + expectTypeOf().toEqualTypeOf(); + + const _updatePostSchema = factory.makeModelUpdateSchema('Post'); + type PostUpdate = z.infer; + + expectTypeOf().toEqualTypeOf(); + // optional relation field present in type expectTypeOf().toHaveProperty('author'); const _userSchema = factory.makeModelSchema('User'); @@ -362,7 +376,7 @@ describe('SchemaFactory - makeModelSchema', () => { const userSchema = factory.makeModelSchema('User'); const result = userSchema.safeParse({ ...validUser, - address: { street: '123 Main St', city: 'Springfield', zip: null }, + address: { residents: [], street: '123 Main St', city: 'Springfield', zip: null }, }); expect(result.success).toBe(true); }); @@ -371,7 +385,7 @@ describe('SchemaFactory - makeModelSchema', () => { const userSchema = factory.makeModelSchema('User'); const result = userSchema.safeParse({ ...validUser, - address: { street: '123 Main St', city: 'Springfield', zip: '12345' }, + address: { residents: [], street: '123 Main St', city: 'Springfield', zip: '12345' }, }); expect(result.success).toBe(true); }); @@ -380,7 +394,7 @@ describe('SchemaFactory - makeModelSchema', () => { const userSchema = factory.makeModelSchema('User'); const result = userSchema.safeParse({ ...validUser, - address: { street: '123 Main St', city: 'Springfield', zip: null, extra: 'field' }, + address: { residents: [], street: '123 Main St', city: 'Springfield', zip: null, extra: 'field' }, }); expect(result.success).toBe(false); }); @@ -389,7 +403,7 @@ describe('SchemaFactory - makeModelSchema', () => { const userSchema = factory.makeModelSchema('User'); const result = userSchema.safeParse({ ...validUser, - address: { street: '123 Main St' }, + address: { residents: [], street: '123 Main St' }, }); expect(result.success).toBe(false); }); @@ -440,18 +454,21 @@ describe('SchemaFactory - makeModelSchema', () => { describe('SchemaFactory - makeTypeSchema', () => { it('generates schema for Address typedef', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: null }).success).toBe(true); + expect( + addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield', zip: null }).success, + ).toBe(true); }); it('rejects Address with missing required field', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main' }); + const result = addressSchema.safeParse({ residents: [], street: '123 Main' }); expect(result.success).toBe(false); }); it('rejects Address with extra fields (strict object)', () => { const addressSchema = factory.makeTypeSchema('Address'); const result = addressSchema.safeParse({ + residents: [], street: '123 Main', city: 'Springfield', zip: null, @@ -462,47 +479,71 @@ describe('SchemaFactory - makeTypeSchema', () => { it('accepts Address with optional zip as null', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: null }).success).toBe(true); + expect( + addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield', zip: null }).success, + ).toBe(true); }); it('accepts Address with optional zip as a string', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '12345' }).success).toBe(true); + expect( + addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield', zip: '12345' }).success, + ).toBe(true); }); describe('extra validations', () => { it('passes when zip is null', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: null }).success).toBe(true); + expect( + addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield', zip: null }).success, + ).toBe(true); }); it('passes when zip is omitted', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield' }).success).toBe(true); + expect(addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield' }).success).toBe( + true, + ); }); it('passes when zip is exactly 5 characters', () => { const addressSchema = factory.makeTypeSchema('Address'); - expect(addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '90210' }).success).toBe( - true, - ); + expect( + addressSchema.safeParse({ residents: [], street: '123 Main', city: 'Springfield', zip: '90210' }) + .success, + ).toBe(true); }); it('fails when zip is fewer than 5 characters', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '123' }); + const result = addressSchema.safeParse({ + residents: [], + street: '123 Main', + city: 'Springfield', + zip: '123', + }); expect(result.success).toBe(false); }); it('fails when zip is more than 5 characters', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '123456' }); + const result = addressSchema.safeParse({ + residents: [], + street: '123 Main', + city: 'Springfield', + zip: '123456', + }); expect(result.success).toBe(false); }); it('error message matches the configured message', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '123' }); + const result = addressSchema.safeParse({ + residents: [], + street: '123 Main', + city: 'Springfield', + zip: '123', + }); expect(result.success).toBe(false); if (!result.success) { expect(result.error.issues.map((i) => i.message)).toContain('Zip code must be exactly 5 characters'); @@ -511,7 +552,12 @@ describe('SchemaFactory - makeTypeSchema', () => { it('error path points to the zip field', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main', city: 'Springfield', zip: '123' }); + const result = addressSchema.safeParse({ + residents: [], + street: '123 Main', + city: 'Springfield', + zip: '123', + }); expect(result.success).toBe(false); if (!result.success) { expect(result.error.issues.map((i) => i.path)).toContainEqual(['zip']); @@ -520,7 +566,7 @@ describe('SchemaFactory - makeTypeSchema', () => { it('fails when city is too short', () => { const addressSchema = factory.makeTypeSchema('Address'); - const result = addressSchema.safeParse({ street: '123 Main', city: '', zip: '12345' }); + const result = addressSchema.safeParse({ residents: [], street: '123 Main', city: '', zip: '12345' }); expect(result.success).toBe(false); }); @@ -541,12 +587,14 @@ describe('SchemaFactory - makeTypeSchema', () => { avatar: null, metadata: null, status: 'ACTIVE', - address: { street: '123 Main', city: 'Springfield', zip: '90210' }, + address: { residents: [], street: '123 Main', city: 'Springfield', zip: '90210' }, }; expect(userSchema.safeParse(validUser).success).toBe(true); expect( - userSchema.safeParse({ ...validUser, address: { street: '123 Main', city: 'Springfield', zip: '123' } }) - .success, + userSchema.safeParse({ + ...validUser, + address: { residents: ['Alice'], street: '123 Main', city: 'Springfield', zip: '123' }, + }).success, ).toBe(false); }); }); @@ -846,3 +894,348 @@ describe('SchemaFactory - delegate models', () => { }); }); }); + +// --------------------------------------------------------------------------- +// makeModelSchema — ORM-style options (omit / include / select) +// --------------------------------------------------------------------------- + +// User without username (the omit use-case baseline) +const validUserNoUsername = (() => { + const { username: _, ...rest } = validUser; + return rest; +})(); + +describe('SchemaFactory - makeModelSchema with options', () => { + // ── omit ──────────────────────────────────────────────────────────────── + describe('omit', () => { + it('excludes the omitted scalar field at runtime', () => { + const schema = factory.makeModelSchema('User', { omit: { username: true } }); + // validUserNoUsername has no username field — should pass + expect(schema.safeParse(validUserNoUsername).success).toBe(true); + }); + + it('rejects when the omitted field is present (strict object)', () => { + const schema = factory.makeModelSchema('User', { omit: { username: true } }); + // passing the full validUser (which has username) must fail because + // the schema is strict and username is no longer a known key + expect(schema.safeParse(validUser).success).toBe(false); + }); + + it('infers omitted field is absent from the output type', () => { + const _schema = factory.makeModelSchema('User', { omit: { username: true } }); + type Result = z.infer; + expectTypeOf().not.toHaveProperty('username'); + }); + + it('keeps all other scalar fields when one is omitted', () => { + const _schema = factory.makeModelSchema('User', { omit: { username: true } }); + type Result = z.infer; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toHaveProperty('email'); + expectTypeOf().toEqualTypeOf(); + }); + + it('omit: {} (empty) keeps all scalar fields', () => { + const schema = factory.makeModelSchema('User', { omit: {} }); + expect(schema.safeParse(validUser).success).toBe(true); + }); + + it('can omit multiple fields', () => { + const schema = factory.makeModelSchema('User', { omit: { username: true, avatar: true } }); + const { username: _u, avatar: _a, ...rest } = validUser; + expect(schema.safeParse(rest).success).toBe(true); + }); + + it('infers multiple omitted fields absent', () => { + const _schema = factory.makeModelSchema('User', { omit: { username: true, avatar: true } }); + type Result = z.infer; + expectTypeOf().not.toHaveProperty('username'); + expectTypeOf().not.toHaveProperty('avatar'); + expectTypeOf().toHaveProperty('email'); + }); + }); + + // ── include ───────────────────────────────────────────────────────────── + describe('include', () => { + it('adds the relation field alongside all scalars', () => { + const schema = factory.makeModelSchema('User', { include: { posts: true } }); + // All scalar fields must still be present + expect(schema.safeParse(validUser).success).toBe(true); + }); + + it('the included relation field is optional', () => { + const schema = factory.makeModelSchema('User', { include: { posts: true } }); + // omitting posts should still pass + expect(schema.safeParse(validUser).success).toBe(true); + }); + + it('infers included relation field in output type', () => { + const _schema = factory.makeModelSchema('User', { include: { posts: true } }); + type Result = z.infer; + expectTypeOf().toHaveProperty('posts'); + const _postSchema = factory.makeModelSchema('Post'); + type Post = z.infer; + expectTypeOf().toEqualTypeOf(); + }); + + it('infers scalar fields still present when using include', () => { + const _schema = factory.makeModelSchema('User', { include: { posts: true } }); + type Result = z.infer; + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf(); + }); + + it('include: false skips the relation', () => { + const schema = factory.makeModelSchema('User', { include: { posts: false } }); + // posts field must not be in the strict schema + expect(schema.safeParse({ ...validUser, posts: [] }).success).toBe(false); + }); + + it('include with nested select on relation', () => { + const schema = factory.makeModelSchema('User', { + include: { posts: { select: { title: true } } }, + }); + // posts with only title should pass + expect(schema.safeParse({ ...validUser, posts: [{ title: 'Hello' }] }).success).toBe(true); + // posts with extra field should fail (strict) + expect(schema.safeParse({ ...validUser, posts: [{ title: 'Hello', published: true }] }).success).toBe( + false, + ); + }); + + it('infers nested select shape on included relation', () => { + const _schema = factory.makeModelSchema('User', { + include: { posts: { select: { title: true } } }, + }); + type Result = z.infer; + type Posts = Exclude; + type Post = Posts extends Array ? P : never; + expectTypeOf().toHaveProperty('title'); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().not.toHaveProperty('id'); + }); + }); + + // ── include + omit ─────────────────────────────────────────────────────── + describe('include + omit', () => { + it('omits the scalar field and adds the relation', () => { + const schema = factory.makeModelSchema('User', { + omit: { username: true }, + include: { posts: true }, + }); + expect(schema.safeParse({ ...validUserNoUsername, posts: [] }).success).toBe(true); + }); + + it('rejects when omitted field is present', () => { + const schema = factory.makeModelSchema('User', { + omit: { username: true }, + include: { posts: true }, + }); + expect(schema.safeParse({ ...validUser, posts: [] }).success).toBe(false); + }); + + it('infers combined shape correctly', () => { + const _schema = factory.makeModelSchema('User', { + omit: { username: true }, + include: { posts: true }, + }); + type Result = z.infer; + expectTypeOf().not.toHaveProperty('username'); + expectTypeOf().toHaveProperty('email'); + expectTypeOf().toHaveProperty('posts'); + }); + }); + + // ── select ─────────────────────────────────────────────────────────────── + describe('select', () => { + it('returns only the selected scalar fields', () => { + const schema = factory.makeModelSchema('User', { select: { id: true, email: true } }); + expect(schema.safeParse({ id: 'u1', email: 'a@b.com' }).success).toBe(true); + }); + + it('rejects when a non-selected field is present (strict)', () => { + const schema = factory.makeModelSchema('User', { select: { id: true, email: true } }); + expect(schema.safeParse({ id: 'u1', email: 'a@b.com', username: 'alice' }).success).toBe(false); + }); + + it('rejects when a selected field is missing', () => { + const schema = factory.makeModelSchema('User', { select: { id: true, email: true } }); + expect(schema.safeParse({ id: 'u1' }).success).toBe(false); + }); + + it('infers only selected fields in output type', () => { + const _schema = factory.makeModelSchema('User', { select: { id: true, email: true } }); + type Result = z.infer; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toHaveProperty('email'); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().not.toHaveProperty('username'); + expectTypeOf().not.toHaveProperty('posts'); + }); + + it('select: false on a field excludes it', () => { + const schema = factory.makeModelSchema('User', { select: { id: true, email: false } }); + expect(schema.safeParse({ id: 'u1' }).success).toBe(true); + expect(schema.safeParse({ id: 'u1', email: 'a@b.com' }).success).toBe(false); + }); + + it('select with a relation field (true) includes the relation', () => { + const schema = factory.makeModelSchema('User', { select: { id: true, posts: true } }); + expect(schema.safeParse({ id: 'u1', posts: [] }).success).toBe(true); + // email should not be present + expect(schema.safeParse({ id: 'u1', posts: [], email: 'a@b.com' }).success).toBe(false); + }); + + it('infers relation field type when selected with true', () => { + const _schema = factory.makeModelSchema('User', { select: { id: true, posts: true } }); + type Result = z.infer; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toHaveProperty('posts'); + expectTypeOf().not.toHaveProperty('email'); + }); + + it('select with nested options on a relation', () => { + const schema = factory.makeModelSchema('User', { + select: { + id: true, + posts: { select: { title: true, published: true } }, + }, + }); + expect(schema.safeParse({ id: 'u1', posts: [{ title: 'Hello', published: true }] }).success).toBe(true); + // extra field in nested post + expect(schema.safeParse({ id: 'u1', posts: [{ title: 'Hello', published: true, id: 'p1' }] }).success).toBe( + false, + ); + }); + + it('infers nested select shape on relation when selected with options', () => { + const _schema = factory.makeModelSchema('User', { + select: { + id: true, + posts: { select: { title: true } }, + }, + }); + type Result = z.infer; + type Posts = Exclude; + type Post = Posts extends Array ? P : never; + expectTypeOf().toHaveProperty('title'); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().not.toHaveProperty('id'); + expectTypeOf().not.toHaveProperty('published'); + }); + + it('select on Post with author relation (nested include)', () => { + const schema = factory.makeModelSchema('Post', { + select: { + id: true, + author: { select: { id: true, email: true } }, + }, + }); + expect(schema.safeParse({ id: 'p1', author: { id: 'u1', email: 'a@b.com' } }).success).toBe(true); + // author with extra field + expect(schema.safeParse({ id: 'p1', author: { id: 'u1', email: 'a@b.com', username: 'x' } }).success).toBe( + false, + ); + }); + }); + + // ── invalid option combinations ─────────────────────────────────────────── + describe('invalid option combinations', () => { + it('throws when select and include are used together', () => { + expect(() => + factory.makeModelSchema('User', { select: { id: true }, include: { posts: true } } as any), + ).toThrow('`select` and `include` cannot be used together'); + }); + + it('throws when select and omit are used together', () => { + expect(() => + factory.makeModelSchema('User', { select: { id: true }, omit: { username: true } } as any), + ).toThrow('`select` and `omit` cannot be used together'); + }); + + it('throws when select and include are used together in nested relation options', () => { + expect(() => + factory.makeModelSchema('User', { + include: { posts: { select: { id: true }, include: {} } as any }, + }), + ).toThrow('`select` and `include` cannot be used together'); + }); + + it('throws when select references a non-existent field', () => { + expect(() => factory.makeModelSchema('User', { select: { nonExistent: true } as any })).toThrow( + 'Field "nonExistent" does not exist on model "User"', + ); + }); + + it('throws when select provides nested options for a scalar field', () => { + expect(() => + factory.makeModelSchema('User', { select: { email: { select: { id: true } } } as any }), + ).toThrow('Field "email" on model "User" is a scalar field and cannot have nested options'); + }); + + it('throws when include references a non-existent field', () => { + expect(() => factory.makeModelSchema('User', { include: { nonExistent: true } as any })).toThrow( + 'Field "nonExistent" does not exist on model "User"', + ); + }); + + it('throws when include references a scalar field', () => { + expect(() => factory.makeModelSchema('User', { include: { email: true } as any })).toThrow( + 'Field "email" on model "User" is not a relation field and cannot be used in "include"', + ); + }); + + it('throws when omit references a non-existent field', () => { + expect(() => factory.makeModelSchema('User', { omit: { nonExistent: true } as any })).toThrow( + 'Field "nonExistent" does not exist on model "User"', + ); + }); + + it('throws when omit references a relation field', () => { + expect(() => factory.makeModelSchema('User', { omit: { posts: true } as any })).toThrow( + 'Field "posts" on model "User" is a relation field and cannot be used in "omit"', + ); + }); + }); + + // ── runtime error handling ──────────────────────────────────────────────── + describe('runtime validation still applies with options', () => { + it('@@validate still runs with omit when the referenced field is present in the shape', () => { + // omitting `username` leaves `age` in the shape, so @@validate(age >= 18) still fires + const schema = factory.makeModelSchema('User', { omit: { username: true } }); + expect(schema.safeParse({ ...validUserNoUsername, age: 16 }).success).toBe(false); + expect(schema.safeParse({ ...validUserNoUsername, age: 18 }).success).toBe(true); + }); + + it('@@validate is skipped when its referenced field is omitted', () => { + // omitting `age` removes the field that @@validate(age >= 18) references, + // so the rule is silently skipped — age: 16 is no longer validated + const { age: _, username: _u, ...validUserNoAgeOrUsername } = validUser; + const schema = factory.makeModelSchema('User', { omit: { age: true, username: true } }); + expect(schema.safeParse(validUserNoAgeOrUsername).success).toBe(true); + }); + + it('field validation still runs with select options', () => { + const schema = factory.makeModelSchema('User', { select: { email: true } }); + expect(schema.safeParse({ email: 'not-an-email' }).success).toBe(false); + expect(schema.safeParse({ email: 'valid@example.com' }).success).toBe(true); + }); + + it('@@validate is skipped with select when the referenced field is not selected', () => { + // selecting only `email` omits `age`, so @@validate(age >= 18) is skipped + const schema = factory.makeModelSchema('User', { select: { email: true } }); + // would fail @@validate if age were present and < 18, but age isn't in the shape + expect(schema.safeParse({ email: 'valid@example.com' }).success).toBe(true); + }); + + it('@@validate still runs with select when the referenced field is selected', () => { + // selecting both `email` and `age` keeps the @@validate(age >= 18) rule active + const schema = factory.makeModelSchema('User', { select: { email: true, age: true } }); + expect(schema.safeParse({ email: 'valid@example.com', age: 16 }).success).toBe(false); + expect(schema.safeParse({ email: 'valid@example.com', age: 18 }).success).toBe(true); + }); + }); +}); diff --git a/packages/zod/test/schema/schema.ts b/packages/zod/test/schema/schema.ts index e2cdd212d..8abbf29c0 100644 --- a/packages/zod/test/schema/schema.ts +++ b/packages/zod/test/schema/schema.ts @@ -8,7 +8,7 @@ import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { - type: "sqlite" + type: "postgresql" } as const; models = { User: { @@ -125,6 +125,11 @@ export class SchemaType implements SchemaDef { name: "published", type: "Boolean" }, + tags: { + name: "tags", + type: "String", + array: true + }, author: { name: "author", type: "User", @@ -302,6 +307,11 @@ export class SchemaType implements SchemaDef { Address: { name: "Address", fields: { + residents: { + name: "residents", + type: "String", + array: true + }, street: { name: "street", type: "String", diff --git a/packages/zod/test/schema/schema.zmodel b/packages/zod/test/schema/schema.zmodel index 07e26a1ec..9e0d5716a 100644 --- a/packages/zod/test/schema/schema.zmodel +++ b/packages/zod/test/schema/schema.zmodel @@ -1,5 +1,5 @@ datasource db { - provider = 'sqlite' + provider = 'postgresql' } enum Status { @@ -11,9 +11,10 @@ enum Status { } type Address { - street String @meta("description", "Street address line") - city String @length(2) - zip String? + residents String[] + street String @meta("description", "Street address line") + city String @length(2) + zip String? @@validate(zip == null || length(zip) == 5, "Zip code must be exactly 5 characters", ["zip"]) @@meta("description", "A mailing address") @@ -42,20 +43,21 @@ model User { } model Post { - id String @id @default(cuid()) + id String @id @default(cuid()) title String published Boolean - author User? @relation(fields: [authorId], references: [id]) + tags String[] + author User? @relation(fields: [authorId], references: [id]) authorId String? } // --- Computed fields --- model Product { - id String @id @default(cuid()) - name String - price Float - discount Float @default(0) - finalPrice Float @computed + id String @id @default(cuid()) + name String + price Float + discount Float @default(0) + finalPrice Float @computed } // --- Delegate models --- diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5ac83d9e..1f2366cb8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -465,12 +465,24 @@ importers: langium: specifier: 'catalog:' version: 3.5.0 + mixpanel: + specifier: ^0.18.0 + version: 0.18.1 + uuid: + specifier: ^11.1.0 + version: 11.1.0 vscode-languageclient: specifier: ^9.0.1 version: 9.0.1 vscode-languageserver: specifier: ^9.0.1 version: 9.0.1 + vscode-uri: + specifier: ^3.1.0 + version: 3.1.0 + zod: + specifier: 'catalog:' + version: 4.1.12 devDependencies: '@types/vscode': specifier: ^1.90.0 @@ -481,6 +493,9 @@ importers: '@zenstackhq/typescript-config': specifier: workspace:* version: link:../../config/typescript-config + dotenv: + specifier: ^17.2.3 + version: 17.2.3 packages/language: dependencies: @@ -702,6 +717,9 @@ importers: decimal.js: specifier: 'catalog:' version: 10.6.0 + openapi-types: + specifier: ^12.1.3 + version: 12.1.3 superjson: specifier: ^2.2.3 version: 2.2.3 @@ -718,6 +736,9 @@ importers: specifier: 'catalog:' version: 4.0.1(zod@4.1.12) devDependencies: + '@readme/openapi-parser': + specifier: ^6.0.0 + version: 6.0.0(openapi-types@12.1.3) '@sveltejs/kit': specifier: 'catalog:' version: 2.53.2(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.53.5)(vite@7.3.1(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.2)))(svelte@5.53.5)(typescript@5.9.3)(vite@7.3.1(@types/node@20.19.24)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.0)(tsx@4.20.3)(yaml@2.8.2)) @@ -1266,6 +1287,12 @@ packages: resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} + '@apidevtools/json-schema-ref-parser@14.2.1': + resolution: {integrity: sha512-HmdFw9CDYqM6B25pqGBpNeLCKvGPlIx1EbLrVL0zPvj50CJQUHyBNBw45Muk0kEIkogo1VZvOKHajdMuAzSxRg==} + engines: {node: '>= 20'} + peerDependencies: + '@types/json-schema': ^7.0.15 + '@asamuzakjp/css-color@4.1.2': resolution: {integrity: sha512-NfBUvBaYgKIuq6E/RBLY1m0IohzNHAYyaJGuTK79Z23uNwmz2jl1mPsC5ZxCCxylinKhT1Amn5oNTlx1wN8cQg==} @@ -2191,6 +2218,10 @@ packages: resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} + '@humanwhocodes/momoa@2.0.4': + resolution: {integrity: sha512-RE815I4arJFtt+FVeU1Tgp9/Xvecacji8w/V6XtXsWWH/wz/eNkNbhb+ny/+PlVZjV0rxQpRSQKNKE3lcktHEA==} + engines: {node: '>=10.10.0'} + '@humanwhocodes/retry@0.3.1': resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==} engines: {node: '>=18.18'} @@ -3046,6 +3077,22 @@ packages: '@prisma/get-platform@6.19.0': resolution: {integrity: sha512-ym85WDO2yDhC3fIXHWYpG3kVMBA49cL1XD2GCsCF8xbwoy2OkDQY44gEbAt2X46IQ4Apq9H6g0Ex1iFfPqEkHA==} + '@readme/better-ajv-errors@2.4.0': + resolution: {integrity: sha512-9WODaOAKSl/mU+MYNZ2aHCrkoRSvmQ+1YkLj589OEqqjOAhbn8j7Z+ilYoiTu/he6X63/clsxxAB4qny9/dDzg==} + engines: {node: '>=18'} + peerDependencies: + ajv: 4.11.8 - 8 + + '@readme/openapi-parser@6.0.0': + resolution: {integrity: sha512-PaTnrKlKgEJZzjJ77AAhGe28NiyLBdiKMx95rJ9xlLZ8QLqYitMpPBQAKhsuEGOWQQbsIMfBZEPavbXghACQHA==} + engines: {node: '>=20'} + peerDependencies: + openapi-types: '>=7' + + '@readme/openapi-schemas@3.1.0': + resolution: {integrity: sha512-9FC/6ho8uFa8fV50+FPy/ngWN53jaUu4GRXlAjcxIRrzhltJnpKkBG2Tp0IDraFJeWrOpk84RJ9EMEEYzaI1Bw==} + engines: {node: '>=18'} + '@rolldown/pluginutils@1.0.0-rc.2': resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==} @@ -4202,6 +4249,14 @@ packages: resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} engines: {node: '>= 14'} + ajv-draft-04@1.0.0: + resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} + peerDependencies: + ajv: ^8.5.0 + peerDependenciesMeta: + ajv: + optional: true + ajv-formats@3.0.1: resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} peerDependencies: @@ -6263,6 +6318,10 @@ packages: jsonify@0.0.1: resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==} + jsonpointer@5.0.1: + resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==} + engines: {node: '>=0.10.0'} + jsonschema@1.4.1: resolution: {integrity: sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ==} @@ -6324,6 +6383,10 @@ packages: resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} engines: {node: '>= 0.6.3'} + leven@3.1.0: + resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} + engines: {node: '>=6'} + levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -7360,6 +7423,7 @@ packages: prebuild-install@7.1.3: resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} engines: {node: '>=10'} + deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available. hasBin: true prelude-ls@1.2.1: @@ -8567,6 +8631,10 @@ packages: resolution: {integrity: sha512-508e6IcKLrhxKdBbcA2b4KQZlLVp2+J5UwQ6F7Drckkc5N9ZJwFa4TgWtsww9UG8fGHbm6gbV19TdM5pQ4GaIA==} hasBin: true + uuid@11.1.0: + resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} + hasBin: true + validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} @@ -9032,6 +9100,11 @@ snapshots: '@alloc/quick-lru@5.2.0': {} + '@apidevtools/json-schema-ref-parser@14.2.1(@types/json-schema@7.0.15)': + dependencies: + '@types/json-schema': 7.0.15 + js-yaml: 4.1.1 + '@asamuzakjp/css-color@4.1.2': dependencies: '@csstools/css-calc': 3.1.1(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) @@ -9077,7 +9150,7 @@ snapshots: '@babel/core@7.28.5': dependencies: - '@babel/code-frame': 7.27.1 + '@babel/code-frame': 7.29.0 '@babel/generator': 7.28.5 '@babel/helper-compilation-targets': 7.27.2 '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.5) @@ -9088,7 +9161,7 @@ snapshots: '@babel/types': 7.28.5 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.1 + debug: 4.4.3 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -9348,31 +9421,31 @@ snapshots: '@babel/template@7.27.2': dependencies: - '@babel/code-frame': 7.27.1 + '@babel/code-frame': 7.29.0 '@babel/parser': 7.28.5 '@babel/types': 7.28.5 '@babel/template@7.28.6': dependencies: - '@babel/code-frame': 7.28.6 + '@babel/code-frame': 7.29.0 '@babel/parser': 7.28.6 '@babel/types': 7.28.6 '@babel/traverse@7.28.5': dependencies: - '@babel/code-frame': 7.27.1 + '@babel/code-frame': 7.29.0 '@babel/generator': 7.28.5 '@babel/helper-globals': 7.28.0 '@babel/parser': 7.28.5 '@babel/template': 7.27.2 '@babel/types': 7.28.5 - debug: 4.4.1 + debug: 4.4.3 transitivePeerDependencies: - supports-color '@babel/traverse@7.28.6': dependencies: - '@babel/code-frame': 7.28.6 + '@babel/code-frame': 7.29.0 '@babel/generator': 7.28.6 '@babel/helper-globals': 7.28.0 '@babel/parser': 7.28.6 @@ -9946,6 +10019,8 @@ snapshots: '@humanwhocodes/module-importer@1.0.1': {} + '@humanwhocodes/momoa@2.0.4': {} + '@humanwhocodes/retry@0.3.1': {} '@humanwhocodes/retry@0.4.3': {} @@ -10786,6 +10861,28 @@ snapshots: dependencies: '@prisma/debug': 6.19.0 + '@readme/better-ajv-errors@2.4.0(ajv@8.18.0)': + dependencies: + '@babel/code-frame': 7.29.0 + '@babel/runtime': 7.28.4 + '@humanwhocodes/momoa': 2.0.4 + ajv: 8.18.0 + jsonpointer: 5.0.1 + leven: 3.1.0 + picocolors: 1.1.1 + + '@readme/openapi-parser@6.0.0(openapi-types@12.1.3)': + dependencies: + '@apidevtools/json-schema-ref-parser': 14.2.1(@types/json-schema@7.0.15) + '@readme/better-ajv-errors': 2.4.0(ajv@8.18.0) + '@readme/openapi-schemas': 3.1.0 + '@types/json-schema': 7.0.15 + ajv: 8.18.0 + ajv-draft-04: 1.0.0(ajv@8.18.0) + openapi-types: 12.1.3 + + '@readme/openapi-schemas@3.1.0': {} + '@rolldown/pluginutils@1.0.0-rc.2': {} '@rolldown/pluginutils@1.0.0-rc.5': {} @@ -11502,7 +11599,7 @@ snapshots: '@typescript-eslint/types': 8.46.2 '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.46.2 - debug: 4.4.1 + debug: 4.4.3 eslint: 9.29.0(jiti@2.6.1) typescript: 5.9.3 transitivePeerDependencies: @@ -11548,7 +11645,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.34.1(typescript@5.9.3) '@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) - debug: 4.4.1 + debug: 4.4.3 eslint: 9.29.0(jiti@2.6.1) ts-api-utils: 2.1.0(typescript@5.9.3) typescript: 5.9.3 @@ -11560,7 +11657,7 @@ snapshots: '@typescript-eslint/types': 8.46.2 '@typescript-eslint/typescript-estree': 8.46.2(typescript@5.9.3) '@typescript-eslint/utils': 8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3) - debug: 4.4.1 + debug: 4.4.3 eslint: 9.29.0(jiti@2.6.1) ts-api-utils: 2.1.0(typescript@5.9.3) typescript: 5.9.3 @@ -11577,7 +11674,7 @@ snapshots: '@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.9.3) '@typescript-eslint/types': 8.34.1 '@typescript-eslint/visitor-keys': 8.34.1 - debug: 4.4.1 + debug: 4.4.3 fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.8 @@ -11593,7 +11690,7 @@ snapshots: '@typescript-eslint/tsconfig-utils': 8.46.2(typescript@5.9.3) '@typescript-eslint/types': 8.46.2 '@typescript-eslint/visitor-keys': 8.46.2 - debug: 4.4.1 + debug: 4.4.3 fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.8 @@ -11853,7 +11950,7 @@ snapshots: '@vue/babel-plugin-resolve-type@2.0.1(@babel/core@7.29.0)': dependencies: - '@babel/code-frame': 7.28.6 + '@babel/code-frame': 7.29.0 '@babel/core': 7.29.0 '@babel/helper-module-imports': 7.28.6 '@babel/helper-plugin-utils': 7.28.6 @@ -12065,12 +12162,16 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.4.1 + debug: 4.4.3 transitivePeerDependencies: - supports-color agent-base@7.1.4: {} + ajv-draft-04@1.0.0(ajv@8.18.0): + optionalDependencies: + ajv: 8.18.0 + ajv-formats@3.0.1(ajv@8.18.0): optionalDependencies: ajv: 8.18.0 @@ -13234,7 +13335,7 @@ snapshots: eslint: 9.29.0(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react: 7.37.5(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react-hooks: 7.0.1(eslint@9.29.0(jiti@2.6.1)) @@ -13267,7 +13368,7 @@ snapshots: tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)) transitivePeerDependencies: - supports-color @@ -13282,7 +13383,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -13935,7 +14036,7 @@ snapshots: https-proxy-agent@5.0.0: dependencies: agent-base: 6.0.2 - debug: 4.4.1 + debug: 4.4.3 transitivePeerDependencies: - supports-color @@ -14328,6 +14429,8 @@ snapshots: jsonify@0.0.1: {} + jsonpointer@5.0.1: {} + jsonschema@1.4.1: {} jsx-ast-utils@3.3.5: @@ -14394,6 +14497,8 @@ snapshots: dependencies: readable-stream: 2.3.8 + leven@3.1.0: {} + levn@0.4.1: dependencies: prelude-ls: 1.2.1 @@ -16989,6 +17094,8 @@ snapshots: uuid@11.0.5: {} + uuid@11.1.0: {} + validate-npm-package-license@3.0.4: dependencies: spdx-correct: 3.2.0 diff --git a/samples/next.js/zenstack/schema-lite.ts b/samples/next.js/zenstack/schema-lite.ts index 0f5ad88bc..78e36b195 100644 --- a/samples/next.js/zenstack/schema-lite.ts +++ b/samples/next.js/zenstack/schema-lite.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,12 +18,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -60,12 +60,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -79,7 +79,7 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - default: false + default: false as FieldDefault }, author: { name: "author", @@ -91,7 +91,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/samples/next.js/zenstack/schema.ts b/samples/next.js/zenstack/schema.ts index c420179f7..6735451d6 100644 --- a/samples/next.js/zenstack/schema.ts +++ b/samples/next.js/zenstack/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,26 +18,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, email: { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -64,20 +64,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, title: { name: "title", @@ -86,13 +86,13 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, author: { name: "author", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, authorId: { @@ -100,7 +100,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/samples/nuxt/zenstack/schema-lite.ts b/samples/nuxt/zenstack/schema-lite.ts index 0f5ad88bc..78e36b195 100644 --- a/samples/nuxt/zenstack/schema-lite.ts +++ b/samples/nuxt/zenstack/schema-lite.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,12 +18,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -60,12 +60,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -79,7 +79,7 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - default: false + default: false as FieldDefault }, author: { name: "author", @@ -91,7 +91,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/samples/nuxt/zenstack/schema.ts b/samples/nuxt/zenstack/schema.ts index c420179f7..6735451d6 100644 --- a/samples/nuxt/zenstack/schema.ts +++ b/samples/nuxt/zenstack/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,26 +18,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, email: { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -64,20 +64,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, title: { name: "title", @@ -86,13 +86,13 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, author: { name: "author", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, authorId: { @@ -100,7 +100,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/samples/orm/main.ts b/samples/orm/main.ts index 3b9dd1294..57f2748e0 100644 --- a/samples/orm/main.ts +++ b/samples/orm/main.ts @@ -8,7 +8,7 @@ async function main() { const db = new ZenStackClient(schema, { dialect: new SqliteDialect({ database: new SQLite('./zenstack/dev.db') }), computedFields: { - User: { + user: { postCount: (eb, { modelAlias }) => eb .selectFrom('Post') diff --git a/samples/orm/package.json b/samples/orm/package.json index 68c776325..dbf735ab6 100644 --- a/samples/orm/package.json +++ b/samples/orm/package.json @@ -1,6 +1,6 @@ { "name": "sample-orm", - "version": "3.4.6", + "version": "3.5.0", "description": "", "main": "index.js", "private": true, diff --git a/samples/orm/zenstack/schema.ts b/samples/orm/zenstack/schema.ts index aa0d92bc6..6b7df5b25 100644 --- a/samples/orm/zenstack/schema.ts +++ b/samples/orm/zenstack/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,26 +18,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, email: { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -47,14 +47,14 @@ export class SchemaType implements SchemaDef { postCount: { name: "postCount", type: "Int", - attributes: [{ name: "@computed" }], + attributes: [{ name: "@computed" }] as readonly AttributeApplication[], computed: true }, role: { name: "role", type: "Role", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }], - default: "USER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }] as readonly AttributeApplication[], + default: "USER" as FieldDefault }, posts: { name: "posts", @@ -72,7 +72,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read,create") }, { name: "condition", value: ExpressionUtils.literal(true) }] }, { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils._this(), "==", ExpressionUtils.call("auth")) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -93,20 +93,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, bio: { name: "bio", @@ -122,7 +122,7 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "profile", fields: ["userId"], references: ["id"] } }, userId: { @@ -130,15 +130,15 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] } }, attributes: [ { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.call("check", [ExpressionUtils.field("user")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -152,20 +152,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, title: { name: "title", @@ -178,13 +178,13 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, author: { name: "author", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "posts", fields: ["authorId"], references: ["id"] } }, authorId: { @@ -192,13 +192,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, attributes: [ { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.field("published") }] }, { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.field("author"), "==", ExpressionUtils.call("auth")) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -212,20 +212,20 @@ export class SchemaType implements SchemaDef { id: { name: "id", type: "String", - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } } } diff --git a/samples/sveltekit/src/zenstack/schema-lite.ts b/samples/sveltekit/src/zenstack/schema-lite.ts index 0f5ad88bc..78e36b195 100644 --- a/samples/sveltekit/src/zenstack/schema-lite.ts +++ b/samples/sveltekit/src/zenstack/schema-lite.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,12 +18,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -60,12 +60,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - default: ExpressionUtils.call("cuid") + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - default: ExpressionUtils.call("now") + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", @@ -79,7 +79,7 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - default: false + default: false as FieldDefault }, author: { name: "author", @@ -91,7 +91,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/samples/sveltekit/src/zenstack/schema.ts b/samples/sveltekit/src/zenstack/schema.ts index c420179f7..6735451d6 100644 --- a/samples/sveltekit/src/zenstack/schema.ts +++ b/samples/sveltekit/src/zenstack/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "sqlite" @@ -18,26 +18,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, email: { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -64,20 +64,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, title: { name: "title", @@ -86,13 +86,13 @@ export class SchemaType implements SchemaDef { published: { name: "published", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, author: { name: "author", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } }, authorId: { @@ -100,7 +100,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "author" - ] + ] as readonly string[] } }, idFields: ["id"], diff --git a/tests/e2e/apps/rally/zenstack/schema.ts b/tests/e2e/apps/rally/zenstack/schema.ts index a729240c7..34a1bf454 100644 --- a/tests/e2e/apps/rally/zenstack/schema.ts +++ b/tests/e2e/apps/rally/zenstack/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "postgresql" @@ -18,16 +18,16 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, provider: { name: "provider", @@ -36,19 +36,19 @@ export class SchemaType implements SchemaDef { providerAccountId: { name: "providerAccountId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] as readonly AttributeApplication[] }, refresh_token: { name: "refresh_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, access_token: { name: "access_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, expires_at: { name: "expires_at", @@ -64,49 +64,49 @@ export class SchemaType implements SchemaDef { name: "id_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("access_token_expires_at") }] }] as readonly AttributeApplication[] }, refreshTokenExpiresAt: { name: "refreshTokenExpiresAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("refresh_token_expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("refresh_token_expires_at") }] }] as readonly AttributeApplication[] }, password: { name: "password", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("password") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("password") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("accounts") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -120,8 +120,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -131,13 +131,13 @@ export class SchemaType implements SchemaDef { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@db.Citext" }] + attributes: [{ name: "@unique" }, { name: "@db.Citext" }] as readonly AttributeApplication[] }, emailVerified: { name: "emailVerified", type: "Boolean", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("email_verified") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("email_verified") }] }] as readonly AttributeApplication[] }, image: { name: "image", @@ -148,19 +148,19 @@ export class SchemaType implements SchemaDef { name: "timeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] as readonly AttributeApplication[] }, weekStart: { name: "weekStart", type: "Int", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("week_start") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("week_start") }] }] as readonly AttributeApplication[] }, timeFormat: { name: "timeFormat", type: "TimeFormat", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_format") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_format") }] }] as readonly AttributeApplication[] }, locale: { name: "locale", @@ -170,63 +170,63 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, customerId: { name: "customerId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("customer_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("customer_id") }] }] as readonly AttributeApplication[] }, banned: { name: "banned", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, bannedAt: { name: "bannedAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("banned_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("banned_at") }] }] as readonly AttributeApplication[] }, banReason: { name: "banReason", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_reason") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_reason") }] }] as readonly AttributeApplication[] }, banExpires: { name: "banExpires", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_expires") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ban_expires") }] }] as readonly AttributeApplication[] }, role: { name: "role", type: "UserRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("user") }] }], - default: "user" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("user") }] }] as readonly AttributeApplication[], + default: "user" as FieldDefault }, lastLoginMethod: { name: "lastLoginMethod", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_login_method") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_login_method") }] }] as readonly AttributeApplication[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("anonymous") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, comments: { name: "comments", @@ -274,14 +274,14 @@ export class SchemaType implements SchemaDef { name: "subscriptions", type: "Subscription", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }] }] as readonly AttributeApplication[], relation: { opposite: "user", name: "UserToSubscription" } }, spaces: { name: "spaces", type: "Space", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }] }] as readonly AttributeApplication[], relation: { opposite: "owner", name: "UserSpaces" } }, memberOf: { @@ -324,16 +324,16 @@ export class SchemaType implements SchemaDef { name: "defaultDestinationCalendarId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("default_destination_calendar_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("default_destination_calendar_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "defaultDestinationCalendar" - ] + ] as readonly string[] }, defaultDestinationCalendar: { name: "defaultDestinationCalendar", type: "ProviderCalendar", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserDefaultDestinationCalendar") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("defaultDestinationCalendarId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserDefaultDestinationCalendar") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("defaultDestinationCalendarId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "userDefaultDestination", name: "UserDefaultDestinationCalendar", fields: ["defaultDestinationCalendarId"], references: ["id"], onDelete: "SetNull" } }, sessions: { @@ -346,13 +346,13 @@ export class SchemaType implements SchemaDef { name: "impersonatedSessions", type: "Session", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ImpersonatedSessions") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ImpersonatedSessions") }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedByUser", name: "ImpersonatedSessions" } } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("users") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -365,14 +365,14 @@ export class SchemaType implements SchemaDef { identifier: { name: "identifier", type: "String", - attributes: [{ name: "@db.Citext" }] + attributes: [{ name: "@db.Citext" }] as readonly AttributeApplication[] }, token: { name: "token", type: "String", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, expires: { name: "expires", @@ -382,7 +382,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("identifier"), ExpressionUtils.field("token")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("verification_tokens") }] } - ], + ] as readonly AttributeApplication[], idFields: ["token"], uniqueFields: { token: { type: "String" }, @@ -396,12 +396,12 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, expiresAt: { name: "expiresAt", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] as readonly AttributeApplication[] }, token: { name: "token", @@ -410,62 +410,62 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, ipAddress: { name: "ipAddress", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] as readonly AttributeApplication[] }, 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("user_agent") }] }] as readonly AttributeApplication[] }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, impersonatedBy: { name: "impersonatedBy", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "impersonatedByUser" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("impersonatedBy")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ImpersonatedSessions") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("impersonatedBy")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedSessions", name: "ImpersonatedSessions", fields: ["impersonatedBy"], references: ["id"] } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("token")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("sessions") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -479,7 +479,7 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, identifier: { name: "identifier", @@ -492,25 +492,25 @@ export class SchemaType implements SchemaDef { expiresAt: { name: "expiresAt", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("verifications") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -524,19 +524,19 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("id") }] }] + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("id") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, deadline: { name: "deadline", @@ -561,111 +561,111 @@ export class SchemaType implements SchemaDef { name: "userId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, guestId: { name: "guestId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] as readonly AttributeApplication[] }, timeZone: { name: "timeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] as readonly AttributeApplication[] }, status: { name: "status", type: "PollStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("live") }] }], - default: "live" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("live") }] }] as readonly AttributeApplication[], + default: "live" as FieldDefault }, deleted: { name: "deleted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, deletedAt: { name: "deletedAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("touched_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, participantUrlId: { name: "participantUrlId", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_url_id") }] }] + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_url_id") }] }] as readonly AttributeApplication[] }, adminUrlId: { name: "adminUrlId", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("admin_url_id") }] }] + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("admin_url_id") }] }] as readonly AttributeApplication[] }, eventId: { name: "eventId", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("event_id") }] }] + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("event_id") }] }] as readonly AttributeApplication[] }, scheduledEventId: { name: "scheduledEventId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "scheduledEvent" - ] + ] as readonly string[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("hide_participants") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("hide_scores") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("disable_comments") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("require_participant_email") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "polls", fields: ["scheduledEventId"], references: ["id"], onDelete: "SetNull" } }, options: { @@ -708,17 +708,17 @@ export class SchemaType implements SchemaDef { name: "space", type: "Space", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], 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") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "space" - ] + ] as readonly string[] } }, attributes: [ @@ -726,7 +726,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("polls") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -742,48 +742,48 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "watchers", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "watcher", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("watchers") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -796,8 +796,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -812,24 +812,24 @@ export class SchemaType implements SchemaDef { name: "userId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, guestId: { name: "guestId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] as readonly AttributeApplication[] }, pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly string[] }, locale: { name: "locale", @@ -840,32 +840,32 @@ export class SchemaType implements SchemaDef { name: "timeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, deleted: { name: "deleted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, deletedAt: { name: "deletedAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] as readonly AttributeApplication[] }, votes: { name: "votes", @@ -876,21 +876,21 @@ export class SchemaType implements SchemaDef { poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "participants", fields: ["userId"], references: ["id"], onDelete: "SetNull" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("participants") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -903,33 +903,33 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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) }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("start_time") }] }, { name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("duration_minutes") }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, votes: { name: "votes", @@ -940,14 +940,14 @@ export class SchemaType implements SchemaDef { poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "options", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("options") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -960,68 +960,68 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, participantId: { name: "participantId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "participant" - ] + ] as readonly string[] }, optionId: { name: "optionId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("option_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("option_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "option" - ] + ] as readonly string[] }, pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly string[] }, type: { name: "type", type: "VoteType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("yes") }] }], - default: "yes" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("yes") }] }] as readonly AttributeApplication[], + default: "yes" as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, participant: { name: "participant", type: "Participant", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("participantId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("participantId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "votes", fields: ["participantId"], references: ["id"], onDelete: "Cascade" } }, option: { name: "option", type: "Option", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("optionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("optionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "votes", fields: ["optionId"], references: ["id"], onDelete: "Cascade" } }, poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "votes", fields: ["pollId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1030,7 +1030,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("participantId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("optionId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("votes") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1043,8 +1043,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, content: { name: "content", @@ -1053,62 +1053,62 @@ export class SchemaType implements SchemaDef { pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly string[] }, authorName: { name: "authorName", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("author_name") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("author_name") }] }] as readonly AttributeApplication[] }, userId: { name: "userId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, guestId: { name: "guestId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("guest_id") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "comments", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("comments") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1121,55 +1121,55 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, pollId: { name: "pollId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "poll" - ] + ] as readonly string[] }, ipAddress: { name: "ipAddress", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] as readonly AttributeApplication[] }, userId: { name: "userId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, 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("user_agent") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("viewed_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, poll: { name: "poll", type: "Poll", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("pollId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "pollViews", fields: ["userId"], references: ["id"], onDelete: "SetNull" } } }, @@ -1178,7 +1178,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("viewedAt")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_views") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1191,8 +1191,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, name: { name: "name", @@ -1206,33 +1206,33 @@ export class SchemaType implements SchemaDef { ownerId: { name: "ownerId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("owner_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("owner_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "owner" - ] + ] as readonly string[] }, tier: { name: "tier", type: "SpaceTier", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("hobby") }] }], - default: "hobby" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("hobby") }] }] as readonly AttributeApplication[], + default: "hobby" as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, owner: { name: "owner", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserSpaces") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("ownerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "spaces", name: "UserSpaces", fields: ["ownerId"], references: ["id"], onDelete: "Cascade" } }, polls: { @@ -1251,7 +1251,7 @@ export class SchemaType implements SchemaDef { name: "subscriptions", type: "Subscription", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SpaceToSubscription") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SpaceToSubscription") }] }] as readonly AttributeApplication[], relation: { opposite: "space", name: "SpaceToSubscription" } }, members: { @@ -1270,7 +1270,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("ownerId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("spaces") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1283,59 +1283,59 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, spaceId: { name: "spaceId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "space" - ] + ] as readonly string[] }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, role: { name: "role", type: "SpaceMemberRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], - default: "MEMBER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }] as readonly AttributeApplication[], + default: "MEMBER" as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_selected_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, space: { name: "space", type: "Space", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "members", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "memberOf", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1344,7 +1344,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [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("String", [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") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1358,16 +1358,16 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, spaceId: { name: "spaceId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "space" - ] + ] as readonly string[] }, email: { name: "email", @@ -1376,39 +1376,39 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, role: { name: "role", type: "SpaceMemberRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], - default: "MEMBER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }] as readonly AttributeApplication[], + default: "MEMBER" as FieldDefault }, inviterId: { name: "inviterId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("inviter_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("inviter_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "invitedBy" - ] + ] as readonly string[] }, invitedBy: { name: "invitedBy", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviterId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviterId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "spaceMemberInvites", fields: ["inviterId"], references: ["id"], onDelete: "Cascade" } }, space: { name: "space", type: "Space", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "memberInvites", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1416,7 +1416,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId"), ExpressionUtils.field("email")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [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") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1430,23 +1430,23 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, priceId: { name: "priceId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("price_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("price_id") }] }] as readonly AttributeApplication[] }, quantity: { name: "quantity", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], - default: 1 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }] as readonly AttributeApplication[], + default: 1 as FieldDefault }, subscriptionItemId: { name: "subscriptionItemId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_item_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_item_id") }] }] as readonly AttributeApplication[] }, amount: { name: "amount", @@ -1471,51 +1471,51 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, periodStart: { name: "periodStart", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_start") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_start") }] }] as readonly AttributeApplication[] }, periodEnd: { name: "periodEnd", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_end") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("period_end") }] }] as readonly AttributeApplication[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("cancel_at_period_end") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, spaceId: { name: "spaceId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "space" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserToSubscription") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SpaceToSubscription") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "subscriptions", name: "SpaceToSubscription", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1523,7 +1523,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscriptions") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1536,15 +1536,15 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, type: { name: "type", @@ -1557,25 +1557,25 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "paymentMethods", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("payment_methods") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1588,24 +1588,24 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, spaceId: { name: "spaceId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("space_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "space" - ] + ] as readonly string[] }, title: { name: "title", @@ -1624,26 +1624,26 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, status: { name: "status", type: "ScheduledEventStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("confirmed") }] }], - default: "confirmed" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("confirmed") }] }] as readonly AttributeApplication[], + default: "confirmed" as FieldDefault }, timeZone: { name: "timeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] as readonly AttributeApplication[] }, start: { name: "start", @@ -1656,37 +1656,37 @@ export class SchemaType implements SchemaDef { 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("all_day") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, deletedAt: { name: "deletedAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted_at") }] }] as readonly AttributeApplication[] }, sequence: { name: "sequence", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, uid: { name: "uid", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "scheduledEvents", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, space: { name: "space", type: "Space", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "scheduledEvents", fields: ["spaceId"], references: ["id"], onDelete: "Cascade" } }, rescheduledDates: { @@ -1712,7 +1712,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spaceId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "type", value: ExpressionUtils.literal("Hash") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_events") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1726,50 +1726,50 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, scheduledEventId: { name: "scheduledEventId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "scheduledEvent" - ] + ] as readonly string[] }, start: { name: "start", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("start") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("start") }] }] as readonly AttributeApplication[] }, end: { name: "end", type: "DateTime", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("end") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("end") }] }] as readonly AttributeApplication[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("all_day") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, scheduledEvent: { name: "scheduledEvent", type: "ScheduledEvent", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "rescheduledDates", fields: ["scheduledEventId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("rescheduled_event_dates") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1782,71 +1782,71 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, scheduledEventId: { name: "scheduledEventId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "scheduledEvent" - ] + ] as readonly string[] }, inviteeName: { name: "inviteeName", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_name") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_name") }] }] as readonly AttributeApplication[] }, inviteeEmail: { name: "inviteeEmail", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_email") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_email") }] }] as readonly AttributeApplication[] }, inviteeId: { name: "inviteeId", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, inviteeTimeZone: { name: "inviteeTimeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("invitee_time_zone") }] }] as readonly AttributeApplication[] }, status: { name: "status", type: "ScheduledEventInviteStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("pending") }] }], - default: "pending" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("pending") }] }] as readonly AttributeApplication[], + default: "pending" as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, scheduledEvent: { name: "scheduledEvent", type: "ScheduledEvent", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("scheduledEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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("String", [ExpressionUtils.field("inviteeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviteeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "scheduledEventInvites", fields: ["inviteeId"], references: ["id"], onDelete: "SetNull" } } }, @@ -1855,7 +1855,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviteeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviteeEmail")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_invites") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1868,16 +1868,16 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, provider: { name: "provider", @@ -1886,7 +1886,7 @@ export class SchemaType implements SchemaDef { providerAccountId: { name: "providerAccountId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] as readonly AttributeApplication[] }, type: { name: "type", @@ -1895,7 +1895,7 @@ export class SchemaType implements SchemaDef { secret: { name: "secret", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("secret") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("secret") }] }] as readonly AttributeApplication[] }, scopes: { name: "scopes", @@ -1906,19 +1906,19 @@ export class SchemaType implements SchemaDef { name: "expiresAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, calendarConnections: { name: "calendarConnections", @@ -1929,7 +1929,7 @@ export class SchemaType implements SchemaDef { user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "credentials", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1937,7 +1937,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [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("DateTime", [ExpressionUtils.field("expiresAt")]) }, { name: "name", value: ExpressionUtils.literal("credential_expiry_idx") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("credentials") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1951,16 +1951,16 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, provider: { name: "provider", @@ -1969,12 +1969,12 @@ export class SchemaType implements SchemaDef { integrationId: { name: "integrationId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("integration_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("integration_id") }] }] as readonly AttributeApplication[] }, providerAccountId: { name: "providerAccountId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_account_id") }] }] as readonly AttributeApplication[] }, email: { name: "email", @@ -1984,38 +1984,38 @@ export class SchemaType implements SchemaDef { name: "displayName", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("display_name") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("display_name") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, credential: { name: "credential", type: "Credential", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("credential_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "credential" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "calendarConnections", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, providerCalendars: { @@ -2028,7 +2028,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [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") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2042,21 +2042,21 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, calendarConnectionId: { name: "calendarConnectionId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("calendar_connection_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("calendar_connection_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "calendarConnection" - ] + ] as readonly string[] }, providerCalendarId: { name: "providerCalendarId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_calendar_id") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_calendar_id") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -2065,68 +2065,68 @@ export class SchemaType implements SchemaDef { 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("primary") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, timeZone: { name: "timeZone", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("time_zone") }] }] as readonly AttributeApplication[] }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("selected") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("deleted") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("writable") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, providerData: { name: "providerData", type: "Json", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_data") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_data") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("last_synced_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, calendarConnection: { name: "calendarConnection", type: "CalendarConnection", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("calendarConnectionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("calendarConnectionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UserDefaultDestinationCalendar") }] }] as readonly AttributeApplication[], relation: { opposite: "defaultDestinationCalendar", name: "UserDefaultDestinationCalendar" } } }, @@ -2136,7 +2136,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("isPrimary")]) }, { name: "name", value: ExpressionUtils.literal("primary_calendar_idx") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("lastSyncedAt")]) }, { name: "name", value: ExpressionUtils.literal("sync_time_idx") }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("provider_calendars") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2150,32 +2150,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], - default: 1 + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }] as readonly AttributeApplication[], + default: 1 as FieldDefault }, 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 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("disable_user_registration") }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("instance_settings") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -2188,20 +2188,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, licenseKey: { name: "licenseKey", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] as readonly AttributeApplication[] }, version: { name: "version", type: "Int", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] as readonly AttributeApplication[] }, type: { name: "type", @@ -2211,37 +2211,37 @@ export class SchemaType implements SchemaDef { name: "seats", type: "Int", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("issued_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] as readonly AttributeApplication[] }, licenseeEmail: { name: "licenseeEmail", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] as readonly AttributeApplication[] }, licenseeName: { name: "licenseeName", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] as readonly AttributeApplication[] }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACTIVE") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("status") }] }] as readonly AttributeApplication[], + default: "ACTIVE" as FieldDefault }, validations: { name: "validations", @@ -2252,7 +2252,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("licenses") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2266,51 +2266,51 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, licenseId: { name: "licenseId", type: "String", - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_id") }] }], + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_id") }] }] as readonly AttributeApplication[], foreignKeyFor: [ "license" - ] + ] as readonly string[] }, license: { name: "license", type: "License", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("licenseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("licenseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], 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") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("ip_address") }] }] as readonly AttributeApplication[] }, fingerprint: { name: "fingerprint", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("fingerprint") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("fingerprint") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("validated_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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("user_agent") }] }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("license_validations") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -2323,20 +2323,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, licenseKey: { name: "licenseKey", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] + attributes: [{ name: "@unique" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("license_key") }] }] as readonly AttributeApplication[] }, version: { name: "version", type: "Int", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("version") }] }] as readonly AttributeApplication[] }, type: { name: "type", @@ -2346,42 +2346,42 @@ export class SchemaType implements SchemaDef { name: "seats", type: "Int", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("seats") }] }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("issued_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("expires_at") }] }] as readonly AttributeApplication[] }, licenseeEmail: { name: "licenseeEmail", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_email") }] }] as readonly AttributeApplication[] }, licenseeName: { name: "licenseeName", type: "String", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("licensee_name") }] }] as readonly AttributeApplication[] }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACTIVE") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("status") }] }] as readonly AttributeApplication[], + default: "ACTIVE" as FieldDefault } }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("instance_licenses") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2398,7 +2398,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("time_format") }] } - ] + ] as readonly AttributeApplication[] }, UserRole: { name: "UserRole", @@ -2408,7 +2408,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("user_role") }] } - ] + ] as readonly AttributeApplication[] }, ParticipantVisibility: { name: "ParticipantVisibility", @@ -2419,7 +2419,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("participant_visibility") }] } - ] + ] as readonly AttributeApplication[] }, PollStatus: { name: "PollStatus", @@ -2430,7 +2430,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("poll_status") }] } - ] + ] as readonly AttributeApplication[] }, VoteType: { name: "VoteType", @@ -2441,7 +2441,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("vote_type") }] } - ] + ] as readonly AttributeApplication[] }, SpaceMemberRole: { name: "SpaceMemberRole", @@ -2458,7 +2458,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("space_tiers") }] } - ] + ] as readonly AttributeApplication[] }, SubscriptionStatus: { name: "SubscriptionStatus", @@ -2474,7 +2474,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_status") }] } - ] + ] as readonly AttributeApplication[] }, SubscriptionInterval: { name: "SubscriptionInterval", @@ -2484,7 +2484,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("subscription_interval") }] } - ] + ] as readonly AttributeApplication[] }, ScheduledEventStatus: { name: "ScheduledEventStatus", @@ -2495,7 +2495,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_status") }] } - ] + ] as readonly AttributeApplication[] }, ScheduledEventInviteStatus: { name: "ScheduledEventInviteStatus", @@ -2507,7 +2507,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("scheduled_event_invite_status") }] } - ] + ] as readonly AttributeApplication[] }, CredentialType: { name: "CredentialType", diff --git a/tests/e2e/github-repos/cal.com/schema.ts b/tests/e2e/github-repos/cal.com/schema.ts index dc3e4194b..787417aee 100644 --- a/tests/e2e/github-repos/cal.com/schema.ts +++ b/tests/e2e/github-repos/cal.com/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "postgresql" @@ -17,7 +17,7 @@ export class SchemaType implements SchemaDef { user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "hosts", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -26,12 +26,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "hosts", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -40,13 +40,13 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, isFixed: { name: "isFixed", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, priority: { name: "priority", @@ -67,7 +67,7 @@ export class SchemaType implements SchemaDef { name: "schedule", type: "Schedule", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "Host", fields: ["scheduleId"], references: ["id"] } }, scheduleId: { @@ -76,13 +76,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "schedule" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ @@ -90,7 +90,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["userId", "eventTypeId"], uniqueFields: { userId_eventTypeId: { userId: { type: "Int" }, eventTypeId: { type: "Int" } } @@ -103,34 +103,34 @@ export class SchemaType implements SchemaDef { name: "eventTypeId", type: "Int", id: true, - attributes: [{ name: "@id" }], + attributes: [{ name: "@id" }] as readonly AttributeApplication[], foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "calVideoSettings", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, disableRecordingForOrganizer: { name: "disableRecordingForOrganizer", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, disableRecordingForGuests: { name: "disableRecordingForGuests", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, enableAutomaticTranscription: { name: "enableAutomaticTranscription", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, redirectUrlOnExit: { name: "redirectUrlOnExit", @@ -140,26 +140,26 @@ export class SchemaType implements SchemaDef { disableTranscriptionForGuests: { name: "disableTranscriptionForGuests", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, disableTranscriptionForOrganizer: { name: "disableTranscriptionForOrganizer", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["eventTypeId"], @@ -174,8 +174,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, title: { name: "title", @@ -198,8 +198,8 @@ export class SchemaType implements SchemaDef { position: { name: "position", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, locations: { name: "locations", @@ -213,14 +213,14 @@ export class SchemaType implements SchemaDef { offsetStart: { name: "offsetStart", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, hidden: { name: "hidden", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hosts: { name: "hosts", @@ -232,14 +232,14 @@ export class SchemaType implements SchemaDef { name: "users", type: "User", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("user_eventtype") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("user_eventtype") }] }] as readonly AttributeApplication[], relation: { opposite: "eventTypes", name: "user_eventtype" } }, owner: { name: "owner", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("owner") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("owner") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "ownedEventTypes", name: "owner", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -248,7 +248,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "owner" - ] + ] as readonly string[] }, profileId: { name: "profileId", @@ -256,20 +256,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "profile" - ] + ] as readonly string[] }, profile: { name: "profile", type: "Profile", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("profileId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("profileId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "eventTypes", fields: ["profileId"], references: ["id"] } }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "eventTypes", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -278,7 +278,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, hashedLink: { name: "hashedLink", @@ -313,8 +313,8 @@ export class SchemaType implements SchemaDef { useEventLevelSelectedCalendars: { name: "useEventLevelSelectedCalendars", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, eventName: { name: "eventName", @@ -333,20 +333,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "parent" - ] + ] as readonly string[] }, parent: { name: "parent", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("managed_eventtype") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("managed_eventtype") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "children", name: "managed_eventtype", fields: ["parentId"], references: ["id"], onDelete: "Cascade" } }, children: { name: "children", type: "EventType", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("managed_eventtype") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("managed_eventtype") }] }] as readonly AttributeApplication[], relation: { opposite: "parent", name: "managed_eventtype" } }, bookingFields: { @@ -362,8 +362,8 @@ export class SchemaType implements SchemaDef { periodType: { name: "periodType", type: "PeriodType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLIMITED") }] }], - default: "UNLIMITED" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLIMITED") }] }] as readonly AttributeApplication[], + default: "UNLIMITED" as FieldDefault }, periodStartDate: { name: "periodStartDate", @@ -388,44 +388,44 @@ export class SchemaType implements SchemaDef { lockTimeZoneToggleOnBookingPage: { name: "lockTimeZoneToggleOnBookingPage", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, requiresConfirmation: { name: "requiresConfirmation", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, requiresConfirmationWillBlockSlot: { name: "requiresConfirmationWillBlockSlot", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, requiresConfirmationForFreeEmail: { name: "requiresConfirmationForFreeEmail", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, requiresBookerEmailVerification: { name: "requiresBookerEmailVerification", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, canSendCalVideoTranscriptionEmails: { name: "canSendCalVideoTranscriptionEmails", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, autoTranslateDescriptionEnabled: { name: "autoTranslateDescriptionEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, recurringEvent: { name: "recurringEvent", @@ -435,38 +435,38 @@ export class SchemaType implements SchemaDef { disableGuests: { name: "disableGuests", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hideCalendarNotes: { name: "hideCalendarNotes", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hideCalendarEventDetails: { name: "hideCalendarEventDetails", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, minimumBookingNotice: { name: "minimumBookingNotice", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(120) }] }], - default: 120 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(120) }] }] as readonly AttributeApplication[], + default: 120 as FieldDefault }, beforeEventBuffer: { name: "beforeEventBuffer", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, afterEventBuffer: { name: "afterEventBuffer", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, seatsPerTimeSlot: { name: "seatsPerTimeSlot", @@ -476,36 +476,36 @@ export class SchemaType implements SchemaDef { onlyShowFirstAvailableSlot: { name: "onlyShowFirstAvailableSlot", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, disableCancelling: { name: "disableCancelling", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, disableRescheduling: { name: "disableRescheduling", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, seatsShowAttendees: { name: "seatsShowAttendees", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, seatsShowAvailabilityCount: { name: "seatsShowAvailabilityCount", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, schedulingType: { name: "schedulingType", @@ -516,7 +516,7 @@ export class SchemaType implements SchemaDef { name: "schedule", type: "Schedule", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "eventType", fields: ["scheduleId"], references: ["id"] } }, scheduleId: { @@ -525,26 +525,26 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "schedule" - ] + ] as readonly string[] }, allowReschedulingCancelledBookings: { name: "allowReschedulingCancelledBookings", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, price: { name: "price", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, currency: { name: "currency", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("usd") }] }], - default: "usd" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("usd") }] }] as readonly AttributeApplication[], + default: "usd" as FieldDefault }, slotInterval: { name: "slotInterval", @@ -565,8 +565,8 @@ export class SchemaType implements SchemaDef { name: "forwardParamsSuccessRedirect", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, workflows: { name: "workflows", @@ -587,14 +587,14 @@ export class SchemaType implements SchemaDef { isInstantEvent: { name: "isInstantEvent", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, instantMeetingExpiryTimeOffsetInSeconds: { name: "instantMeetingExpiryTimeOffsetInSeconds", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(90) }] }], - default: 90 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(90) }] }] as readonly AttributeApplication[], + default: 90 as FieldDefault }, instantMeetingScheduleId: { name: "instantMeetingScheduleId", @@ -602,13 +602,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "instantMeetingSchedule" - ] + ] as readonly string[] }, instantMeetingSchedule: { name: "instantMeetingSchedule", type: "Schedule", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("InstantMeetingSchedule") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("instantMeetingScheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("InstantMeetingSchedule") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("instantMeetingScheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "instantMeetingEvents", name: "InstantMeetingSchedule", fields: ["instantMeetingScheduleId"], references: ["id"] } }, instantMeetingParameters: { @@ -619,14 +619,14 @@ export class SchemaType implements SchemaDef { assignAllTeamMembers: { name: "assignAllTeamMembers", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, assignRRMembersUsingSegment: { name: "assignRRMembersUsingSegment", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, rrSegmentQueryValue: { name: "rrSegmentQueryValue", @@ -636,8 +636,8 @@ export class SchemaType implements SchemaDef { useEventTypeDestinationCalendarEmail: { name: "useEventTypeDestinationCalendarEmail", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, aiPhoneCallConfig: { name: "aiPhoneCallConfig", @@ -648,8 +648,8 @@ export class SchemaType implements SchemaDef { isRRWeightsEnabled: { name: "isRRWeightsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, fieldTranslations: { name: "fieldTranslations", @@ -665,8 +665,8 @@ export class SchemaType implements SchemaDef { includeNoShowInRRCalculation: { name: "includeNoShowInRRCalculation", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, selectedCalendars: { name: "selectedCalendars", @@ -677,14 +677,14 @@ export class SchemaType implements SchemaDef { allowReschedulingPastBookings: { name: "allowReschedulingPastBookings", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hideOrganizerEmail: { name: "hideOrganizerEmail", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, maxActiveBookingsPerBooker: { name: "maxActiveBookingsPerBooker", @@ -694,8 +694,8 @@ export class SchemaType implements SchemaDef { maxActiveBookingPerBookerOfferReschedule: { name: "maxActiveBookingPerBookerOfferReschedule", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, customReplyToEmail: { name: "customReplyToEmail", @@ -716,8 +716,8 @@ export class SchemaType implements SchemaDef { rescheduleWithSameRoundRobinHost: { name: "rescheduleWithSameRoundRobinHost", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, secondaryEmailId: { name: "secondaryEmailId", @@ -725,20 +725,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "secondaryEmail" - ] + ] as readonly string[] }, secondaryEmail: { name: "secondaryEmail", type: "SecondaryEmail", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "eventTypes", fields: ["secondaryEmailId"], references: ["id"], onDelete: "Cascade" } }, useBookerTimezone: { name: "useBookerTimezone", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, restrictionScheduleId: { name: "restrictionScheduleId", @@ -746,13 +746,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "restrictionSchedule" - ] + ] as readonly string[] }, restrictionSchedule: { name: "restrictionSchedule", type: "Schedule", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("restrictionSchedule") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("restrictionScheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("restrictionSchedule") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("restrictionScheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "restrictionSchedule", name: "restrictionSchedule", fields: ["restrictionScheduleId"], references: ["id"] } } }, @@ -767,7 +767,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("restrictionScheduleId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -783,8 +783,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, type: { name: "type", @@ -798,7 +798,7 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "credentials", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -807,13 +807,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "credentials", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -822,13 +822,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, app: { name: "app", type: "App", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "credentials", fields: ["appId"], references: ["slug"], onDelete: "Cascade" } }, appId: { @@ -837,7 +837,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "app" - ] + ] as readonly string[] }, subscriptionId: { name: "subscriptionId", @@ -870,8 +870,8 @@ export class SchemaType implements SchemaDef { name: "invalid", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, CalendarCache: { name: "CalendarCache", @@ -891,13 +891,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "delegationCredential" - ] + ] as readonly string[] }, delegationCredential: { name: "delegationCredential", type: "DelegationCredential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "credentials", fields: ["delegationCredentialId"], references: ["id"], onDelete: "Cascade" } } }, @@ -906,7 +906,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("subscriptionId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("invalid")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("delegationCredentialId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -919,8 +919,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, integration: { name: "integration", @@ -939,7 +939,7 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationCalendar", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -947,10 +947,10 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, booking: { name: "booking", @@ -962,7 +962,7 @@ export class SchemaType implements SchemaDef { name: "eventType", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationCalendar", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -970,10 +970,10 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, credentialId: { name: "credentialId", @@ -981,20 +981,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "credential" - ] + ] as readonly string[] }, credential: { name: "credential", type: "Credential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationCalendars", fields: ["credentialId"], references: ["id"], onDelete: "Cascade" } }, delegationCredential: { name: "delegationCredential", type: "DelegationCredential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationCalendar", fields: ["delegationCredentialId"], references: ["id"], onDelete: "Cascade" } }, delegationCredentialId: { @@ -1003,13 +1003,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "delegationCredential" - ] + ] as readonly string[] }, domainWideDelegation: { name: "domainWideDelegation", type: "DomainWideDelegation", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationCalendar", fields: ["domainWideDelegationCredentialId"], references: ["id"], onDelete: "Cascade" } }, domainWideDelegationCredentialId: { @@ -1018,14 +1018,14 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "domainWideDelegation" - ] + ] as readonly string[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -1045,15 +1045,15 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "password", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, @@ -1069,20 +1069,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "travelSchedules", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, timeZone: { @@ -1107,7 +1107,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("startDate")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("endDate")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -1120,8 +1120,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, username: { name: "username", @@ -1161,8 +1161,8 @@ export class SchemaType implements SchemaDef { timeZone: { name: "timeZone", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Europe/London") }] }], - default: "Europe/London" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Europe/London") }] }] as readonly AttributeApplication[], + default: "Europe/London" as FieldDefault }, travelSchedules: { name: "travelSchedules", @@ -1173,32 +1173,32 @@ export class SchemaType implements SchemaDef { weekStart: { name: "weekStart", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Sunday") }] }], - default: "Sunday" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Sunday") }] }] as readonly AttributeApplication[], + default: "Sunday" as FieldDefault }, startTime: { name: "startTime", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, endTime: { name: "endTime", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1440) }] }], - default: 1440 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1440) }] }] as readonly AttributeApplication[], + default: 1440 as FieldDefault }, bufferTime: { name: "bufferTime", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, hideBranding: { name: "hideBranding", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, theme: { name: "theme", @@ -1213,8 +1213,8 @@ export class SchemaType implements SchemaDef { createdDate: { name: "createdDate", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, trialEndsAt: { name: "trialEndsAt", @@ -1230,7 +1230,7 @@ export class SchemaType implements SchemaDef { name: "eventTypes", type: "EventType", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("user_eventtype") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("user_eventtype") }] }] as readonly AttributeApplication[], relation: { opposite: "users", name: "user_eventtype" } }, credentials: { @@ -1271,8 +1271,8 @@ export class SchemaType implements SchemaDef { completedOnboarding: { name: "completedOnboarding", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, locale: { name: "locale", @@ -1283,8 +1283,8 @@ export class SchemaType implements SchemaDef { name: "timeFormat", type: "Int", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(12) }] }], - default: 12 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(12) }] }] as readonly AttributeApplication[], + default: 12 as FieldDefault }, twoFactorSecret: { name: "twoFactorSecret", @@ -1294,8 +1294,8 @@ export class SchemaType implements SchemaDef { twoFactorEnabled: { name: "twoFactorEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, backupCodes: { name: "backupCodes", @@ -1305,8 +1305,8 @@ export class SchemaType implements SchemaDef { identityProvider: { name: "identityProvider", type: "IdentityProvider", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CAL") }] }], - default: "CAL" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CAL") }] }] as readonly AttributeApplication[], + default: "CAL" as FieldDefault }, identityProviderId: { name: "identityProviderId", @@ -1350,22 +1350,22 @@ export class SchemaType implements SchemaDef { name: "allowDynamicBooking", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, allowSEOIndexing: { name: "allowSEOIndexing", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, receiveMonthlyDigestEmail: { name: "receiveMonthlyDigestEmail", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, metadata: { name: "metadata", @@ -1376,33 +1376,33 @@ export class SchemaType implements SchemaDef { name: "verified", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, role: { name: "role", type: "UserPermissionRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }], - default: "USER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }] as readonly AttributeApplication[], + default: "USER" as FieldDefault }, disableImpersonation: { name: "disableImpersonation", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, impersonatedUsers: { name: "impersonatedUsers", type: "Impersonations", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_user") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_user") }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedUser", name: "impersonated_user" } }, impersonatedBy: { name: "impersonatedBy", type: "Impersonations", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by_user") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by_user") }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedBy", name: "impersonated_by_user" } }, apiKeys: { @@ -1433,7 +1433,7 @@ export class SchemaType implements SchemaDef { name: "ownedEventTypes", type: "EventType", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("owner") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("owner") }] }] as readonly AttributeApplication[], relation: { opposite: "owner", name: "owner" } }, workflows: { @@ -1446,14 +1446,14 @@ export class SchemaType implements SchemaDef { name: "routingForms", type: "App_RoutingForms_Form", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("routing-form") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("routing-form") }] }] as readonly AttributeApplication[], relation: { opposite: "user", name: "routing-form" } }, updatedRoutingForms: { name: "updatedRoutingForms", type: "App_RoutingForms_Form", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updated-routing-form") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updated-routing-form") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedBy", name: "updated-routing-form" } }, verifiedNumbers: { @@ -1480,13 +1480,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("scope") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("scope") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "orgUsers", name: "scope", fields: ["organizationId"], references: ["id"], onDelete: "SetNull" } }, accessCodes: { @@ -1505,14 +1505,14 @@ export class SchemaType implements SchemaDef { name: "bookingRedirectsTo", type: "OutOfOfficeEntry", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("toUser") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("toUser") }] }] as readonly AttributeApplication[], relation: { opposite: "toUser", name: "toUser" } }, locked: { name: "locked", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, platformOAuthClients: { name: "platformOAuthClients", @@ -1550,13 +1550,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "movedToProfile" - ] + ] as readonly string[] }, movedToProfile: { name: "movedToProfile", type: "Profile", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("moved_to_profile") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("movedToProfileId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("moved_to_profile") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("movedToProfileId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "movedFromUser", name: "moved_to_profile", fields: ["movedToProfileId"], references: ["id"], onDelete: "SetNull" } }, secondaryEmails: { @@ -1568,8 +1568,8 @@ export class SchemaType implements SchemaDef { isPlatformManaged: { name: "isPlatformManaged", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, OutOfOfficeReasons: { name: "OutOfOfficeReasons", @@ -1580,14 +1580,14 @@ export class SchemaType implements SchemaDef { smsLockState: { name: "smsLockState", type: "SMSLockState", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLOCKED") }] }], - default: "UNLOCKED" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLOCKED") }] }] as readonly AttributeApplication[], + default: "UNLOCKED" as FieldDefault }, smsLockReviewedByAdmin: { name: "smsLockReviewedByAdmin", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, NotificationsSubscriptions: { name: "NotificationsSubscriptions", @@ -1610,49 +1610,49 @@ export class SchemaType implements SchemaDef { name: "reassignedBookings", type: "Booking", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("reassignByUser") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("reassignByUser") }] }] as readonly AttributeApplication[], relation: { opposite: "reassignBy", name: "reassignByUser" } }, createdAttributeToUsers: { name: "createdAttributeToUsers", type: "AttributeToUser", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdBy") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdBy") }] }] as readonly AttributeApplication[], relation: { opposite: "createdBy", name: "createdBy" } }, updatedAttributeToUsers: { name: "updatedAttributeToUsers", type: "AttributeToUser", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedBy") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedBy") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedBy", name: "updatedBy" } }, createdTranslations: { name: "createdTranslations", type: "EventTypeTranslation", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedEventTypeTranslations") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedEventTypeTranslations") }] }] as readonly AttributeApplication[], relation: { opposite: "creator", name: "CreatedEventTypeTranslations" } }, updatedTranslations: { name: "updatedTranslations", type: "EventTypeTranslation", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedEventTypeTranslations") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedEventTypeTranslations") }] }] as readonly AttributeApplication[], relation: { opposite: "updater", name: "UpdatedEventTypeTranslations" } }, createdWatchlists: { name: "createdWatchlists", type: "Watchlist", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedWatchlists") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedWatchlists") }] }] as readonly AttributeApplication[], relation: { opposite: "createdBy", name: "CreatedWatchlists" } }, updatedWatchlists: { name: "updatedWatchlists", type: "Watchlist", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedWatchlists") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedWatchlists") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedBy", name: "UpdatedWatchlists" } }, BookingInternalNote: { @@ -1670,7 +1670,7 @@ export class SchemaType implements SchemaDef { name: "createdOrganizationOnboardings", type: "OrganizationOnboarding", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedOrganizationOnboardings") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedOrganizationOnboardings") }] }] as readonly AttributeApplication[], relation: { opposite: "createdBy", name: "CreatedOrganizationOnboardings" } }, filterSegments: { @@ -1694,8 +1694,8 @@ export class SchemaType implements SchemaDef { whitelistWorkflows: { name: "whitelistWorkflows", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ @@ -1708,7 +1708,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("IdentityProvider", [ExpressionUtils.field("identityProvider")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("identityProviderId")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("users") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -1725,20 +1725,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "NotificationsSubscriptions", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, subscription: { @@ -1748,7 +1748,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("subscription")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -1761,8 +1761,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, uid: { name: "uid", @@ -1773,12 +1773,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "profiles", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, organizationId: { @@ -1786,12 +1786,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "orgProfiles", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, username: { @@ -1808,20 +1808,20 @@ export class SchemaType implements SchemaDef { name: "movedFromUser", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("moved_to_profile") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("moved_to_profile") }] }] as readonly AttributeApplication[], relation: { opposite: "movedToProfile", name: "moved_to_profile" } }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ @@ -1830,7 +1830,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -1845,8 +1845,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, name: { name: "name", @@ -1885,26 +1885,26 @@ export class SchemaType implements SchemaDef { hideBranding: { name: "hideBranding", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hideTeamProfileLink: { name: "hideTeamProfileLink", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isPrivate: { name: "isPrivate", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hideBookATeamMember: { name: "hideBookATeamMember", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, members: { name: "members", @@ -1927,8 +1927,8 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, metadata: { name: "metadata", @@ -1944,14 +1944,14 @@ export class SchemaType implements SchemaDef { name: "rrResetInterval", type: "RRResetInterval", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MONTH") }] }], - default: "MONTH" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MONTH") }] }] as readonly AttributeApplication[], + default: "MONTH" as FieldDefault }, rrTimestampBasis: { name: "rrTimestampBasis", type: "RRTimestampBasis", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CREATED_AT") }] }], - default: "CREATED_AT" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CREATED_AT") }] }] as readonly AttributeApplication[], + default: "CREATED_AT" as FieldDefault }, brandColor: { name: "brandColor", @@ -1986,27 +1986,27 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "parent" - ] + ] as readonly string[] }, parent: { name: "parent", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("organization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("organization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "children", name: "organization", fields: ["parentId"], references: ["id"], onDelete: "Cascade" } }, children: { name: "children", type: "Team", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("organization") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("organization") }] }] as readonly AttributeApplication[], relation: { opposite: "parent", name: "organization" } }, orgUsers: { name: "orgUsers", type: "User", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("scope") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("scope") }] }] as readonly AttributeApplication[], relation: { opposite: "organization", name: "scope" } }, inviteTokens: { @@ -2029,14 +2029,14 @@ export class SchemaType implements SchemaDef { timeZone: { name: "timeZone", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Europe/London") }] }], - default: "Europe/London" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Europe/London") }] }] as readonly AttributeApplication[], + default: "Europe/London" as FieldDefault }, weekStart: { name: "weekStart", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Sunday") }] }], - default: "Sunday" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("Sunday") }] }] as readonly AttributeApplication[], + default: "Sunday" as FieldDefault }, routingForms: { name: "routingForms", @@ -2065,8 +2065,8 @@ export class SchemaType implements SchemaDef { isOrganization: { name: "isOrganization", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, organizationSettings: { name: "organizationSettings", @@ -2089,8 +2089,8 @@ export class SchemaType implements SchemaDef { pendingPayment: { name: "pendingPayment", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, dsyncTeamGroupMapping: { name: "dsyncTeamGroupMapping", @@ -2101,8 +2101,8 @@ export class SchemaType implements SchemaDef { isPlatform: { name: "isPlatform", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, platformOAuthClient: { name: "platformOAuthClient", @@ -2114,7 +2114,7 @@ export class SchemaType implements SchemaDef { name: "createdByOAuthClient", type: "PlatformOAuthClient", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedByOAuthClient") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdByOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedByOAuthClient") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdByOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teams", name: "CreatedByOAuthClient", fields: ["createdByOAuthClientId"], references: ["id"], onDelete: "Cascade" } }, createdByOAuthClientId: { @@ -2123,13 +2123,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "createdByOAuthClient" - ] + ] as readonly string[] }, smsLockState: { name: "smsLockState", type: "SMSLockState", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLOCKED") }] }], - default: "UNLOCKED" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNLOCKED") }] }] as readonly AttributeApplication[], + default: "UNLOCKED" as FieldDefault }, platformBilling: { name: "platformBilling", @@ -2152,8 +2152,8 @@ export class SchemaType implements SchemaDef { smsLockReviewedByAdmin: { name: "smsLockReviewedByAdmin", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, delegationCredentials: { name: "delegationCredentials", @@ -2187,8 +2187,8 @@ export class SchemaType implements SchemaDef { includeManagedEventsInLimits: { name: "includeManagedEventsInLimits", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, internalNotePresets: { name: "internalNotePresets", @@ -2212,14 +2212,14 @@ export class SchemaType implements SchemaDef { name: "managedOrganization", type: "ManagedOrganization", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagedOrganization") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagedOrganization") }] }] as readonly AttributeApplication[], relation: { opposite: "managedOrganization", name: "ManagedOrganization" } }, managedOrganizations: { name: "managedOrganizations", type: "ManagedOrganization", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagerOrganization") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagerOrganization") }] }] as readonly AttributeApplication[], relation: { opposite: "managerOrganization", name: "ManagerOrganization" } }, filterSegments: { @@ -2232,7 +2232,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug"), ExpressionUtils.field("parentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("parentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -2246,14 +2246,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "creditBalance", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -2261,16 +2261,16 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "team" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "creditBalance", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -2278,16 +2278,16 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "user" - ] + ] as readonly string[] }, additionalCredits: { name: "additionalCredits", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, limitReachedAt: { name: "limitReachedAt", @@ -2326,20 +2326,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, creditBalanceId: { name: "creditBalanceId", type: "String", foreignKeyFor: [ "creditBalance" - ] + ] as readonly string[] }, creditBalance: { name: "creditBalance", type: "CreditBalance", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creditBalanceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creditBalanceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "purchaseLogs", fields: ["creditBalanceId"], references: ["id"], onDelete: "Cascade" } }, credits: { @@ -2349,8 +2349,8 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, idFields: ["id"], @@ -2365,20 +2365,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, creditBalanceId: { name: "creditBalanceId", type: "String", foreignKeyFor: [ "creditBalance" - ] + ] as readonly string[] }, creditBalance: { name: "creditBalance", type: "CreditBalance", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creditBalanceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creditBalanceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "expenseLogs", fields: ["creditBalanceId"], references: ["id"], onDelete: "Cascade" } }, bookingUid: { @@ -2387,13 +2387,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("bookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("bookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "expenseLogs", fields: ["bookingUid"], references: ["uid"], onDelete: "Cascade" } }, credits: { @@ -2432,35 +2432,35 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, organization: { name: "organization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "organizationSettings", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, organizationId: { name: "organizationId", type: "Int", unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, isOrganizationConfigured: { name: "isOrganizationConfigured", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isOrganizationVerified: { name: "isOrganizationVerified", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, orgAutoAcceptEmail: { name: "orgAutoAcceptEmail", @@ -2469,20 +2469,20 @@ export class SchemaType implements SchemaDef { lockEventTypeCreationForUsers: { name: "lockEventTypeCreationForUsers", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, adminGetsNoSlotsNotification: { name: "adminGetsNoSlotsNotification", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isAdminReviewed: { name: "isAdminReviewed", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, dSyncData: { name: "dSyncData", @@ -2493,26 +2493,26 @@ export class SchemaType implements SchemaDef { isAdminAPIEnabled: { name: "isAdminAPIEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, allowSEOIndexing: { name: "allowSEOIndexing", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, orgProfileRedirectsToVerifiedDomain: { name: "orgProfileRedirectsToVerifiedDomain", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, disablePhoneOnlySMSNotifications: { name: "disablePhoneOnlySMSNotifications", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, idFields: ["id"], @@ -2528,28 +2528,28 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, teamId: { name: "teamId", type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, accepted: { name: "accepted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, role: { name: "role", @@ -2561,32 +2561,32 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "customRole" - ] + ] as readonly string[] }, customRole: { name: "customRole", type: "Role", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("customRoleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("customRoleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "memberships", fields: ["customRoleId"], references: ["id"] } }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "members", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teams", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, disableImpersonation: { name: "disableImpersonation", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, AttributeToUser: { name: "AttributeToUser", @@ -2598,15 +2598,15 @@ export class SchemaType implements SchemaDef { name: "createdAt", type: "DateTime", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ @@ -2616,7 +2616,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("accepted")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("MembershipRole", [ExpressionUtils.field("role")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("customRoleId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -2630,8 +2630,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, identifier: { name: "identifier", @@ -2641,7 +2641,7 @@ export class SchemaType implements SchemaDef { name: "token", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, expires: { name: "expires", @@ -2655,14 +2655,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, teamId: { name: "teamId", @@ -2670,13 +2670,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "inviteTokens", fields: ["teamId"], references: ["id"] } }, secondaryEmailId: { @@ -2685,13 +2685,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "secondaryEmail" - ] + ] as readonly string[] }, secondaryEmail: { name: "secondaryEmail", type: "SecondaryEmail", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "verificationTokens", fields: ["secondaryEmailId"], references: ["id"] } } }, @@ -2700,7 +2700,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("token")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("secondaryEmailId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -2715,14 +2715,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, token: { name: "token", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, expires: { name: "expires", @@ -2733,12 +2733,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "instantMeetingTokens", fields: ["teamId"], references: ["id"] } }, bookingId: { @@ -2746,34 +2746,34 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "instantMeetingToken", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("token")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -2788,8 +2788,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, type: { name: "type", @@ -2823,7 +2823,7 @@ export class SchemaType implements SchemaDef { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "references", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, bookingId: { @@ -2832,7 +2832,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, externalCalendarId: { name: "externalCalendarId", @@ -2848,7 +2848,7 @@ export class SchemaType implements SchemaDef { name: "credential", type: "Credential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "references", fields: ["credentialId"], references: ["id"], onDelete: "SetNull" } }, credentialId: { @@ -2857,13 +2857,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "credential" - ] + ] as readonly string[] }, delegationCredential: { name: "delegationCredential", type: "DelegationCredential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "bookingReferences", fields: ["delegationCredentialId"], references: ["id"], onDelete: "SetNull" } }, delegationCredentialId: { @@ -2872,13 +2872,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "delegationCredential" - ] + ] as readonly string[] }, domainWideDelegation: { name: "domainWideDelegation", type: "DomainWideDelegation", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "bookingReferences", fields: ["domainWideDelegationCredentialId"], references: ["id"], onDelete: "SetNull" } }, domainWideDelegationCredentialId: { @@ -2887,14 +2887,14 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "domainWideDelegation" - ] + ] as readonly string[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("type")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -2907,8 +2907,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, email: { name: "email", @@ -2931,14 +2931,14 @@ export class SchemaType implements SchemaDef { name: "locale", type: "String", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("en") }] }], - default: "en" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("en") }] }] as readonly AttributeApplication[], + default: "en" as FieldDefault }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attendees", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, bookingId: { @@ -2947,7 +2947,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, bookingSeat: { name: "bookingSeat", @@ -2959,14 +2959,14 @@ export class SchemaType implements SchemaDef { name: "noShow", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("email")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -2979,27 +2979,27 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, uid: { name: "uid", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, idempotencyKey: { name: "idempotencyKey", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "bookings", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -3008,7 +3008,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, userPrimaryEmail: { name: "userPrimaryEmail", @@ -3025,7 +3025,7 @@ export class SchemaType implements SchemaDef { name: "eventType", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "bookings", fields: ["eventTypeId"], references: ["id"] } }, eventTypeId: { @@ -3034,7 +3034,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, title: { name: "title", @@ -3077,27 +3077,27 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, status: { name: "status", type: "BookingStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACCEPTED") }] }], - default: "ACCEPTED" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ACCEPTED") }] }] as readonly AttributeApplication[], + default: "ACCEPTED" as FieldDefault }, paid: { name: "paid", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, payment: { name: "payment", @@ -3109,7 +3109,7 @@ export class SchemaType implements SchemaDef { name: "destinationCalendar", type: "DestinationCalendar", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("destinationCalendarId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("destinationCalendarId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "booking", fields: ["destinationCalendarId"], references: ["id"] } }, destinationCalendarId: { @@ -3118,7 +3118,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "destinationCalendar" - ] + ] as readonly string[] }, cancellationReason: { name: "cancellationReason", @@ -3139,7 +3139,7 @@ export class SchemaType implements SchemaDef { name: "reassignBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("reassignByUser") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("reassignById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("reassignByUser") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("reassignById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "reassignedBookings", name: "reassignByUser", fields: ["reassignById"], references: ["id"] } }, reassignById: { @@ -3148,7 +3148,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "reassignBy" - ] + ] as readonly string[] }, dynamicEventSlugRef: { name: "dynamicEventSlugRef", @@ -3205,21 +3205,21 @@ export class SchemaType implements SchemaDef { isRecorded: { name: "isRecorded", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, iCalUID: { name: "iCalUID", type: "String", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }], - default: "" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }] as readonly AttributeApplication[], + default: "" as FieldDefault }, iCalSequence: { name: "iCalSequence", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, instantMeetingToken: { name: "instantMeetingToken", @@ -3241,8 +3241,8 @@ export class SchemaType implements SchemaDef { name: "noShowHost", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, scheduledTriggers: { name: "scheduledTriggers", @@ -3255,8 +3255,8 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, cancelledBy: { name: "cancelledBy", @@ -3318,7 +3318,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("BookingStatus", [ExpressionUtils.field("status")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("startTime"), ExpressionUtils.field("endTime"), ExpressionUtils.field("status")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -3334,20 +3334,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, bookingId: { name: "bookingId", type: "Int", foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tracking", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, utm_source: { @@ -3378,7 +3378,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -3392,13 +3392,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "schedules", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -3406,7 +3406,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, eventType: { name: "eventType", @@ -3418,14 +3418,14 @@ export class SchemaType implements SchemaDef { name: "instantMeetingEvents", type: "EventType", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("InstantMeetingSchedule") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("InstantMeetingSchedule") }] }] as readonly AttributeApplication[], relation: { opposite: "instantMeetingSchedule", name: "InstantMeetingSchedule" } }, restrictionSchedule: { name: "restrictionSchedule", type: "EventType", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("restrictionSchedule") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("restrictionSchedule") }] }] as readonly AttributeApplication[], relation: { opposite: "restrictionSchedule", name: "restrictionSchedule" } }, name: { @@ -3452,7 +3452,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -3465,14 +3465,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "availability", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -3481,13 +3481,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "availability", fields: ["eventTypeId"], references: ["id"] } }, eventTypeId: { @@ -3496,7 +3496,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, days: { name: "days", @@ -3506,24 +3506,24 @@ export class SchemaType implements SchemaDef { startTime: { name: "startTime", type: "DateTime", - attributes: [{ name: "@db.Time" }] + attributes: [{ name: "@db.Time" }] as readonly AttributeApplication[] }, endTime: { name: "endTime", type: "DateTime", - attributes: [{ name: "@db.Time" }] + attributes: [{ name: "@db.Time" }] as readonly AttributeApplication[] }, date: { name: "date", type: "DateTime", optional: true, - attributes: [{ name: "@db.Date" }] + attributes: [{ name: "@db.Date" }] as readonly AttributeApplication[] }, Schedule: { name: "Schedule", type: "Schedule", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "availability", fields: ["scheduleId"], references: ["id"] } }, scheduleId: { @@ -3532,14 +3532,14 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "Schedule" - ] + ] as readonly string[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("scheduleId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -3552,13 +3552,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "selectedCalendars", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -3566,7 +3566,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, integration: { name: "integration", @@ -3580,7 +3580,7 @@ export class SchemaType implements SchemaDef { name: "credential", type: "Credential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "selectedCalendars", fields: ["credentialId"], references: ["id"], onDelete: "Cascade" } }, credentialId: { @@ -3589,7 +3589,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "credential" - ] + ] as readonly string[] }, googleChannelId: { name: "googleChannelId", @@ -3620,7 +3620,7 @@ export class SchemaType implements SchemaDef { name: "delegationCredential", type: "DelegationCredential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("delegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "selectedCalendars", fields: ["delegationCredentialId"], references: ["id"], onDelete: "Cascade" } }, delegationCredentialId: { @@ -3629,13 +3629,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "delegationCredential" - ] + ] as readonly string[] }, domainWideDelegationCredential: { name: "domainWideDelegationCredential", type: "DomainWideDelegation", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("domainWideDelegationCredentialId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "selectedCalendars", fields: ["domainWideDelegationCredentialId"], references: ["id"], onDelete: "Cascade" } }, domainWideDelegationCredentialId: { @@ -3644,7 +3644,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "domainWideDelegationCredential" - ] + ] as readonly string[] }, error: { name: "error", @@ -3659,20 +3659,20 @@ export class SchemaType implements SchemaDef { watchAttempts: { name: "watchAttempts", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, unwatchAttempts: { name: "unwatchAttempts", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, maxAttempts: { name: "maxAttempts", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(3) }] }], - default: 3 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[], + default: 3 as FieldDefault }, eventTypeId: { name: "eventTypeId", @@ -3680,13 +3680,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "selectedCalendars", fields: ["eventTypeId"], references: ["id"] } } }, @@ -3699,7 +3699,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("integration"), ExpressionUtils.field("googleChannelExpiration"), ExpressionUtils.field("error"), ExpressionUtils.field("watchAttempts"), ExpressionUtils.field("maxAttempts")]) }, { name: "name", value: ExpressionUtils.literal("SelectedCalendar_watch_idx") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("integration"), ExpressionUtils.field("googleChannelExpiration"), ExpressionUtils.field("error"), ExpressionUtils.field("unwatchAttempts"), ExpressionUtils.field("maxAttempts")]) }, { name: "name", value: ExpressionUtils.literal("SelectedCalendar_unwatch_idx") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3714,20 +3714,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, eventTypeId: { name: "eventTypeId", type: "Int", foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "customInputs", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, label: { @@ -3750,13 +3750,13 @@ export class SchemaType implements SchemaDef { placeholder: { name: "placeholder", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }], - default: "" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }] as readonly AttributeApplication[], + default: "" as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -3769,20 +3769,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, email: { name: "email", @@ -3805,8 +3805,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, referenceId: { name: "referenceId", @@ -3823,14 +3823,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("referenceId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("ReminderType", [ExpressionUtils.field("reminderType")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -3843,20 +3843,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, uid: { name: "uid", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, app: { name: "app", type: "App", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "payments", fields: ["appId"], references: ["slug"], onDelete: "Cascade" } }, appId: { @@ -3865,20 +3865,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "app" - ] + ] as readonly string[] }, bookingId: { name: "bookingId", type: "Int", foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "payment", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, amount: { @@ -3909,20 +3909,20 @@ export class SchemaType implements SchemaDef { name: "externalId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, paymentOption: { name: "paymentOption", type: "PaymentOption", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ON_BOOKING") }] }], - default: "ON_BOOKING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("ON_BOOKING") }] }] as readonly AttributeApplication[], + default: "ON_BOOKING" as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("externalId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -3938,7 +3938,7 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }] + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[] }, userId: { name: "userId", @@ -3946,7 +3946,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, teamId: { name: "teamId", @@ -3954,7 +3954,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, eventTypeId: { name: "eventTypeId", @@ -3962,7 +3962,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, platformOAuthClientId: { name: "platformOAuthClientId", @@ -3970,7 +3970,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "platformOAuthClient" - ] + ] as readonly string[] }, subscriberUrl: { name: "subscriberUrl", @@ -3984,14 +3984,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, active: { name: "active", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, eventTriggers: { name: "eventTriggers", @@ -4002,35 +4002,35 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "webhooks", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "webhooks", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, eventType: { name: "eventType", type: "EventType", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "webhooks", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, platformOAuthClient: { name: "platformOAuthClient", type: "PlatformOAuthClient", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "webhook", fields: ["platformOAuthClientId"], references: ["id"], onDelete: "Cascade" } }, app: { name: "app", type: "App", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "Webhook", fields: ["appId"], references: ["slug"], onDelete: "Cascade" } }, appId: { @@ -4039,7 +4039,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "app" - ] + ] as readonly string[] }, secret: { name: "secret", @@ -4049,8 +4049,8 @@ export class SchemaType implements SchemaDef { platform: { name: "platform", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, scheduledTriggers: { name: "scheduledTriggers", @@ -4073,7 +4073,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("subscriberUrl")]) }, { name: "name", value: ExpressionUtils.literal("courseIdentifier") }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId"), ExpressionUtils.field("subscriberUrl")]) }, { name: "name", value: ExpressionUtils.literal("oauthclientwebhook") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("active")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4088,25 +4088,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, impersonatedUser: { name: "impersonatedUser", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_user") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedUserId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_user") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedUserId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedUsers", name: "impersonated_user", fields: ["impersonatedUserId"], references: ["id"], onDelete: "Cascade" } }, impersonatedBy: { name: "impersonatedBy", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by_user") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("impersonated_by_user") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "impersonatedBy", name: "impersonated_by_user", fields: ["impersonatedById"], references: ["id"], onDelete: "Cascade" } }, impersonatedUserId: { @@ -4114,20 +4114,20 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "impersonatedUser" - ] + ] as readonly string[] }, impersonatedById: { name: "impersonatedById", type: "Int", foreignKeyFor: [ "impersonatedBy" - ] + ] as readonly string[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedUserId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("impersonatedById")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -4141,15 +4141,15 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, teamId: { name: "teamId", @@ -4157,7 +4157,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, note: { name: "note", @@ -4167,8 +4167,8 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", @@ -4184,27 +4184,27 @@ export class SchemaType implements SchemaDef { name: "hashedKey", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "apiKeys", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "apiKeys", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, app: { name: "app", type: "App", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("appId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "ApiKey", fields: ["appId"], references: ["slug"], onDelete: "Cascade" } }, appId: { @@ -4213,7 +4213,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "app" - ] + ] as readonly string[] }, rateLimits: { name: "rateLimits", @@ -4224,7 +4224,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4238,8 +4238,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, name: { name: "name", @@ -4250,7 +4250,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "apiKey" - ] + ] as readonly string[] }, ttl: { name: "ttl", @@ -4267,25 +4267,25 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, apiKey: { name: "apiKey", type: "ApiKey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "rateLimits", fields: ["apiKeyId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -4298,19 +4298,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, link: { name: "link", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "hashedLink", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -4318,7 +4318,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "eventType" - ] + ] as readonly string[] } }, idFields: ["id"], @@ -4334,15 +4334,15 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, type: { name: "type", @@ -4365,13 +4365,13 @@ export class SchemaType implements SchemaDef { name: "refresh_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, access_token: { name: "access_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, expires_at: { name: "expires_at", @@ -4392,7 +4392,7 @@ export class SchemaType implements SchemaDef { name: "id_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, session_state: { name: "session_state", @@ -4403,7 +4403,7 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accounts", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, @@ -4411,7 +4411,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("type")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4425,21 +4425,21 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, sessionToken: { name: "sessionToken", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, expires: { name: "expires", @@ -4449,13 +4449,13 @@ export class SchemaType implements SchemaDef { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "sessions", fields: ["userId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4470,13 +4470,13 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }] + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[] }, dirName: { name: "dirName", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, keys: { name: "keys", @@ -4491,14 +4491,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, credentials: { name: "credentials", @@ -4527,13 +4527,13 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("enabled")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["slug"], uniqueFields: { slug: { type: "String" }, @@ -4547,8 +4547,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, description: { name: "description", @@ -4558,8 +4558,8 @@ export class SchemaType implements SchemaDef { position: { name: "position", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, routes: { name: "routes", @@ -4569,14 +4569,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -4590,14 +4590,14 @@ export class SchemaType implements SchemaDef { user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("routing-form") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("routing-form") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "routingForms", name: "routing-form", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, updatedBy: { name: "updatedBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updated-routing-form") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updated-routing-form") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedRoutingForms", name: "updated-routing-form", fields: ["updatedById"], references: ["id"], onDelete: "SetNull" } }, updatedById: { @@ -4606,20 +4606,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "updatedBy" - ] + ] as readonly string[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "routingForms", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -4628,7 +4628,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, responses: { name: "responses", @@ -4645,8 +4645,8 @@ export class SchemaType implements SchemaDef { disabled: { name: "disabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, settings: { name: "settings", @@ -4663,7 +4663,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("disabled")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -4676,19 +4676,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, formFillerId: { name: "formFillerId", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, form: { name: "form", type: "App_RoutingForms_Form", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "responses", fields: ["formId"], references: ["id"], onDelete: "Cascade" } }, formId: { @@ -4696,7 +4696,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "form" - ] + ] as readonly string[] }, response: { name: "response", @@ -4705,31 +4705,31 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, routedToBookingUid: { name: "routedToBookingUid", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "routedToBooking" - ] + ] as readonly string[] }, routedToBooking: { name: "routedToBooking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("routedToBookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("routedToBookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }] as readonly AttributeApplication[], relation: { opposite: "routedFromRoutingFormReponse", fields: ["routedToBookingUid"], references: ["uid"] } }, chosenRouteId: { @@ -4761,7 +4761,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formFillerId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("routedToBookingUid")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -4776,13 +4776,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, form: { name: "form", type: "App_RoutingForms_Form", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "queuedResponses", fields: ["formId"], references: ["id"], onDelete: "Cascade" } }, formId: { @@ -4790,7 +4790,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "form" - ] + ] as readonly string[] }, response: { name: "response", @@ -4804,31 +4804,31 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, actualResponseId: { name: "actualResponseId", type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "actualResponse" - ] + ] as readonly string[] }, actualResponse: { name: "actualResponse", type: "App_RoutingForms_FormResponse", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("actualResponseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("actualResponseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "queuedFormResponse", fields: ["actualResponseId"], references: ["id"], onDelete: "Cascade" } } }, @@ -4845,8 +4845,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, responseId: { name: "responseId", @@ -4854,7 +4854,7 @@ export class SchemaType implements SchemaDef { foreignKeyFor: [ "response", "denormalized" - ] + ] as readonly string[] }, fieldId: { name: "fieldId", @@ -4878,13 +4878,13 @@ export class SchemaType implements SchemaDef { response: { name: "response", type: "App_RoutingForms_FormResponse", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "map", value: ExpressionUtils.literal("RoutingFormResponseField_response_fkey") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "map", value: ExpressionUtils.literal("RoutingFormResponseField_response_fkey") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "routingFormResponseFields", fields: ["responseId"], references: ["id"], onDelete: "Cascade" } }, denormalized: { name: "denormalized", type: "RoutingFormResponseDenormalized", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DenormalizedResponseToFields") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DenormalizedResponseToFields") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "fields", name: "DenormalizedResponseToFields", fields: ["responseId"], references: ["id"], onDelete: "Cascade" } } }, @@ -4893,7 +4893,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("fieldId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Float", [ExpressionUtils.field("valueNumber")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("valueStringArray")]) }, { name: "type", value: ExpressionUtils.literal("Gin") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -4907,7 +4907,7 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, response: { name: "response", @@ -5043,10 +5043,10 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }], + attributes: [{ name: "@id" }] as readonly AttributeApplication[], foreignKeyFor: [ "response" - ] + ] as readonly string[] }, formId: { name: "formId", @@ -5069,7 +5069,7 @@ export class SchemaType implements SchemaDef { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "routingFormResponses", fields: ["bookingId"], references: ["id"], onDelete: "SetNull" } }, bookingUid: { @@ -5083,7 +5083,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, bookingStatus: { name: "bookingStatus", @@ -5099,19 +5099,19 @@ export class SchemaType implements SchemaDef { name: "bookingCreatedAt", type: "DateTime", optional: true, - attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] + attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[] }, bookingStartTime: { name: "bookingStartTime", type: "DateTime", optional: true, - attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] + attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[] }, bookingEndTime: { name: "bookingEndTime", type: "DateTime", optional: true, - attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] + attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[] }, bookingUserId: { name: "bookingUserId", @@ -5156,7 +5156,7 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] + attributes: [{ name: "@db.Timestamp", args: [{ name: "x", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[] }, utm_source: { name: "utm_source", @@ -5186,14 +5186,14 @@ export class SchemaType implements SchemaDef { response: { name: "response", type: "App_RoutingForms_FormResponse", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "routingFormResponses", fields: ["id"], references: ["id"], onDelete: "Cascade" } }, fields: { name: "fields", type: "RoutingFormResponseField", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DenormalizedResponseToFields") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DenormalizedResponseToFields") }] }] as readonly AttributeApplication[], relation: { opposite: "denormalized", name: "DenormalizedResponseToFields" } } }, @@ -5205,7 +5205,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingUserId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId"), ExpressionUtils.field("eventTypeParentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -5218,26 +5218,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, date: { name: "date", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "Feedback", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, rating: { @@ -5253,7 +5253,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("rating")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -5266,8 +5266,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, stepNumber: { name: "stepNumber", @@ -5282,12 +5282,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "workflow" - ] + ] as readonly string[] }, workflow: { name: "workflow", type: "Workflow", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "steps", fields: ["workflowId"], references: ["id"], onDelete: "Cascade" } }, sendTo: { @@ -5308,8 +5308,8 @@ export class SchemaType implements SchemaDef { template: { name: "template", type: "WorkflowTemplates", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("REMINDER") }] }], - default: "REMINDER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("REMINDER") }] }] as readonly AttributeApplication[], + default: "REMINDER" as FieldDefault }, workflowReminders: { name: "workflowReminders", @@ -5330,14 +5330,14 @@ export class SchemaType implements SchemaDef { numberVerificationPending: { name: "numberVerificationPending", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, includeCalendarEvent: { name: "includeCalendarEvent", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, verifiedAt: { name: "verifiedAt", @@ -5347,7 +5347,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -5360,14 +5360,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, position: { name: "position", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, name: { name: "name", @@ -5379,20 +5379,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workflows", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workflows", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -5401,7 +5401,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, activeOn: { name: "activeOn", @@ -5418,8 +5418,8 @@ export class SchemaType implements SchemaDef { isActiveOnAll: { name: "isActiveOnAll", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, trigger: { name: "trigger", @@ -5445,7 +5445,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -5458,13 +5458,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "aiPhoneCallConfig", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -5472,13 +5472,13 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, templateType: { name: "templateType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CUSTOM_TEMPLATE") }] }], - default: "CUSTOM_TEMPLATE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CUSTOM_TEMPLATE") }] }] as readonly AttributeApplication[], + default: "CUSTOM_TEMPLATE" as FieldDefault }, schedulerName: { name: "schedulerName", @@ -5516,8 +5516,8 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, beginMessage: { name: "beginMessage", @@ -5533,7 +5533,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -5547,13 +5547,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, workflow: { name: "workflow", type: "Workflow", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "activeOn", fields: ["workflowId"], references: ["id"], onDelete: "Cascade" } }, workflowId: { @@ -5561,12 +5561,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "workflow" - ] + ] as readonly string[] }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workflows", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -5574,14 +5574,14 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "eventType" - ] + ] as readonly string[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId"), ExpressionUtils.field("eventTypeId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -5595,13 +5595,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, workflow: { name: "workflow", type: "Workflow", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "activeOnTeams", fields: ["workflowId"], references: ["id"], onDelete: "Cascade" } }, workflowId: { @@ -5609,12 +5609,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "workflow" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "activeOrgWorkflows", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -5622,14 +5622,14 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId"), ExpressionUtils.field("teamId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -5643,8 +5643,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], - default: 1 + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }] as readonly AttributeApplication[], + default: 1 as FieldDefault }, logo: { name: "logo", @@ -5679,16 +5679,16 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, uuid: { name: "uuid", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, bookingUid: { name: "bookingUid", @@ -5696,13 +5696,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("bookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("bookingUid")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("uid")]) }] }] as readonly AttributeApplication[], relation: { opposite: "workflowReminders", fields: ["bookingUid"], references: ["uid"] } }, method: { @@ -5718,7 +5718,7 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, scheduled: { name: "scheduled", @@ -5730,13 +5730,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "workflowStep" - ] + ] as readonly string[] }, workflowStep: { name: "workflowStep", type: "WorkflowStep", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowStepId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workflowStepId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workflowReminders", fields: ["workflowStepId"], references: ["id"], onDelete: "Cascade" } }, cancelled: { @@ -5753,14 +5753,14 @@ export class SchemaType implements SchemaDef { name: "isMandatoryReminder", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, retryCount: { name: "retryCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault } }, attributes: [ @@ -5769,7 +5769,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("seatReferenceId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("WorkflowMethods", [ExpressionUtils.field("method"), ExpressionUtils.field("scheduled"), ExpressionUtils.field("scheduledDate")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("cancelled"), ExpressionUtils.field("scheduledDate")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -5784,8 +5784,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, jobName: { name: "jobName", @@ -5807,15 +5807,15 @@ export class SchemaType implements SchemaDef { retryCount: { name: "retryCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, appId: { name: "appId", @@ -5828,13 +5828,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "webhook" - ] + ] as readonly string[] }, webhook: { name: "webhook", type: "Webhook", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("webhookId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("webhookId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "scheduledTriggers", fields: ["webhookId"], references: ["id"], onDelete: "Cascade" } }, bookingId: { @@ -5843,13 +5843,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "scheduledTriggers", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } } }, @@ -5865,41 +5865,41 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, referenceUid: { name: "referenceUid", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, bookingId: { name: "bookingId", type: "Int", foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "seatsReferences", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, attendeeId: { name: "attendeeId", type: "Int", unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "attendee" - ] + ] as readonly string[] }, attendee: { name: "attendee", type: "Attendee", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("attendeeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("attendeeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "bookingSeat", fields: ["attendeeId"], references: ["id"], onDelete: "Cascade" } }, data: { @@ -5916,7 +5916,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("attendeeId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -5931,8 +5931,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", @@ -5940,13 +5940,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "verifiedNumbers", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -5955,13 +5955,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "verifiedNumbers", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, phoneNumber: { @@ -5972,7 +5972,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -5985,8 +5985,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", @@ -5994,13 +5994,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "verifiedEmails", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -6009,13 +6009,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "verifiedEmails", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, email: { @@ -6026,7 +6026,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -6040,13 +6040,13 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }] + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[] }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, description: { name: "description", @@ -6057,15 +6057,15 @@ export class SchemaType implements SchemaDef { name: "type", type: "FeatureType", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("RELEASE") }] }], - default: "RELEASE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("RELEASE") }] }] as readonly AttributeApplication[], + default: "RELEASE" as FieldDefault }, stale: { name: "stale", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, lastUsedAt: { name: "lastUsedAt", @@ -6076,16 +6076,16 @@ export class SchemaType implements SchemaDef { name: "createdAt", type: "DateTime", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedBy: { name: "updatedBy", @@ -6108,7 +6108,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("enabled")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("stale")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["slug"], uniqueFields: { slug: { type: "String" } @@ -6120,7 +6120,7 @@ export class SchemaType implements SchemaDef { user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "features", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -6129,12 +6129,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, feature: { name: "feature", type: "Feature", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("featureId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("featureId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "users", fields: ["featureId"], references: ["slug"], onDelete: "Cascade" } }, featureId: { @@ -6143,13 +6143,13 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "feature" - ] + ] as readonly string[] }, assignedAt: { name: "assignedAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, assignedBy: { name: "assignedBy", @@ -6159,13 +6159,13 @@ export class SchemaType implements SchemaDef { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("featureId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("featureId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["userId", "featureId"], uniqueFields: { userId_featureId: { userId: { type: "Int" }, featureId: { type: "String" } } @@ -6177,7 +6177,7 @@ export class SchemaType implements SchemaDef { team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "features", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -6186,12 +6186,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, feature: { name: "feature", type: "Feature", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("featureId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("featureId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teams", fields: ["featureId"], references: ["slug"], onDelete: "Cascade" } }, featureId: { @@ -6200,13 +6200,13 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "feature" - ] + ] as readonly string[] }, assignedAt: { name: "assignedAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, assignedBy: { name: "assignedBy", @@ -6216,13 +6216,13 @@ export class SchemaType implements SchemaDef { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("featureId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("featureId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["teamId", "featureId"], uniqueFields: { teamId_featureId: { teamId: { type: "Int" }, featureId: { type: "String" } } @@ -6235,8 +6235,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, eventTypeId: { name: "eventTypeId", @@ -6265,13 +6265,13 @@ export class SchemaType implements SchemaDef { isSeat: { name: "isSeat", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("slotUtcStartDate"), ExpressionUtils.field("slotUtcEndDate"), ExpressionUtils.field("uid")]) }, { name: "name", value: ExpressionUtils.literal("selectedSlotUnique") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -6286,7 +6286,7 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }] + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[] }, redirectUri: { name: "redirectUri", @@ -6324,8 +6324,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, code: { name: "code", @@ -6337,13 +6337,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "client" - ] + ] as readonly string[] }, client: { name: "client", type: "OAuthClient", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("clientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("clientId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("clientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("clientId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accessCodes", fields: ["clientId"], references: ["clientId"], onDelete: "Cascade" } }, expiresAt: { @@ -6361,13 +6361,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accessCodes", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -6376,13 +6376,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accessCodes", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } } }, @@ -6399,7 +6399,7 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, uid: { name: "uid", @@ -6525,7 +6525,7 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }] + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[] }, uid: { name: "uid", @@ -6646,7 +6646,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("BookingStatus", [ExpressionUtils.field("status")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("isTeamBooking")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("isTeamBooking")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -6660,7 +6660,7 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, uid: { name: "uid", @@ -6788,8 +6788,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, key: { name: "key", @@ -6810,7 +6810,7 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "credential" - ] + ] as readonly string[] }, userId: { name: "userId", @@ -6821,7 +6821,7 @@ export class SchemaType implements SchemaDef { name: "credential", type: "Credential", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "CalendarCache", fields: ["credentialId"], references: ["id"], onDelete: "Cascade" } } }, @@ -6829,7 +6829,7 @@ export class SchemaType implements SchemaDef { { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId"), ExpressionUtils.field("key")]) }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("credentialId"), ExpressionUtils.field("key")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("key")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["key", "credentialId"], uniqueFields: { credentialId_key: { credentialId: { type: "Int" }, key: { type: "String" } } @@ -6842,8 +6842,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, from: { name: "from", @@ -6864,25 +6864,25 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("from"), ExpressionUtils.field("type"), ExpressionUtils.field("fromOrgId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -6895,14 +6895,14 @@ export class SchemaType implements SchemaDef { teamId: { name: "teamId", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, userId: { name: "userId", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, data: { name: "data", @@ -6913,19 +6913,19 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, isBanner: { name: "isBanner", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("userId"), ExpressionUtils.field("isBanner")]) }] }, { name: "@@map", args: [{ name: "name", value: ExpressionUtils.literal("avatars") }] } - ], + ] as readonly AttributeApplication[], idFields: ["objectKey"], uniqueFields: { objectKey: { type: "String" }, @@ -6939,14 +6939,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, uuid: { name: "uuid", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, start: { name: "start", @@ -6966,12 +6966,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "bookingRedirects", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, toUserId: { @@ -6980,13 +6980,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "toUser" - ] + ] as readonly string[] }, toUser: { name: "toUser", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("toUser") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("toUserId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("toUser") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("toUserId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "bookingRedirectsTo", name: "toUser", fields: ["toUserId"], references: ["id"], onDelete: "Cascade" } }, reasonId: { @@ -6995,26 +6995,26 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "reason" - ] + ] as readonly string[] }, reason: { name: "reason", type: "OutOfOfficeReason", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("reasonId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("reasonId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "entries", fields: ["reasonId"], references: ["id"], onDelete: "SetNull" } }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ @@ -7022,7 +7022,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("toUserId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("start"), ExpressionUtils.field("end")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -7036,8 +7036,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, emoji: { name: "emoji", @@ -7047,13 +7047,13 @@ export class SchemaType implements SchemaDef { name: "reason", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, userId: { name: "userId", @@ -7061,13 +7061,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "OutOfOfficeReasons", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, entries: { @@ -7090,8 +7090,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -7126,19 +7126,19 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "platformOAuthClient", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, teams: { name: "teams", type: "Team", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedByOAuthClient") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedByOAuthClient") }] }] as readonly AttributeApplication[], relation: { opposite: "createdByOAuthClient", name: "CreatedByOAuthClient" } }, accessTokens: { @@ -7183,26 +7183,26 @@ export class SchemaType implements SchemaDef { areEmailsEnabled: { name: "areEmailsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, areDefaultEventTypesEnabled: { name: "areDefaultEventTypesEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, areCalendarEventsEnabled: { name: "areCalendarEventsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, idFields: ["id"], @@ -7217,19 +7217,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, owner: { name: "owner", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "PlatformAuthorizationToken", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, client: { name: "client", type: "PlatformOAuthClient", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "authorizationTokens", fields: ["platformOAuthClientId"], references: ["id"], onDelete: "Cascade" } }, platformOAuthClientId: { @@ -7237,25 +7237,25 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "client" - ] + ] as readonly string[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "owner" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("platformOAuthClientId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -7269,20 +7269,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, secret: { name: "secret", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", @@ -7291,13 +7291,13 @@ export class SchemaType implements SchemaDef { owner: { name: "owner", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "AccessToken", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, client: { name: "client", type: "PlatformOAuthClient", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accessTokens", fields: ["platformOAuthClientId"], references: ["id"], onDelete: "Cascade" } }, platformOAuthClientId: { @@ -7305,14 +7305,14 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "client" - ] + ] as readonly string[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "owner" - ] + ] as readonly string[] } }, idFields: ["id"], @@ -7328,20 +7328,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, secret: { name: "secret", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", @@ -7350,13 +7350,13 @@ export class SchemaType implements SchemaDef { owner: { name: "owner", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "RefreshToken", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, client: { name: "client", type: "PlatformOAuthClient", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("platformOAuthClientId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "refreshToken", fields: ["platformOAuthClientId"], references: ["id"], onDelete: "Cascade" } }, platformOAuthClientId: { @@ -7364,14 +7364,14 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "client" - ] + ] as readonly string[] }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "owner" - ] + ] as readonly string[] } }, idFields: ["id"], @@ -7387,14 +7387,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, directoryId: { name: "directoryId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, tenant: { name: "tenant", @@ -7405,16 +7405,16 @@ export class SchemaType implements SchemaDef { type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "org" - ] + ] as readonly string[] }, org: { name: "org", type: "OrganizationSettings", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "dSyncData", fields: ["organizationId"], references: ["organizationId"], onDelete: "Cascade" } }, teamGroupMapping: { @@ -7427,14 +7427,14 @@ export class SchemaType implements SchemaDef { name: "createdAttributeToUsers", type: "AttributeToUser", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdByDSync") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdByDSync") }] }] as readonly AttributeApplication[], relation: { opposite: "createdByDSync", name: "createdByDSync" } }, updatedAttributeToUsers: { name: "updatedAttributeToUsers", type: "AttributeToUser", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedByDSync") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedByDSync") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedByDSync", name: "updatedByDSync" } } }, @@ -7452,8 +7452,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, organizationId: { name: "organizationId", @@ -7464,12 +7464,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "dsyncTeamGroupMapping", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, directoryId: { @@ -7477,12 +7477,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "directory" - ] + ] as readonly string[] }, directory: { name: "directory", type: "DSyncData", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teamGroupMapping", fields: ["directoryId"], references: ["directoryId"], onDelete: "Cascade" } }, groupName: { @@ -7492,7 +7492,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("groupName")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -7506,13 +7506,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "secondaryEmails", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -7520,7 +7520,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, email: { name: "email", @@ -7548,7 +7548,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("email")]) }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("email")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -7564,26 +7564,26 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, scheduledAt: { name: "scheduledAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, succeededAt: { name: "succeededAt", @@ -7601,14 +7601,14 @@ export class SchemaType implements SchemaDef { attempts: { name: "attempts", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, maxAttempts: { name: "maxAttempts", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(3) }] }], - default: 3 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(3) }] }] as readonly AttributeApplication[], + default: 3 as FieldDefault }, lastError: { name: "lastError", @@ -7639,15 +7639,15 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "managedOrganization" - ] + ] as readonly string[] }, managedOrganization: { name: "managedOrganization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagedOrganization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managedOrganizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagedOrganization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managedOrganizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "managedOrganization", name: "ManagedOrganization", fields: ["managedOrganizationId"], references: ["id"], onDelete: "Cascade" } }, managerOrganizationId: { @@ -7655,25 +7655,25 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "managerOrganization" - ] + ] as readonly string[] }, managerOrganization: { name: "managerOrganization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagerOrganization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerOrganizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ManagerOrganization") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerOrganizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "managedOrganizations", name: "ManagerOrganization", fields: ["managerOrganizationId"], references: ["id"], onDelete: "Cascade" } }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerOrganizationId"), ExpressionUtils.field("managedOrganizationId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerOrganizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["managedOrganizationId"], uniqueFields: { managedOrganizationId: { type: "Int" }, @@ -7688,10 +7688,10 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }], + attributes: [{ name: "@id" }, { name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "team" - ] + ] as readonly string[] }, customerId: { name: "customerId", @@ -7710,8 +7710,8 @@ export class SchemaType implements SchemaDef { plan: { name: "plan", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("none") }] }], - default: "none" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("none") }] }] as readonly AttributeApplication[], + default: "none" as FieldDefault }, billingCycleStart: { name: "billingCycleStart", @@ -7727,8 +7727,8 @@ export class SchemaType implements SchemaDef { name: "overdue", type: "Boolean", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, managerBillingId: { name: "managerBillingId", @@ -7736,26 +7736,26 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "managerBilling" - ] + ] as readonly string[] }, managerBilling: { name: "managerBilling", type: "PlatformBilling", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("PlatformManagedBilling") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerBillingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("PlatformManagedBilling") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("managerBillingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "managedBillings", name: "PlatformManagedBilling", fields: ["managerBillingId"], references: ["id"] } }, managedBillings: { name: "managedBillings", type: "PlatformBilling", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("PlatformManagedBilling") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("PlatformManagedBilling") }] }] as readonly AttributeApplication[], relation: { opposite: "managerBilling", name: "PlatformManagedBilling" } }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "platformBilling", fields: ["id"], references: ["id"], onDelete: "Cascade" } } }, @@ -7771,13 +7771,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, attribute: { name: "attribute", type: "Attribute", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "options", fields: ["attributeId"], references: ["id"], onDelete: "Cascade" } }, attributeId: { @@ -7785,7 +7785,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attribute" - ] + ] as readonly string[] }, value: { name: "value", @@ -7798,8 +7798,8 @@ export class SchemaType implements SchemaDef { isGroup: { name: "isGroup", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, contains: { name: "contains", @@ -7825,13 +7825,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributes", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -7839,7 +7839,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] }, type: { name: "type", @@ -7853,31 +7853,31 @@ export class SchemaType implements SchemaDef { name: "slug", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, usersCanEditRelation: { name: "usersCanEditRelation", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, options: { name: "options", @@ -7888,19 +7888,19 @@ export class SchemaType implements SchemaDef { isWeightsEnabled: { name: "isWeightsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isLocked: { name: "isLocked", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -7914,13 +7914,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, member: { name: "member", type: "Membership", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("memberId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("memberId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "AttributeToUser", fields: ["memberId"], references: ["id"], onDelete: "Cascade" } }, memberId: { @@ -7928,12 +7928,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "member" - ] + ] as readonly string[] }, attributeOption: { name: "attributeOption", type: "AttributeOption", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeOptionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeOptionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "assignedUsers", fields: ["attributeOptionId"], references: ["id"], onDelete: "Cascade" } }, attributeOptionId: { @@ -7941,7 +7941,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attributeOption" - ] + ] as readonly string[] }, weight: { name: "weight", @@ -7951,8 +7951,8 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, createdById: { name: "createdById", @@ -7960,13 +7960,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "createdBy" - ] + ] as readonly string[] }, createdBy: { name: "createdBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdBy") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdBy") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "createdAttributeToUsers", name: "createdBy", fields: ["createdById"], references: ["id"], onDelete: "SetNull" } }, createdByDSyncId: { @@ -7975,13 +7975,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "createdByDSync" - ] + ] as readonly string[] }, createdByDSync: { name: "createdByDSync", type: "DSyncData", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdByDSync") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdByDSyncId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("createdByDSync") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdByDSyncId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "createdAttributeToUsers", name: "createdByDSync", fields: ["createdByDSyncId"], references: ["directoryId"], onDelete: "SetNull" } }, updatedAt: { @@ -7989,13 +7989,13 @@ export class SchemaType implements SchemaDef { type: "DateTime", optional: true, updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, updatedBy: { name: "updatedBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedBy") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedBy") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedAttributeToUsers", name: "updatedBy", fields: ["updatedById"], references: ["id"], onDelete: "SetNull" } }, updatedById: { @@ -8004,7 +8004,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "updatedBy" - ] + ] as readonly string[] }, updatedByDSyncId: { name: "updatedByDSyncId", @@ -8012,19 +8012,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "updatedByDSync" - ] + ] as readonly string[] }, updatedByDSync: { name: "updatedByDSync", type: "DSyncData", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedByDSync") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("updatedByDSyncId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("updatedByDSync") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("updatedByDSyncId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("directoryId")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedAttributeToUsers", name: "updatedByDSync", fields: ["updatedByDSyncId"], references: ["directoryId"], onDelete: "SetNull" } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("memberId"), ExpressionUtils.field("attributeOptionId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -8039,26 +8039,26 @@ export class SchemaType implements SchemaDef { type: "Int", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, bookingId: { name: "bookingId", type: "Int", foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, booking: { name: "booking", type: "Booking", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "assignmentReason", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, reasonEnum: { @@ -8072,7 +8072,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -8085,13 +8085,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, workspacePlatform: { name: "workspacePlatform", type: "WorkspacePlatform", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workspacePlatformId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workspacePlatformId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "delegationCredentials", fields: ["workspacePlatformId"], references: ["id"], onDelete: "Cascade" } }, workspacePlatformId: { @@ -8099,7 +8099,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "workspacePlatform" - ] + ] as readonly string[] }, serviceAccountKey: { name: "serviceAccountKey", @@ -8108,8 +8108,8 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, lastEnabledAt: { name: "lastEnabledAt", @@ -8126,12 +8126,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "delegationCredentials", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, domain: { @@ -8159,14 +8159,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, credentials: { name: "credentials", @@ -8178,7 +8178,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("domain")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Boolean", [ExpressionUtils.field("enabled")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -8192,13 +8192,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, workspacePlatform: { name: "workspacePlatform", type: "WorkspacePlatform", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workspacePlatformId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("workspacePlatformId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "domainWideDelegations", fields: ["workspacePlatformId"], references: ["id"], onDelete: "Cascade" } }, workspacePlatformId: { @@ -8206,7 +8206,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "workspacePlatform" - ] + ] as readonly string[] }, serviceAccountKey: { name: "serviceAccountKey", @@ -8215,20 +8215,20 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, organizationId: { name: "organizationId", type: "Int", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "domainWideDelegations", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, domain: { @@ -8256,19 +8256,19 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("domain")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -8282,8 +8282,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, slug: { name: "slug", @@ -8304,20 +8304,20 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, delegationCredentials: { name: "delegationCredentials", @@ -8334,7 +8334,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("slug")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -8348,13 +8348,13 @@ export class SchemaType implements SchemaDef { name: "uid", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, eventType: { name: "eventType", type: "EventType", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "fieldTranslations", fields: ["eventTypeId"], references: ["id"], onDelete: "Cascade" } }, eventTypeId: { @@ -8362,7 +8362,7 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "eventType" - ] + ] as readonly string[] }, field: { name: "field", @@ -8379,26 +8379,26 @@ export class SchemaType implements SchemaDef { translatedText: { name: "translatedText", type: "String", - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, createdBy: { name: "createdBy", type: "Int", foreignKeyFor: [ "creator" - ] + ] as readonly string[] }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, updatedBy: { name: "updatedBy", @@ -8406,26 +8406,26 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "updater" - ] + ] as readonly string[] }, creator: { name: "creator", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedEventTypeTranslations") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdBy")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedEventTypeTranslations") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdBy")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "createdTranslations", name: "CreatedEventTypeTranslations", fields: ["createdBy"], references: ["id"] } }, updater: { name: "updater", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedEventTypeTranslations") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedBy")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedEventTypeTranslations") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedBy")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "updatedTranslations", name: "UpdatedEventTypeTranslations", fields: ["updatedBy"], references: ["id"], onDelete: "SetNull" } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId"), ExpressionUtils.field("field"), ExpressionUtils.field("targetLocale")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("eventTypeId"), ExpressionUtils.field("field"), ExpressionUtils.field("targetLocale")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["uid"], uniqueFields: { uid: { type: "String" }, @@ -8440,8 +8440,8 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", @@ -8459,13 +8459,13 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, createdBy: { name: "createdBy", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedWatchlists") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedWatchlists") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "createdWatchlists", name: "CreatedWatchlists", onDelete: "Cascade", fields: ["createdById"], references: ["id"] } }, createdById: { @@ -8473,19 +8473,19 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "createdBy" - ] + ] as readonly string[] }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, updatedBy: { name: "updatedBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedWatchlists") }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("UpdatedWatchlists") }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("updatedById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "updatedWatchlists", name: "UpdatedWatchlists", onDelete: "SetNull", fields: ["updatedById"], references: ["id"] } }, updatedById: { @@ -8494,19 +8494,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "updatedBy" - ] + ] as readonly string[] }, severity: { name: "severity", type: "WatchlistSeverity", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("LOW") }] }], - default: "LOW" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("LOW") }] }] as readonly AttributeApplication[], + default: "LOW" as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("WatchlistType", [ExpressionUtils.field("type"), ExpressionUtils.field("value")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("WatchlistType", [ExpressionUtils.field("type"), ExpressionUtils.field("value")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -8520,13 +8520,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, createdBy: { name: "createdBy", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedOrganizationOnboardings") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CreatedOrganizationOnboardings") }, { name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "createdOrganizationOnboardings", name: "CreatedOrganizationOnboardings", fields: ["createdById"], references: ["id"], onDelete: "Cascade" } }, createdById: { @@ -8534,19 +8534,19 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "createdBy" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, orgOwnerEmail: { name: "orgOwnerEmail", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, error: { name: "error", @@ -8557,23 +8557,23 @@ export class SchemaType implements SchemaDef { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, organizationId: { name: "organizationId", type: "Int", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "organizationOnboarding", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, billingPeriod: { @@ -8591,8 +8591,8 @@ export class SchemaType implements SchemaDef { isPlatform: { name: "isPlatform", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, name: { name: "name", @@ -8615,15 +8615,15 @@ export class SchemaType implements SchemaDef { isDomainConfigured: { name: "isDomainConfigured", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, stripeCustomerId: { name: "stripeCustomerId", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, stripeSubscriptionId: { name: "stripeSubscriptionId", @@ -8638,26 +8638,26 @@ export class SchemaType implements SchemaDef { invitedMembers: { name: "invitedMembers", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }], - default: "[]" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }] as readonly AttributeApplication[], + default: "[]" as FieldDefault }, teams: { name: "teams", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }], - default: "[]" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }] as readonly AttributeApplication[], + default: "[]" as FieldDefault }, isComplete: { name: "isComplete", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("orgOwnerEmail")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("stripeCustomerId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -8673,13 +8673,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, form: { name: "form", type: "App_RoutingForms_Form", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("formId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "incompleteBookingActions", fields: ["formId"], references: ["id"], onDelete: "Cascade" } }, formId: { @@ -8687,7 +8687,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "form" - ] + ] as readonly string[] }, actionType: { name: "actionType", @@ -8700,8 +8700,8 @@ export class SchemaType implements SchemaDef { enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, credentialId: { name: "credentialId", @@ -8721,8 +8721,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, name: { name: "name", @@ -8736,7 +8736,7 @@ export class SchemaType implements SchemaDef { team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "internalNotePresets", fields: ["teamId"], references: ["id"] } }, teamId: { @@ -8744,13 +8744,13 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "team" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, BookingInternalNote: { name: "BookingInternalNote", @@ -8762,7 +8762,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId"), ExpressionUtils.field("name")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -8776,8 +8776,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, name: { name: "name", @@ -8819,24 +8819,24 @@ export class SchemaType implements SchemaDef { name: "searchTerm", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "filterSegments", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -8844,13 +8844,13 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "filterSegments", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -8859,7 +8859,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, userPreferences: { name: "userPreferences", @@ -8871,7 +8871,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("FilterSegmentScope", [ExpressionUtils.field("scope"), ExpressionUtils.field("userId"), ExpressionUtils.field("tableIdentifier")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("FilterSegmentScope", [ExpressionUtils.field("scope"), ExpressionUtils.field("teamId"), ExpressionUtils.field("tableIdentifier")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" } @@ -8884,15 +8884,15 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, userId: { name: "userId", type: "Int", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, tableIdentifier: { name: "tableIdentifier", @@ -8903,30 +8903,30 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "segment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "filterSegmentPreferences", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, segment: { name: "segment", type: "FilterSegment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("segmentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("segmentId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "userPreferences", fields: ["segmentId"], references: ["id"], onDelete: "Cascade" } } }, @@ -8934,7 +8934,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId"), ExpressionUtils.field("tableIdentifier")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("segmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -8948,14 +8948,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, notePreset: { name: "notePreset", type: "InternalNotePreset", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("notePresetId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("notePresetId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "BookingInternalNote", fields: ["notePresetId"], references: ["id"], onDelete: "Cascade" } }, notePresetId: { @@ -8964,7 +8964,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "notePreset" - ] + ] as readonly string[] }, text: { name: "text", @@ -8974,7 +8974,7 @@ export class SchemaType implements SchemaDef { booking: { name: "booking", type: "Booking", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "internalNote", fields: ["bookingId"], references: ["id"], onDelete: "Cascade" } }, bookingId: { @@ -8982,12 +8982,12 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "booking" - ] + ] as readonly string[] }, createdBy: { name: "createdBy", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("createdById")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "BookingInternalNote", fields: ["createdById"], references: ["id"] } }, createdById: { @@ -8995,19 +8995,19 @@ export class SchemaType implements SchemaDef { type: "Int", foreignKeyFor: [ "createdBy" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId"), ExpressionUtils.field("notePresetId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("bookingId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -9021,8 +9021,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "Int", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }], - default: ExpressionUtils.call("autoincrement") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("autoincrement") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("autoincrement") as FieldDefault }, type: { name: "type", @@ -9039,19 +9039,19 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("WorkflowContactType", [ExpressionUtils.field("type"), ExpressionUtils.field("value")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "Int" }, @@ -9065,8 +9065,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -9083,13 +9083,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("Int", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "roles", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, permissions: { @@ -9107,26 +9107,26 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, type: { name: "type", type: "RoleType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CUSTOM") }] }], - default: "CUSTOM" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CUSTOM") }] }] as readonly AttributeApplication[], + default: "CUSTOM" as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("name"), ExpressionUtils.field("teamId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("Int", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -9140,20 +9140,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, roleId: { name: "roleId", type: "String", foreignKeyFor: [ "role" - ] + ] as readonly string[] }, role: { name: "role", type: "Role", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("roleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("roleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "permissions", fields: ["roleId"], references: ["id"], onDelete: "Cascade" } }, resource: { @@ -9167,15 +9167,15 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("roleId"), ExpressionUtils.field("resource"), ExpressionUtils.field("action")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("roleId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("action")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -9196,19 +9196,19 @@ export class SchemaType implements SchemaDef { name: "ROUND_ROBIN", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("roundRobin") }] } - ] + ] as readonly AttributeApplication[] }, COLLECTIVE: { name: "COLLECTIVE", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("collective") }] } - ] + ] as readonly AttributeApplication[] }, MANAGED: { name: "MANAGED", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("managed") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9225,25 +9225,25 @@ export class SchemaType implements SchemaDef { name: "UNLIMITED", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("unlimited") }] } - ] + ] as readonly AttributeApplication[] }, ROLLING: { name: "ROLLING", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("rolling") }] } - ] + ] as readonly AttributeApplication[] }, ROLLING_WINDOW: { name: "ROLLING_WINDOW", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("rolling_window") }] } - ] + ] as readonly AttributeApplication[] }, RANGE: { name: "RANGE", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("range") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9259,19 +9259,19 @@ export class SchemaType implements SchemaDef { name: "API_V1", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("api_v1") }] } - ] + ] as readonly AttributeApplication[] }, API_V2: { name: "API_V2", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("api_v2") }] } - ] + ] as readonly AttributeApplication[] }, WEBAPP: { name: "WEBAPP", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("webapp") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9319,31 +9319,31 @@ export class SchemaType implements SchemaDef { name: "CANCELLED", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("cancelled") }] } - ] + ] as readonly AttributeApplication[] }, ACCEPTED: { name: "ACCEPTED", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("accepted") }] } - ] + ] as readonly AttributeApplication[] }, REJECTED: { name: "REJECTED", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("rejected") }] } - ] + ] as readonly AttributeApplication[] }, PENDING: { name: "PENDING", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("pending") }] } - ] + ] as readonly AttributeApplication[] }, AWAITING_HOST: { name: "AWAITING_HOST", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("awaiting_host") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9362,37 +9362,37 @@ export class SchemaType implements SchemaDef { name: "TEXT", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("text") }] } - ] + ] as readonly AttributeApplication[] }, TEXTLONG: { name: "TEXTLONG", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("textLong") }] } - ] + ] as readonly AttributeApplication[] }, NUMBER: { name: "NUMBER", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("number") }] } - ] + ] as readonly AttributeApplication[] }, BOOL: { name: "BOOL", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("bool") }] } - ] + ] as readonly AttributeApplication[] }, RADIO: { name: "RADIO", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("radio") }] } - ] + ] as readonly AttributeApplication[] }, PHONE: { name: "PHONE", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("phone") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9483,19 +9483,19 @@ export class SchemaType implements SchemaDef { name: "DAY", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("day") }] } - ] + ] as readonly AttributeApplication[] }, HOUR: { name: "HOUR", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("hour") }] } - ] + ] as readonly AttributeApplication[] }, MINUTE: { name: "MINUTE", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("minute") }] } - ] + ] as readonly AttributeApplication[] } } }, @@ -9562,25 +9562,25 @@ export class SchemaType implements SchemaDef { name: "UserEventType", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user-event-type") }] } - ] + ] as readonly AttributeApplication[] }, TeamEventType: { name: "TeamEventType", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("team-event-type") }] } - ] + ] as readonly AttributeApplication[] }, User: { name: "User", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("user") }] } - ] + ] as readonly AttributeApplication[] }, Team: { name: "Team", attributes: [ { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("team") }] } - ] + ] as readonly AttributeApplication[] } } }, diff --git a/tests/e2e/github-repos/formbricks/schema.ts b/tests/e2e/github-repos/formbricks/schema.ts index 825df4e9d..265fad364 100644 --- a/tests/e2e/github-repos/formbricks/schema.ts +++ b/tests/e2e/github-repos/formbricks/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "postgresql" @@ -18,8 +18,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -29,15 +29,15 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, url: { name: "url", @@ -46,13 +46,13 @@ export class SchemaType implements SchemaDef { source: { name: "source", type: "WebhookSource", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("user") }] }], - default: "user" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("user") }] }] as readonly AttributeApplication[], + default: "user" as FieldDefault }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "webhooks", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -60,7 +60,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, triggers: { name: "triggers", @@ -75,7 +75,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -88,25 +88,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, attributeKey: { name: "attributeKey", type: "ContactAttributeKey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributes", fields: ["attributeKeyId"], references: ["id"], onDelete: "Cascade" } }, attributeKeyId: { @@ -114,12 +114,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attributeKey" - ] + ] as readonly string[] }, contact: { name: "contact", type: "Contact", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributes", fields: ["contactId"], references: ["id"], onDelete: "Cascade" } }, contactId: { @@ -127,7 +127,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "contact" - ] + ] as readonly string[] }, value: { name: "value", @@ -137,7 +137,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId"), ExpressionUtils.field("attributeKeyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId"), ExpressionUtils.field("value")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -151,26 +151,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, isUnique: { name: "isUnique", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, key: { name: "key", @@ -189,13 +189,13 @@ export class SchemaType implements SchemaDef { type: { name: "type", type: "ContactAttributeType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("custom") }] }], - default: "custom" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("custom") }] }] as readonly AttributeApplication[], + default: "custom" as FieldDefault }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributeKeys", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -203,7 +203,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, attributes: { name: "attributes", @@ -221,7 +221,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("key"), ExpressionUtils.field("environmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -235,8 +235,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userId: { name: "userId", @@ -246,19 +246,19 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "contacts", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -266,7 +266,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, responses: { name: "responses", @@ -289,7 +289,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -302,32 +302,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, 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: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, finished: { name: "finished", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "responses", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -335,13 +335,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, contact: { name: "contact", type: "Contact", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "responses", fields: ["contactId"], references: ["id"], onDelete: "Cascade" } }, contactId: { @@ -350,7 +350,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "contact" - ] + ] as readonly string[] }, endingId: { name: "endingId", @@ -366,26 +366,26 @@ export class SchemaType implements SchemaDef { data: { name: "data", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, variables: { name: "variables", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, ttc: { name: "ttc", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, meta: { name: "meta", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, tags: { name: "tags", @@ -419,16 +419,16 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "display" - ] + ] as readonly string[] }, display: { name: "display", type: "Display", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("displayId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("displayId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "response", fields: ["displayId"], references: ["id"] } } }, @@ -438,7 +438,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId"), ExpressionUtils.field("createdAt")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId"), ExpressionUtils.field("createdAt")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -453,25 +453,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, response: { name: "response", type: "Response", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "notes", fields: ["responseId"], references: ["id"], onDelete: "Cascade" } }, responseId: { @@ -479,12 +479,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "response" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "responseNotes", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -492,7 +492,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, text: { name: "text", @@ -501,19 +501,19 @@ export class SchemaType implements SchemaDef { isResolved: { name: "isResolved", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isEdited: { name: "isEdited", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -526,20 +526,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -556,19 +556,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tags", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("name")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -584,12 +584,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "response" - ] + ] as readonly string[] }, response: { name: "response", type: "Response", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tags", fields: ["responseId"], references: ["id"], onDelete: "Cascade" } }, tagId: { @@ -598,19 +598,19 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "tag" - ] + ] as readonly string[] }, tag: { name: "tag", type: "Tag", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tagId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tagId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "responses", fields: ["tagId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId"), ExpressionUtils.field("tagId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["responseId", "tagId"], uniqueFields: { responseId_tagId: { responseId: { type: "String" }, tagId: { type: "String" } } @@ -623,25 +623,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "displays", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -649,13 +649,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, contact: { name: "contact", type: "Contact", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "displays", fields: ["contactId"], references: ["id"], onDelete: "Cascade" } }, contactId: { @@ -664,14 +664,14 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "contact" - ] + ] as readonly string[] }, responseId: { name: "responseId", type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, status: { name: "status", @@ -688,7 +688,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("contactId"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -702,25 +702,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "triggers", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -728,12 +728,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, actionClass: { name: "actionClass", type: "ActionClass", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("actionClassId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("actionClassId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "surveyTriggers", fields: ["actionClassId"], references: ["id"], onDelete: "Cascade" } }, actionClassId: { @@ -741,13 +741,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "actionClass" - ] + ] as readonly string[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId"), ExpressionUtils.field("actionClassId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -761,25 +761,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, attributeKey: { name: "attributeKey", type: "ContactAttributeKey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributeFilters", fields: ["attributeKeyId"], references: ["id"], onDelete: "Cascade" } }, attributeKeyId: { @@ -787,12 +787,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attributeKey" - ] + ] as readonly string[] }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attributeFilters", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -800,7 +800,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, condition: { name: "condition", @@ -815,7 +815,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId"), ExpressionUtils.field("attributeKeyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attributeKeyId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -829,20 +829,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -856,13 +856,13 @@ export class SchemaType implements SchemaDef { type: { name: "type", type: "SurveyType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("web") }] }], - default: "web" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("web") }] }] as readonly AttributeApplication[], + default: "web" as FieldDefault }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "surveys", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -870,13 +870,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, creator: { name: "creator", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdBy")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("createdBy")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "surveys", fields: ["createdBy"], references: ["id"] } }, createdBy: { @@ -885,32 +885,32 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "creator" - ] + ] as readonly string[] }, status: { name: "status", type: "SurveyStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("draft") }] }], - default: "draft" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("draft") }] }] as readonly AttributeApplication[], + default: "draft" as FieldDefault }, welcomeCard: { name: "welcomeCard", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false}") }] }], - default: "{\"enabled\": false}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false}") }] }] as readonly AttributeApplication[], + default: "{\"enabled\": false}" as FieldDefault }, questions: { name: "questions", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }], - default: "[]" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }] as readonly AttributeApplication[], + default: "[]" as FieldDefault }, endings: { name: "endings", type: "Json", array: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }], - default: [] + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }] as readonly AttributeApplication[], + default: [] as FieldDefault }, thankYouCard: { name: "thankYouCard", @@ -920,14 +920,14 @@ export class SchemaType implements SchemaDef { hiddenFields: { name: "hiddenFields", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false}") }] }], - default: "{\"enabled\": false}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false}") }] }] as readonly AttributeApplication[], + default: "{\"enabled\": false}" as FieldDefault }, variables: { name: "variables", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }], - default: "[]" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }] as readonly AttributeApplication[], + default: "[]" as FieldDefault }, responses: { name: "responses", @@ -938,8 +938,8 @@ export class SchemaType implements SchemaDef { displayOption: { name: "displayOption", type: "displayOptions", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("displayOnce") }] }], - default: "displayOnce" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("displayOnce") }] }] as readonly AttributeApplication[], + default: "displayOnce" as FieldDefault }, recontactDays: { name: "recontactDays", @@ -987,8 +987,8 @@ export class SchemaType implements SchemaDef { delay: { name: "delay", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, runOnDate: { name: "runOnDate", @@ -1011,13 +1011,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "segment" - ] + ] as readonly string[] }, segment: { name: "segment", type: "Segment", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("segmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("segmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "surveys", fields: ["segmentId"], references: ["id"] } }, projectOverwrites: { @@ -1034,8 +1034,8 @@ export class SchemaType implements SchemaDef { name: "singleUse", type: "Json", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false, \"isEncrypted\": true}") }] }], - default: "{\"enabled\": false, \"isEncrypted\": true}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false, \"isEncrypted\": true}") }] }] as readonly AttributeApplication[], + default: "{\"enabled\": false, \"isEncrypted\": true}" as FieldDefault }, verifyEmail: { name: "verifyEmail", @@ -1045,20 +1045,20 @@ export class SchemaType implements SchemaDef { isVerifyEmailEnabled: { name: "isVerifyEmailEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isSingleResponsePerEmailEnabled: { name: "isSingleResponsePerEmailEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isBackButtonHidden: { name: "isBackButtonHidden", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, pin: { name: "pin", @@ -1070,7 +1070,7 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, displayPercentage: { name: "displayPercentage", @@ -1104,14 +1104,14 @@ export class SchemaType implements SchemaDef { name: "recaptcha", type: "Json", optional: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false, \"threshold\":0.1}") }] }], - default: "{\"enabled\": false, \"threshold\":0.1}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"enabled\": false, \"threshold\":0.1}") }] }] as readonly AttributeApplication[], + default: "{\"enabled\": false, \"threshold\":0.1}" as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("updatedAt")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("segmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1125,25 +1125,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "followUps", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -1151,7 +1151,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, name: { name: "name", @@ -1178,20 +1178,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -1219,7 +1219,7 @@ export class SchemaType implements SchemaDef { environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "actionClasses", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -1227,7 +1227,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, surveyTriggers: { name: "surveyTriggers", @@ -1240,7 +1240,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("key"), ExpressionUtils.field("environmentId")]) }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("name"), ExpressionUtils.field("environmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1255,8 +1255,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", @@ -1267,7 +1267,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, config: { name: "config", @@ -1276,14 +1276,14 @@ export class SchemaType implements SchemaDef { environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "integration", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("IntegrationType", [ExpressionUtils.field("type"), ExpressionUtils.field("environmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1297,26 +1297,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, startedAt: { name: "startedAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("started_at") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("started_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, finishedAt: { name: "finishedAt", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("finished_at") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("finished_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, status: { name: "status", @@ -1336,20 +1336,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, type: { name: "type", @@ -1358,7 +1358,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environments", fields: ["projectId"], references: ["id"], onDelete: "Cascade" } }, projectId: { @@ -1366,19 +1366,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, widgetSetupCompleted: { name: "widgetSetupCompleted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, appSetupCompleted: { name: "appSetupCompleted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, surveys: { name: "surveys", @@ -1449,7 +1449,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1462,20 +1462,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -1484,7 +1484,7 @@ export class SchemaType implements SchemaDef { organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "projects", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, organizationId: { @@ -1492,7 +1492,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, environments: { name: "environments", @@ -1513,50 +1513,50 @@ export class SchemaType implements SchemaDef { styling: { name: "styling", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"allowStyleOverwrite\":true}") }] }], - default: "{\"allowStyleOverwrite\":true}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{\"allowStyleOverwrite\":true}") }] }] as readonly AttributeApplication[], + default: "{\"allowStyleOverwrite\":true}" as FieldDefault }, config: { name: "config", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, recontactDays: { name: "recontactDays", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(7) }] }], - default: 7 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(7) }] }] as readonly AttributeApplication[], + default: 7 as FieldDefault }, linkSurveyBranding: { name: "linkSurveyBranding", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, inAppSurveyBranding: { name: "inAppSurveyBranding", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, placement: { name: "placement", type: "WidgetPlacement", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("bottomRight") }] }], - default: "bottomRight" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("bottomRight") }] }] as readonly AttributeApplication[], + default: "bottomRight" as FieldDefault }, clickOutsideClose: { name: "clickOutsideClose", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, darkOverlay: { name: "darkOverlay", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, languages: { name: "languages", @@ -1579,7 +1579,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("name")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1593,20 +1593,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -1631,8 +1631,8 @@ export class SchemaType implements SchemaDef { whitelabel: { name: "whitelabel", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, invites: { name: "invites", @@ -1643,8 +1643,8 @@ export class SchemaType implements SchemaDef { isAIEnabled: { name: "isAIEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, teams: { name: "teams", @@ -1670,7 +1670,7 @@ export class SchemaType implements SchemaDef { organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "memberships", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, organizationId: { @@ -1679,12 +1679,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "memberships", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -1693,13 +1693,13 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, accepted: { name: "accepted", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, deprecatedRole: { name: "deprecatedRole", @@ -1709,15 +1709,15 @@ export class SchemaType implements SchemaDef { role: { name: "role", type: "OrganizationRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("member") }] }], - default: "member" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("member") }] }] as readonly AttributeApplication[], + default: "member" as FieldDefault } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId"), ExpressionUtils.field("organizationId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["organizationId", "userId"], uniqueFields: { userId_organizationId: { userId: { type: "String" }, organizationId: { type: "String" } } @@ -1730,8 +1730,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }], - default: ExpressionUtils.call("uuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("uuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("uuid") as FieldDefault }, email: { name: "email", @@ -1745,7 +1745,7 @@ export class SchemaType implements SchemaDef { organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "invites", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, organizationId: { @@ -1753,12 +1753,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, creator: { name: "creator", type: "User", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteCreatedBy") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creatorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteCreatedBy") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("creatorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "invitesCreated", name: "inviteCreatedBy", fields: ["creatorId"], references: ["id"] } }, creatorId: { @@ -1766,13 +1766,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "creator" - ] + ] as readonly string[] }, acceptor: { name: "acceptor", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteAcceptedBy") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("acceptorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteAcceptedBy") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("acceptorId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "invitesAccepted", name: "inviteAcceptedBy", fields: ["acceptorId"], references: ["id"], onDelete: "Cascade" } }, acceptorId: { @@ -1781,13 +1781,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "acceptor" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, expiresAt: { name: "expiresAt", @@ -1801,21 +1801,21 @@ export class SchemaType implements SchemaDef { role: { name: "role", type: "OrganizationRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("member") }] }], - default: "member" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("member") }] }] as readonly AttributeApplication[], + default: "member" as FieldDefault }, teamIds: { name: "teamIds", type: "String", array: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }], - default: [] + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }] as readonly AttributeApplication[], + default: [] as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("email"), ExpressionUtils.field("organizationId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -1828,14 +1828,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, createdBy: { name: "createdBy", @@ -1855,19 +1855,19 @@ export class SchemaType implements SchemaDef { name: "hashedKey", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, organizationId: { name: "organizationId", type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "apiKeys", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, apiKeyEnvironments: { @@ -1879,13 +1879,13 @@ export class SchemaType implements SchemaDef { organizationAccess: { name: "organizationAccess", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1899,32 +1899,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, apiKeyId: { name: "apiKeyId", type: "String", foreignKeyFor: [ "apiKey" - ] + ] as readonly string[] }, apiKey: { name: "apiKey", type: "ApiKey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "apiKeyEnvironments", fields: ["apiKeyId"], references: ["id"], onDelete: "Cascade" } }, environmentId: { @@ -1932,12 +1932,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "ApiKeyEnvironment", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, permission: { @@ -1948,7 +1948,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("apiKeyId"), ExpressionUtils.field("environmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1962,26 +1962,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "accounts", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -1989,7 +1989,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, type: { name: "type", @@ -2007,13 +2007,13 @@ export class SchemaType implements SchemaDef { name: "access_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, refresh_token: { name: "refresh_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, expires_at: { name: "expires_at", @@ -2039,7 +2039,7 @@ export class SchemaType implements SchemaDef { name: "id_token", type: "String", optional: true, - attributes: [{ name: "@db.Text" }] + attributes: [{ name: "@db.Text" }] as readonly AttributeApplication[] }, session_state: { name: "session_state", @@ -2050,7 +2050,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("provider"), ExpressionUtils.field("providerAccountId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2064,20 +2064,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -2087,13 +2087,13 @@ export class SchemaType implements SchemaDef { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, emailVerified: { name: "emailVerified", type: "DateTime", optional: true, - attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("email_verified") }] }] + attributes: [{ name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("email_verified") }] }] as readonly AttributeApplication[] }, imageUrl: { name: "imageUrl", @@ -2108,8 +2108,8 @@ export class SchemaType implements SchemaDef { twoFactorEnabled: { name: "twoFactorEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, backupCodes: { name: "backupCodes", @@ -2124,8 +2124,8 @@ export class SchemaType implements SchemaDef { identityProvider: { name: "identityProvider", type: "IdentityProvider", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("email") }] }], - default: "email" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("email") }] }] as readonly AttributeApplication[], + default: "email" as FieldDefault }, identityProviderAccountId: { name: "identityProviderAccountId", @@ -2159,14 +2159,14 @@ export class SchemaType implements SchemaDef { name: "invitesCreated", type: "Invite", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteCreatedBy") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteCreatedBy") }] }] as readonly AttributeApplication[], relation: { opposite: "creator", name: "inviteCreatedBy" } }, invitesAccepted: { name: "invitesAccepted", type: "Invite", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteAcceptedBy") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("inviteAcceptedBy") }] }] as readonly AttributeApplication[], relation: { opposite: "acceptor", name: "inviteAcceptedBy" } }, role: { @@ -2182,14 +2182,14 @@ export class SchemaType implements SchemaDef { notificationSettings: { name: "notificationSettings", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }], - default: "{}" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("{}") }] }] as readonly AttributeApplication[], + default: "{}" as FieldDefault }, locale: { name: "locale", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("en-US") }] }], - default: "en-US" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("en-US") }] }] as readonly AttributeApplication[], + default: "en-US" as FieldDefault }, surveys: { name: "surveys", @@ -2211,13 +2211,13 @@ export class SchemaType implements SchemaDef { isActive: { name: "isActive", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("email")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2231,25 +2231,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, url: { name: "url", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -2265,20 +2265,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, title: { name: "title", @@ -2292,26 +2292,26 @@ export class SchemaType implements SchemaDef { isPrivate: { name: "isPrivate", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, filters: { name: "filters", type: "Json", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }], - default: "[]" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("[]") }] }] as readonly AttributeApplication[], + default: "[]" as FieldDefault }, environmentId: { name: "environmentId", type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "segments", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, surveys: { @@ -2324,7 +2324,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("title")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2338,20 +2338,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, code: { name: "code", @@ -2365,7 +2365,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "languages", fields: ["projectId"], references: ["id"], onDelete: "Cascade" } }, projectId: { @@ -2373,7 +2373,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, surveyLanguages: { name: "surveyLanguages", @@ -2384,7 +2384,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("code")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2397,7 +2397,7 @@ export class SchemaType implements SchemaDef { language: { name: "language", type: "Language", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("languageId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("languageId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "surveyLanguages", fields: ["languageId"], references: ["id"], onDelete: "Cascade" } }, languageId: { @@ -2406,7 +2406,7 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "language" - ] + ] as readonly string[] }, surveyId: { name: "surveyId", @@ -2414,32 +2414,32 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, survey: { name: "survey", type: "Survey", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "languages", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, default: { name: "default", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("languageId"), ExpressionUtils.field("surveyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("languageId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["languageId", "surveyId"], uniqueFields: { languageId_surveyId: { languageId: { type: "String" }, surveyId: { type: "String" } } @@ -2452,32 +2452,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, environmentId: { name: "environmentId", type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "insights", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, category: { @@ -2518,12 +2518,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "document" - ] + ] as readonly string[] }, document: { name: "document", type: "Document", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("documentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("documentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "documentInsights", fields: ["documentId"], references: ["id"], onDelete: "Cascade" } }, insightId: { @@ -2532,19 +2532,19 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "insight" - ] + ] as readonly string[] }, insight: { name: "insight", type: "Insight", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("insightId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("insightId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "documentInsights", fields: ["insightId"], references: ["id"], onDelete: "Cascade" } } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("documentId"), ExpressionUtils.field("insightId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("insightId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["documentId", "insightId"], uniqueFields: { documentId_insightId: { documentId: { type: "String" }, insightId: { type: "String" } } @@ -2557,32 +2557,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, environmentId: { name: "environmentId", type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "Environment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "documents", fields: ["environmentId"], references: ["id"], onDelete: "Cascade" } }, surveyId: { @@ -2591,13 +2591,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "survey" - ] + ] as readonly string[] }, survey: { name: "survey", type: "Survey", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("surveyId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "documents", fields: ["surveyId"], references: ["id"], onDelete: "Cascade" } }, responseId: { @@ -2606,13 +2606,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "response" - ] + ] as readonly string[] }, response: { name: "response", type: "Response", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "documents", fields: ["responseId"], references: ["id"], onDelete: "Cascade" } }, questionId: { @@ -2647,7 +2647,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("responseId"), ExpressionUtils.field("questionId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2661,20 +2661,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, name: { name: "name", @@ -2685,12 +2685,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teams", fields: ["organizationId"], references: ["id"], onDelete: "Cascade" } }, teamUsers: { @@ -2708,7 +2708,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("name")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2721,14 +2721,14 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, teamId: { name: "teamId", @@ -2736,12 +2736,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teamUsers", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, userId: { @@ -2750,12 +2750,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "user" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "teamUsers", fields: ["userId"], references: ["id"], onDelete: "Cascade" } }, role: { @@ -2766,7 +2766,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId"), ExpressionUtils.field("userId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["teamId", "userId"], uniqueFields: { teamId_userId: { teamId: { type: "String" }, userId: { type: "String" } } @@ -2778,14 +2778,14 @@ export class SchemaType implements SchemaDef { 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") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("created_at") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] + attributes: [{ name: "@updatedAt" }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("updated_at") }] }] as readonly AttributeApplication[] }, projectId: { name: "projectId", @@ -2793,12 +2793,12 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "project" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "projectTeams", fields: ["projectId"], references: ["id"], onDelete: "Cascade" } }, teamId: { @@ -2807,25 +2807,25 @@ export class SchemaType implements SchemaDef { id: true, foreignKeyFor: [ "team" - ] + ] as readonly string[] }, team: { name: "team", type: "Team", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "projectTeams", fields: ["teamId"], references: ["id"], onDelete: "Cascade" } }, permission: { name: "permission", type: "ProjectTeamPermission", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("read") }] }], - default: "read" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("read") }] }] as readonly AttributeApplication[], + default: "read" as FieldDefault } }, attributes: [ { name: "@@id", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("teamId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("teamId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["projectId", "teamId"], uniqueFields: { projectId_teamId: { projectId: { type: "String" }, teamId: { type: "String" } } diff --git a/tests/e2e/github-repos/trigger.dev/schema.ts b/tests/e2e/github-repos/trigger.dev/schema.ts index 4e4156b9f..547121089 100644 --- a/tests/e2e/github-repos/trigger.dev/schema.ts +++ b/tests/e2e/github-repos/trigger.dev/schema.ts @@ -5,7 +5,7 @@ /* eslint-disable */ -import { type SchemaDef, ExpressionUtils } from "@zenstackhq/schema"; +import { type SchemaDef, type AttributeApplication, type FieldDefault, ExpressionUtils } from "@zenstackhq/schema"; export class SchemaType implements SchemaDef { provider = { type: "postgresql" @@ -18,14 +18,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, email: { name: "email", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, authenticationMethod: { name: "authenticationMethod", @@ -46,7 +46,7 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, displayName: { name: "displayName", @@ -66,8 +66,8 @@ export class SchemaType implements SchemaDef { admin: { name: "admin", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, dashboardPreferences: { name: "dashboardPreferences", @@ -77,44 +77,44 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, isOnCloudWaitlist: { name: "isOnCloudWaitlist", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, featureCloud: { name: "featureCloud", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isOnHostedRepoWaitlist: { name: "isOnHostedRepoWaitlist", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, marketingEmails: { name: "marketingEmails", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, confirmedBasicDetails: { name: "confirmedBasicDetails", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, referralSource: { name: "referralSource", @@ -137,7 +137,7 @@ export class SchemaType implements SchemaDef { name: "invitationCode", type: "InvitationCode", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("invitationCodeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("invitationCodeId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "users", fields: ["invitationCodeId"], references: ["id"] } }, invitationCodeId: { @@ -146,7 +146,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "invitationCode" - ] + ] as readonly string[] }, personalAccessTokens: { name: "personalAccessTokens", @@ -175,14 +175,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, code: { name: "code", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, users: { name: "users", @@ -193,8 +193,8 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, idFields: ["id"], @@ -210,20 +210,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, code: { name: "code", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, personalAccessToken: { name: "personalAccessToken", type: "PersonalAccessToken", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("personalAccessTokenId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("personalAccessTokenId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "authorizationCodes", fields: ["personalAccessTokenId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, personalAccessTokenId: { @@ -232,19 +232,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "personalAccessToken" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -260,8 +260,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -279,12 +279,12 @@ export class SchemaType implements SchemaDef { name: "hashedToken", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "personalAccessTokens", fields: ["userId"], references: ["id"] } }, userId: { @@ -292,7 +292,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, revokedAt: { name: "revokedAt", @@ -307,14 +307,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, authorizationCodes: { name: "authorizationCodes", @@ -336,14 +336,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, slug: { name: "slug", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, title: { name: "title", @@ -352,20 +352,20 @@ export class SchemaType implements SchemaDef { maximumExecutionTimePerRunInMs: { name: "maximumExecutionTimePerRunInMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(900000) }] }], - default: 900000 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(900000) }] }] as readonly AttributeApplication[], + default: 900000 as FieldDefault }, maximumConcurrencyLimit: { name: "maximumConcurrencyLimit", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(10) }] }], - default: 10 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(10) }] }] as readonly AttributeApplication[], + default: 10 as FieldDefault }, maximumSchedulesLimit: { name: "maximumSchedulesLimit", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(5) }] }], - default: 5 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(5) }] }] as readonly AttributeApplication[], + default: 5 as FieldDefault }, maximumDevQueueSize: { name: "maximumDevQueueSize", @@ -380,14 +380,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, deletedAt: { name: "deletedAt", @@ -407,32 +407,32 @@ export class SchemaType implements SchemaDef { runsEnabled: { name: "runsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, v3Enabled: { name: "v3Enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, v2Enabled: { name: "v2Enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, v2MarqsEnabled: { name: "v2MarqsEnabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, hasRequestedV3: { name: "hasRequestedV3", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, environments: { name: "environments", @@ -506,13 +506,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "members", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -520,12 +520,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, user: { name: "user", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "orgMemberships", fields: ["userId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, userId: { @@ -533,25 +533,25 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "user" - ] + ] as readonly string[] }, role: { name: "role", type: "OrgMemberRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], - default: "MEMBER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }] as readonly AttributeApplication[], + default: "MEMBER" as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, environments: { name: "environments", @@ -562,7 +562,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("userId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -576,15 +576,15 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, token: { name: "token", type: "String", unique: true, - attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@unique" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, email: { name: "email", @@ -593,13 +593,13 @@ export class SchemaType implements SchemaDef { role: { name: "role", type: "OrgMemberRole", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }], - default: "MEMBER" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("MEMBER") }] }] as readonly AttributeApplication[], + default: "MEMBER" as FieldDefault }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "invites", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -607,12 +607,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, inviter: { name: "inviter", type: "User", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviterId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("inviterId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "sentInvites", fields: ["inviterId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, inviterId: { @@ -620,24 +620,24 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "inviter" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId"), ExpressionUtils.field("email")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -652,8 +652,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, slug: { name: "slug", @@ -663,25 +663,25 @@ export class SchemaType implements SchemaDef { name: "apiKey", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, pkApiKey: { name: "pkApiKey", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, type: { name: "type", type: "RuntimeEnvironmentType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("DEVELOPMENT") }] }], - default: "DEVELOPMENT" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("DEVELOPMENT") }] }] as readonly AttributeApplication[], + default: "DEVELOPMENT" as FieldDefault }, isBranchableEnvironment: { name: "isBranchableEnvironment", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, branchName: { name: "branchName", @@ -692,7 +692,7 @@ export class SchemaType implements SchemaDef { name: "parentEnvironment", type: "RuntimeEnvironment", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("parentEnvironment") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("parentEnvironment") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "childEnvironments", name: "parentEnvironment", fields: ["parentEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, parentEnvironmentId: { @@ -701,13 +701,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "parentEnvironment" - ] + ] as readonly string[] }, childEnvironments: { name: "childEnvironments", type: "RuntimeEnvironment", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("parentEnvironment") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("parentEnvironment") }] }] as readonly AttributeApplication[], relation: { opposite: "parentEnvironment", name: "parentEnvironment" } }, git: { @@ -727,25 +727,25 @@ export class SchemaType implements SchemaDef { maximumConcurrencyLimit: { name: "maximumConcurrencyLimit", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(5) }] }], - default: 5 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(5) }] }] as readonly AttributeApplication[], + default: 5 as FieldDefault }, paused: { name: "paused", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, autoEnableInternalSources: { name: "autoEnableInternalSources", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environments", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -753,12 +753,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environments", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -766,13 +766,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, orgMember: { name: "orgMember", type: "OrgMember", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("orgMemberId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("orgMemberId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environments", fields: ["orgMemberId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, orgMemberId: { @@ -781,19 +781,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "orgMember" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, tunnelId: { name: "tunnelId", @@ -888,7 +888,7 @@ export class SchemaType implements SchemaDef { name: "currentSession", type: "RuntimeEnvironmentSession", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("currentSession") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("currentSessionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("currentSession") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("currentSessionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "currentEnvironments", name: "currentSession", fields: ["currentSessionId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, currentSessionId: { @@ -897,7 +897,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "currentSession" - ] + ] as readonly string[] }, taskRunNumberCounter: { name: "taskRunNumberCounter", @@ -941,7 +941,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("shortcode")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentEnvironmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -958,14 +958,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, slug: { name: "slug", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -975,12 +975,12 @@ export class SchemaType implements SchemaDef { name: "externalRef", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "projects", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -988,19 +988,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, deletedAt: { name: "deletedAt", @@ -1010,14 +1010,14 @@ export class SchemaType implements SchemaDef { version: { name: "version", type: "ProjectVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V2") }] }], - default: "V2" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V2") }] }] as readonly AttributeApplication[], + default: "V2" as FieldDefault }, engine: { name: "engine", type: "RunEngineVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }], - default: "V1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }] as readonly AttributeApplication[], + default: "V1" as FieldDefault }, builderProjectId: { name: "builderProjectId", @@ -1040,7 +1040,7 @@ export class SchemaType implements SchemaDef { name: "defaultWorkerGroup", type: "WorkerInstanceGroup", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ProjectDefaultWorkerGroup") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("defaultWorkerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ProjectDefaultWorkerGroup") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("defaultWorkerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "defaultForProjects", name: "ProjectDefaultWorkerGroup", fields: ["defaultWorkerGroupId"], references: ["id"] } }, defaultWorkerGroupId: { @@ -1049,7 +1049,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "defaultWorkerGroup" - ] + ] as readonly string[] }, environments: { name: "environments", @@ -1192,20 +1192,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, key: { name: "key", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, provider: { name: "provider", type: "SecretStoreProvider", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("DATABASE") }] }], - default: "DATABASE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("DATABASE") }] }] as readonly AttributeApplication[], + default: "DATABASE" as FieldDefault }, environmentVariableValues: { name: "environmentVariableValues", @@ -1216,14 +1216,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, OrganizationIntegration: { name: "OrganizationIntegration", @@ -1246,7 +1246,7 @@ export class SchemaType implements SchemaDef { type: "String", id: true, unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, value: { name: "value", @@ -1255,25 +1255,25 @@ export class SchemaType implements SchemaDef { version: { name: "version", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("1") }] }], - default: "1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("1") }] }] as readonly AttributeApplication[], + default: "1" as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("key")]) }, { name: "type", value: ExpressionUtils.literal("BTree") }] } - ], + ] as readonly AttributeApplication[], idFields: ["key"], uniqueFields: { key: { type: "String" } @@ -1286,26 +1286,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, completedAt: { name: "completedAt", @@ -1326,20 +1326,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, engine: { name: "engine", type: "RunEngineVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }], - default: "V1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }] as readonly AttributeApplication[], + default: "V1" as FieldDefault }, contentHash: { name: "contentHash", @@ -1348,19 +1348,19 @@ export class SchemaType implements SchemaDef { sdkVersion: { name: "sdkVersion", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("unknown") }] }], - default: "unknown" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("unknown") }] }] as readonly AttributeApplication[], + default: "unknown" as FieldDefault }, cliVersion: { name: "cliVersion", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("unknown") }] }], - default: "unknown" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("unknown") }] }] as readonly AttributeApplication[], + default: "unknown" as FieldDefault }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "backgroundWorkers", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -1368,12 +1368,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "backgroundWorkers", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -1381,7 +1381,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, version: { name: "version", @@ -1394,14 +1394,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, tasks: { name: "tasks", @@ -1443,7 +1443,7 @@ export class SchemaType implements SchemaDef { name: "workerGroup", type: "WorkerInstanceGroup", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "backgroundWorkers", fields: ["workerGroupId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, workerGroupId: { @@ -1452,20 +1452,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "workerGroup" - ] + ] as readonly string[] }, supportsLazyAttempts: { name: "supportsLazyAttempts", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("version")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1480,14 +1480,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, filePath: { name: "filePath", @@ -1504,7 +1504,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "BackgroundWorkerFile", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -1512,7 +1512,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, backgroundWorkers: { name: "backgroundWorkers", @@ -1529,13 +1529,13 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("contentHash")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1550,8 +1550,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, slug: { name: "slug", @@ -1566,7 +1566,7 @@ export class SchemaType implements SchemaDef { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, filePath: { name: "filePath", @@ -1580,7 +1580,7 @@ export class SchemaType implements SchemaDef { worker: { name: "worker", type: "BackgroundWorker", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tasks", fields: ["workerId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, workerId: { @@ -1588,12 +1588,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "worker" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "backgroundWorkerTasks", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -1601,13 +1601,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, file: { name: "file", type: "BackgroundWorkerFile", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("fileId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("fileId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tasks", fields: ["fileId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, fileId: { @@ -1616,12 +1616,12 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "file" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "backgroundWorkerTasks", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -1629,19 +1629,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, attempts: { name: "attempts", @@ -1676,13 +1676,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "queue" - ] + ] as readonly string[] }, queue: { name: "queue", type: "TaskQueue", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("queueId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("queueId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "tasks", fields: ["queueId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, maxDurationInSeconds: { @@ -1693,15 +1693,15 @@ export class SchemaType implements SchemaDef { triggerSource: { name: "triggerSource", type: "TaskTriggerSource", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("STANDARD") }] }], - default: "STANDARD" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("STANDARD") }] }] as readonly AttributeApplication[], + default: "STANDARD" as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId"), ExpressionUtils.field("slug")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("slug")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("projectId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -1716,32 +1716,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, number: { name: "number", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, engine: { name: "engine", type: "RunEngineVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }], - default: "V1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }] as readonly AttributeApplication[], + default: "V1" as FieldDefault }, status: { name: "status", type: "TaskRunStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, statusReason: { name: "statusReason", @@ -1765,8 +1765,8 @@ export class SchemaType implements SchemaDef { isTest: { name: "isTest", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, payload: { name: "payload", @@ -1775,8 +1775,8 @@ export class SchemaType implements SchemaDef { payloadType: { name: "payloadType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, context: { name: "context", @@ -1799,7 +1799,7 @@ export class SchemaType implements SchemaDef { runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRuns", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -1807,7 +1807,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, environmentType: { name: "environmentType", @@ -1817,7 +1817,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRuns", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -1825,7 +1825,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, organizationId: { name: "organizationId", @@ -1844,8 +1844,8 @@ export class SchemaType implements SchemaDef { workerQueue: { name: "workerQueue", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("main") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("masterQueue") }] }], - default: "main" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("main") }] }, { name: "@map", args: [{ name: "name", value: ExpressionUtils.literal("masterQueue") }] }] as readonly AttributeApplication[], + default: "main" as FieldDefault }, secondaryMasterQueue: { name: "secondaryMasterQueue", @@ -1860,20 +1860,20 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, attempts: { name: "attempts", type: "TaskRunAttempt", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("attempts") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("attempts") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRun", name: "attempts" } }, tags: { @@ -1931,20 +1931,20 @@ export class SchemaType implements SchemaDef { usageDurationMs: { name: "usageDurationMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, costInCents: { name: "costInCents", type: "Float", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, baseCostInCents: { name: "baseCostInCents", type: "Float", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, lockedAt: { name: "lockedAt", @@ -1955,7 +1955,7 @@ export class SchemaType implements SchemaDef { name: "lockedBy", type: "BackgroundWorkerTask", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("lockedById")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("lockedById")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "runs", fields: ["lockedById"], references: ["id"] } }, lockedById: { @@ -1964,13 +1964,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "lockedBy" - ] + ] as readonly string[] }, lockedToVersion: { name: "lockedToVersion", type: "BackgroundWorker", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("lockedToVersionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("lockedToVersionId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "lockedRuns", fields: ["lockedToVersionId"], references: ["id"] } }, lockedToVersionId: { @@ -1979,13 +1979,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "lockedToVersion" - ] + ] as readonly string[] }, priorityMs: { name: "priorityMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, concurrencyKey: { name: "concurrencyKey", @@ -2026,7 +2026,7 @@ export class SchemaType implements SchemaDef { name: "associatedWaitpoint", type: "Waitpoint", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CompletingRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CompletingRun") }] }] as readonly AttributeApplication[], relation: { opposite: "completedByTaskRun", name: "CompletingRun" } }, blockedByWaitpoints: { @@ -2039,14 +2039,14 @@ export class SchemaType implements SchemaDef { name: "connectedWaitpoints", type: "Waitpoint", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("WaitpointRunConnections") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("WaitpointRunConnections") }] }] as readonly AttributeApplication[], relation: { opposite: "connectedRuns", name: "WaitpointRunConnections" } }, taskEventStore: { name: "taskEventStore", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("taskEvent") }] }], - default: "taskEvent" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("taskEvent") }] }] as readonly AttributeApplication[], + default: "taskEvent" as FieldDefault }, queueTimestamp: { name: "queueTimestamp", @@ -2097,14 +2097,14 @@ export class SchemaType implements SchemaDef { name: "sourceBulkActionItems", type: "BulkActionItem", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SourceActionItemRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SourceActionItemRun") }] }] as readonly AttributeApplication[], relation: { opposite: "sourceRun", name: "SourceActionItemRun" } }, destinationBulkActionItems: { name: "destinationBulkActionItems", type: "BulkActionItem", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DestinationActionItemRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DestinationActionItemRun") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationRun", name: "DestinationActionItemRun" } }, logsDeletedAt: { @@ -2116,7 +2116,7 @@ export class SchemaType implements SchemaDef { name: "rootTaskRun", type: "TaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskRootRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("rootTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskRootRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("rootTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }] as readonly AttributeApplication[], relation: { opposite: "descendantRuns", name: "TaskRootRun", fields: ["rootTaskRunId"], references: ["id"], onDelete: "SetNull", onUpdate: "NoAction" } }, rootTaskRunId: { @@ -2125,20 +2125,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "rootTaskRun" - ] + ] as readonly string[] }, descendantRuns: { name: "descendantRuns", type: "TaskRun", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskRootRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskRootRun") }] }] as readonly AttributeApplication[], relation: { opposite: "rootTaskRun", name: "TaskRootRun" } }, parentTaskRun: { name: "parentTaskRun", type: "TaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }] as readonly AttributeApplication[], relation: { opposite: "childRuns", name: "TaskParentRun", fields: ["parentTaskRunId"], references: ["id"], onDelete: "SetNull", onUpdate: "NoAction" } }, parentTaskRunId: { @@ -2147,20 +2147,20 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "parentTaskRun" - ] + ] as readonly string[] }, childRuns: { name: "childRuns", type: "TaskRun", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRun") }] }] as readonly AttributeApplication[], relation: { opposite: "parentTaskRun", name: "TaskParentRun" } }, parentTaskRunAttempt: { name: "parentTaskRunAttempt", type: "TaskRunAttempt", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRunAttempt") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentTaskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRunAttempt") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("parentTaskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }] as readonly AttributeApplication[], relation: { opposite: "childRuns", name: "TaskParentRunAttempt", fields: ["parentTaskRunAttemptId"], references: ["id"], onDelete: "SetNull", onUpdate: "NoAction" } }, parentTaskRunAttemptId: { @@ -2169,13 +2169,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "parentTaskRunAttempt" - ] + ] as readonly string[] }, batch: { name: "batch", type: "BatchTaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("NoAction") }] }] as readonly AttributeApplication[], relation: { opposite: "runs", fields: ["batchId"], references: ["id"], onDelete: "SetNull", onUpdate: "NoAction" } }, batchId: { @@ -2184,19 +2184,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "batch" - ] + ] as readonly string[] }, resumeParentOnCompletion: { name: "resumeParentOnCompletion", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, depth: { name: "depth", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, parentSpanId: { name: "parentSpanId", @@ -2216,8 +2216,8 @@ export class SchemaType implements SchemaDef { seedMetadataType: { name: "seedMetadataType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, metadata: { name: "metadata", @@ -2227,14 +2227,14 @@ export class SchemaType implements SchemaDef { metadataType: { name: "metadataType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, metadataVersion: { name: "metadataVersion", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }], - default: 1 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(1) }] }] as readonly AttributeApplication[], + default: 1 as FieldDefault }, output: { name: "output", @@ -2244,8 +2244,8 @@ export class SchemaType implements SchemaDef { outputType: { name: "outputType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, error: { name: "error", @@ -2273,7 +2273,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("createdAt")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("createdAt")]) }, { name: "type", value: ExpressionUtils.literal("Brin") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("TaskRunStatus", [ExpressionUtils.field("status"), ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("createdAt"), ExpressionUtils.field("id")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2289,14 +2289,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, engine: { name: "engine", type: "RunEngineVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V2") }] }], - default: "V2" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V2") }] }] as readonly AttributeApplication[], + default: "V2" as FieldDefault }, executionStatus: { name: "executionStatus", @@ -2309,8 +2309,8 @@ export class SchemaType implements SchemaDef { isValid: { name: "isValid", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, error: { name: "error", @@ -2327,12 +2327,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "run" - ] + ] as readonly string[] }, run: { name: "run", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshots", fields: ["runId"], references: ["id"] } }, runStatus: { @@ -2345,13 +2345,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "batch" - ] + ] as readonly string[] }, batch: { name: "batch", type: "BatchTaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshots", fields: ["batchId"], references: ["id"] } }, attemptNumber: { @@ -2364,12 +2364,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshots", fields: ["environmentId"], references: ["id"] } }, environmentType: { @@ -2381,12 +2381,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshots", fields: ["projectId"], references: ["id"] } }, organizationId: { @@ -2394,19 +2394,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshots", fields: ["organizationId"], references: ["id"] } }, completedWaitpoints: { name: "completedWaitpoints", type: "Waitpoint", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("completedWaitpoints") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("completedWaitpoints") }] }] as readonly AttributeApplication[], relation: { opposite: "completedExecutionSnapshots", name: "completedWaitpoints" } }, completedWaitpointOrder: { @@ -2420,13 +2420,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "checkpoint" - ] + ] as readonly string[] }, checkpoint: { name: "checkpoint", type: "TaskRunCheckpoint", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "executionSnapshot", fields: ["checkpointId"], references: ["id"] } }, workerId: { @@ -2435,13 +2435,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "worker" - ] + ] as readonly string[] }, worker: { name: "worker", type: "WorkerInstance", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "TaskRunExecutionSnapshot", fields: ["workerId"], references: ["id"] } }, runnerId: { @@ -2452,14 +2452,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, lastHeartbeatAt: { name: "lastHeartbeatAt", @@ -2474,7 +2474,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId"), ExpressionUtils.field("isValid"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -2487,14 +2487,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, type: { name: "type", @@ -2522,7 +2522,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunCheckpoints", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -2530,12 +2530,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunCheckpoints", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -2543,7 +2543,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, executionSnapshot: { name: "executionSnapshot", @@ -2554,14 +2554,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -2577,14 +2577,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, type: { name: "type", @@ -2593,8 +2593,8 @@ export class SchemaType implements SchemaDef { status: { name: "status", type: "WaitpointStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, completedAt: { name: "completedAt", @@ -2624,16 +2624,16 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "completedByTaskRun" - ] + ] as readonly string[] }, completedByTaskRun: { name: "completedByTaskRun", type: "TaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CompletingRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("completedByTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("CompletingRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("completedByTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "associatedWaitpoint", name: "CompletingRun", fields: ["completedByTaskRunId"], references: ["id"], onDelete: "SetNull" } }, completedAfter: { @@ -2647,13 +2647,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "completedByBatch" - ] + ] as readonly string[] }, completedByBatch: { name: "completedByBatch", type: "BatchTaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("completedByBatchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("completedByBatchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }] }] as readonly AttributeApplication[], relation: { opposite: "waitpoints", fields: ["completedByBatchId"], references: ["id"], onDelete: "SetNull" } }, blockingTaskRuns: { @@ -2666,14 +2666,14 @@ export class SchemaType implements SchemaDef { name: "connectedRuns", type: "TaskRun", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("WaitpointRunConnections") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("WaitpointRunConnections") }] }] as readonly AttributeApplication[], relation: { opposite: "connectedWaitpoints", name: "WaitpointRunConnections" } }, completedExecutionSnapshots: { name: "completedExecutionSnapshots", type: "TaskRunExecutionSnapshot", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("completedWaitpoints") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("completedWaitpoints") }] }] as readonly AttributeApplication[], relation: { opposite: "completedWaitpoints", name: "completedWaitpoints" } }, output: { @@ -2684,19 +2684,19 @@ export class SchemaType implements SchemaDef { outputType: { name: "outputType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, outputIsError: { name: "outputIsError", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "waitpoints", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -2704,12 +2704,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "waitpoints", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -2717,19 +2717,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, tags: { name: "tags", @@ -2742,7 +2742,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("completedByBatchId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("type"), ExpressionUtils.field("createdAt")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("type"), ExpressionUtils.field("status")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2758,13 +2758,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, taskRun: { name: "taskRun", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "blockedByWaitpoints", fields: ["taskRunId"], references: ["id"] } }, taskRunId: { @@ -2772,12 +2772,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "taskRun" - ] + ] as readonly string[] }, waitpoint: { name: "waitpoint", type: "Waitpoint", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("waitpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("waitpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "blockingTaskRuns", fields: ["waitpointId"], references: ["id"] } }, waitpointId: { @@ -2785,12 +2785,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "waitpoint" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunWaitpoints", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -2798,7 +2798,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, spanIdToComplete: { name: "spanIdToComplete", @@ -2811,13 +2811,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "batch" - ] + ] as readonly string[] }, batch: { name: "batch", type: "BatchTaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "runsBlocked", fields: ["batchId"], references: ["id"] } }, batchIndex: { @@ -2828,21 +2828,21 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId"), ExpressionUtils.field("waitpointId"), ExpressionUtils.field("batchIndex")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("waitpointId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2856,8 +2856,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -2866,7 +2866,7 @@ export class SchemaType implements SchemaDef { environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "waitpointTags", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -2874,12 +2874,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "waitpointTags", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -2887,18 +2887,18 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("name")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -2912,14 +2912,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, key: { name: "key", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, value: { name: "value", @@ -2940,8 +2940,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -2959,7 +2959,7 @@ export class SchemaType implements SchemaDef { workerGroup: { name: "workerGroup", type: "WorkerInstanceGroup", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerGroupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "workers", fields: ["workerGroupId"], references: ["id"] } }, workerGroupId: { @@ -2967,7 +2967,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "workerGroup" - ] + ] as readonly string[] }, TaskRunExecutionSnapshot: { name: "TaskRunExecutionSnapshot", @@ -2979,7 +2979,7 @@ export class SchemaType implements SchemaDef { name: "organization", type: "Organization", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerInstances", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -2988,13 +2988,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workers", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -3003,13 +3003,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "project" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerInstances", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -3018,13 +3018,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, deployment: { name: "deployment", type: "WorkerDeployment", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("deploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("deploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerInstance", fields: ["deploymentId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, deploymentId: { @@ -3033,19 +3033,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "deployment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, lastDequeueAt: { name: "lastDequeueAt", @@ -3060,7 +3060,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerGroupId"), ExpressionUtils.field("resourceIdentifier")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3074,8 +3074,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", @@ -3089,7 +3089,7 @@ export class SchemaType implements SchemaDef { name: "masterQueue", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, description: { name: "description", @@ -3099,23 +3099,23 @@ export class SchemaType implements SchemaDef { hidden: { name: "hidden", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, token: { name: "token", type: "WorkerGroupToken", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tokenId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tokenId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerGroup", fields: ["tokenId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, tokenId: { name: "tokenId", type: "String", unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "token" - ] + ] as readonly string[] }, workers: { name: "workers", @@ -3133,14 +3133,14 @@ export class SchemaType implements SchemaDef { name: "defaultForProjects", type: "Project", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ProjectDefaultWorkerGroup") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("ProjectDefaultWorkerGroup") }] }] as readonly AttributeApplication[], relation: { opposite: "defaultWorkerGroup", name: "ProjectDefaultWorkerGroup" } }, organization: { name: "organization", type: "Organization", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerGroups", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -3149,13 +3149,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerGroups", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -3164,19 +3164,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -3193,26 +3193,26 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, tokenHash: { name: "tokenHash", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, workerGroup: { name: "workerGroup", @@ -3234,8 +3234,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, name: { name: "name", @@ -3245,7 +3245,7 @@ export class SchemaType implements SchemaDef { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, runs: { name: "runs", @@ -3256,7 +3256,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "runTags", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -3264,19 +3264,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("name")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("name"), ExpressionUtils.field("id")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3291,29 +3291,29 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, taskRun: { name: "taskRun", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "dependency", fields: ["taskRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskRunId: { name: "taskRunId", type: "String", unique: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "taskRun" - ] + ] as readonly string[] }, checkpointEvent: { name: "checkpointEvent", type: "CheckpointRestoreEvent", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunDependency", fields: ["checkpointEventId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, checkpointEventId: { @@ -3321,16 +3321,16 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "checkpointEvent" - ] + ] as readonly string[] }, dependentAttempt: { name: "dependentAttempt", type: "TaskRunAttempt", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "dependencies", fields: ["dependentAttemptId"], references: ["id"] } }, dependentAttemptId: { @@ -3339,13 +3339,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "dependentAttempt" - ] + ] as readonly string[] }, dependentBatchRun: { name: "dependentBatchRun", type: "BatchTaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("dependentBatchRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentBatchRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("dependentBatchRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentBatchRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }] }] as readonly AttributeApplication[], relation: { opposite: "runDependencies", name: "dependentBatchRun", fields: ["dependentBatchRunId"], references: ["id"] } }, dependentBatchRunId: { @@ -3354,19 +3354,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "dependentBatchRun" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, resumedAt: { name: "resumedAt", @@ -3377,7 +3377,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentAttemptId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentBatchRunId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3392,13 +3392,13 @@ export class SchemaType implements SchemaDef { name: "taskIdentifier", type: "String", id: true, - attributes: [{ name: "@id" }] + attributes: [{ name: "@id" }] as readonly AttributeApplication[] }, lastNumber: { name: "lastNumber", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault } }, idFields: ["taskIdentifier"], @@ -3413,8 +3413,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, taskIdentifier: { name: "taskIdentifier", @@ -3423,7 +3423,7 @@ export class SchemaType implements SchemaDef { environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunNumberCounter", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -3431,18 +3431,18 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, lastNumber: { name: "lastNumber", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskIdentifier"), ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3456,25 +3456,25 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, number: { name: "number", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, taskRun: { name: "taskRun", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("attempts") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("attempts") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attempts", name: "attempts", fields: ["taskRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskRunId: { @@ -3482,12 +3482,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "taskRun" - ] + ] as readonly string[] }, backgroundWorker: { name: "backgroundWorker", type: "BackgroundWorker", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("backgroundWorkerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("backgroundWorkerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attempts", fields: ["backgroundWorkerId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, backgroundWorkerId: { @@ -3495,12 +3495,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "backgroundWorker" - ] + ] as readonly string[] }, backgroundWorkerTask: { name: "backgroundWorkerTask", type: "BackgroundWorkerTask", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("backgroundWorkerTaskId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("backgroundWorkerTaskId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attempts", fields: ["backgroundWorkerTaskId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, backgroundWorkerTaskId: { @@ -3508,12 +3508,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "backgroundWorkerTask" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskRunAttempts", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -3521,12 +3521,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, queue: { name: "queue", type: "TaskQueue", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("queueId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("queueId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "attempts", fields: ["queueId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, queueId: { @@ -3534,25 +3534,25 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "queue" - ] + ] as readonly string[] }, status: { name: "status", type: "TaskRunAttemptStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, startedAt: { name: "startedAt", @@ -3567,8 +3567,8 @@ export class SchemaType implements SchemaDef { usageDurationMs: { name: "usageDurationMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, error: { name: "error", @@ -3583,8 +3583,8 @@ export class SchemaType implements SchemaDef { outputType: { name: "outputType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, dependencies: { name: "dependencies", @@ -3626,14 +3626,14 @@ export class SchemaType implements SchemaDef { name: "childRuns", type: "TaskRun", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRunAttempt") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("TaskParentRunAttempt") }] }] as readonly AttributeApplication[], relation: { opposite: "parentTaskRunAttempt", name: "TaskParentRunAttempt" } } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId"), ExpressionUtils.field("number")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -3648,8 +3648,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, message: { name: "message", @@ -3676,26 +3676,26 @@ export class SchemaType implements SchemaDef { isError: { name: "isError", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isPartial: { name: "isPartial", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isCancelled: { name: "isCancelled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isDebug: { name: "isDebug", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, serviceName: { name: "serviceName", @@ -3708,20 +3708,20 @@ export class SchemaType implements SchemaDef { level: { name: "level", type: "TaskEventLevel", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("TRACE") }] }], - default: "TRACE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("TRACE") }] }] as readonly AttributeApplication[], + default: "TRACE" as FieldDefault }, kind: { name: "kind", type: "TaskEventKind", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("INTERNAL") }] }], - default: "INTERNAL" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("INTERNAL") }] }] as readonly AttributeApplication[], + default: "INTERNAL" as FieldDefault }, status: { name: "status", type: "TaskEventStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNSET") }] }], - default: "UNSET" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNSET") }] }] as readonly AttributeApplication[], + default: "UNSET" as FieldDefault }, links: { name: "links", @@ -3740,8 +3740,8 @@ export class SchemaType implements SchemaDef { duration: { name: "duration", type: "BigInt", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, attemptId: { name: "attemptId", @@ -3780,8 +3780,8 @@ export class SchemaType implements SchemaDef { runIsTest: { name: "runIsTest", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, idempotencyKey: { name: "idempotencyKey", @@ -3864,20 +3864,20 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, usageDurationMs: { name: "usageDurationMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, usageCostInCents: { name: "usageCostInCents", type: "Float", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, machinePreset: { name: "machinePreset", @@ -3904,7 +3904,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("traceId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spanId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -3917,14 +3917,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, name: { name: "name", @@ -3933,14 +3933,14 @@ export class SchemaType implements SchemaDef { type: { name: "type", type: "TaskQueueType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("VIRTUAL") }] }], - default: "VIRTUAL" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("VIRTUAL") }] }] as readonly AttributeApplication[], + default: "VIRTUAL" as FieldDefault }, version: { name: "version", type: "TaskQueueVersion", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }], - default: "V1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }] as readonly AttributeApplication[], + default: "V1" as FieldDefault }, orderableName: { name: "orderableName", @@ -3950,7 +3950,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskQueues", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -3958,12 +3958,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskQueues", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -3971,7 +3971,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, concurrencyLimit: { name: "concurrencyLimit", @@ -3986,26 +3986,26 @@ export class SchemaType implements SchemaDef { paused: { name: "paused", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, releaseConcurrencyOnWaitpoint: { name: "releaseConcurrencyOnWaitpoint", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, attempts: { name: "attempts", @@ -4028,7 +4028,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("name")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4043,14 +4043,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, idempotencyKey: { name: "idempotencyKey", @@ -4065,21 +4065,21 @@ export class SchemaType implements SchemaDef { runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "batchTaskRuns", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, status: { name: "status", type: "BatchTaskRunStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, runtimeEnvironmentId: { name: "runtimeEnvironmentId", type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, runs: { name: "runs", @@ -4090,27 +4090,27 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, runIds: { name: "runIds", type: "String", array: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }], - default: [] + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("Any", []) }] }] as readonly AttributeApplication[], + default: [] as FieldDefault }, runCount: { name: "runCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, payload: { name: "payload", @@ -4120,8 +4120,8 @@ export class SchemaType implements SchemaDef { payloadType: { name: "payloadType", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }], - default: "application/json" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("application/json") }] }] as readonly AttributeApplication[], + default: "application/json" as FieldDefault }, options: { name: "options", @@ -4131,8 +4131,8 @@ export class SchemaType implements SchemaDef { batchVersion: { name: "batchVersion", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("v1") }] }], - default: "v1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("v1") }] }] as readonly AttributeApplication[], + default: "v1" as FieldDefault }, executionSnapshots: { name: "executionSnapshots", @@ -4155,8 +4155,8 @@ export class SchemaType implements SchemaDef { sealed: { name: "sealed", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, sealedAt: { name: "sealedAt", @@ -4166,14 +4166,14 @@ export class SchemaType implements SchemaDef { expectedCount: { name: "expectedCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, completedCount: { name: "completedCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, completedAt: { name: "completedAt", @@ -4188,14 +4188,14 @@ export class SchemaType implements SchemaDef { processingJobsCount: { name: "processingJobsCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, processingJobsExpectedCount: { name: "processingJobsExpectedCount", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, oneTimeUseToken: { name: "oneTimeUseToken", @@ -4217,7 +4217,7 @@ export class SchemaType implements SchemaDef { name: "checkpointEvent", type: "CheckpointRestoreEvent", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointEventId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "batchTaskRunDependency", fields: ["checkpointEventId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, checkpointEventId: { @@ -4225,16 +4225,16 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "checkpointEvent" - ] + ] as readonly string[] }, dependentTaskAttempt: { name: "dependentTaskAttempt", type: "TaskRunAttempt", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentTaskAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentTaskAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "batchDependencies", fields: ["dependentTaskAttemptId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, dependentTaskAttemptId: { @@ -4243,13 +4243,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "dependentTaskAttempt" - ] + ] as readonly string[] }, runDependencies: { name: "runDependencies", type: "TaskRunDependency", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("dependentBatchRun") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("dependentBatchRun") }] }] as readonly AttributeApplication[], relation: { opposite: "dependentBatchRun", name: "dependentBatchRun" } } }, @@ -4257,7 +4257,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("oneTimeUseToken")]) }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId"), ExpressionUtils.field("idempotencyKey")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("dependentTaskAttemptId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4274,19 +4274,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, status: { name: "status", type: "BatchTaskRunItemStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, batchTaskRun: { name: "batchTaskRun", type: "BatchTaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchTaskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "items", fields: ["batchTaskRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, batchTaskRunId: { @@ -4294,12 +4294,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "batchTaskRun" - ] + ] as readonly string[] }, taskRun: { name: "taskRun", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "batchItems", fields: ["taskRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskRunId: { @@ -4307,13 +4307,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "taskRun" - ] + ] as readonly string[] }, taskRunAttempt: { name: "taskRunAttempt", type: "TaskRunAttempt", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "batchTaskRunItems", fields: ["taskRunAttemptId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, taskRunAttemptId: { @@ -4322,19 +4322,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "taskRunAttempt" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, completedAt: { name: "completedAt", @@ -4346,7 +4346,7 @@ export class SchemaType implements SchemaDef { { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("batchTaskRunId"), ExpressionUtils.field("taskRunId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunAttemptId")]) }, { name: "map", value: ExpressionUtils.literal("idx_batchtaskrunitem_taskrunattempt") }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "map", value: ExpressionUtils.literal("idx_batchtaskrunitem_taskrun") }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4360,14 +4360,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, key: { name: "key", @@ -4376,7 +4376,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environmentVariables", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -4384,19 +4384,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, values: { name: "values", @@ -4407,7 +4407,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("key")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4422,14 +4422,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, valueReference: { name: "valueReference", type: "SecretReference", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("valueReferenceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("valueReferenceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environmentVariableValues", fields: ["valueReferenceId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, valueReferenceId: { @@ -4438,12 +4438,12 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "valueReference" - ] + ] as readonly string[] }, variable: { name: "variable", type: "EnvironmentVariable", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("variableId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("variableId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "values", fields: ["variableId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, variableId: { @@ -4451,12 +4451,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "variable" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "environmentVariableValues", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -4464,30 +4464,30 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, isSecret: { name: "isSecret", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("variableId"), ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4501,14 +4501,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, type: { name: "type", @@ -4541,7 +4541,7 @@ export class SchemaType implements SchemaDef { run: { name: "run", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "checkpoints", fields: ["runId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runId: { @@ -4549,12 +4549,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "run" - ] + ] as readonly string[] }, attempt: { name: "attempt", type: "TaskRunAttempt", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "checkpoints", fields: ["attemptId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, attemptId: { @@ -4562,7 +4562,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attempt" - ] + ] as readonly string[] }, attemptNumber: { name: "attemptNumber", @@ -4572,7 +4572,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "checkpoints", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -4580,12 +4580,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "checkpoints", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -4593,25 +4593,25 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attemptId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4625,8 +4625,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", @@ -4645,7 +4645,7 @@ export class SchemaType implements SchemaDef { checkpoint: { name: "checkpoint", type: "Checkpoint", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "events", fields: ["checkpointId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, checkpointId: { @@ -4653,12 +4653,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "checkpoint" - ] + ] as readonly string[] }, run: { name: "run", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "CheckpointRestoreEvent", fields: ["runId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runId: { @@ -4666,12 +4666,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "run" - ] + ] as readonly string[] }, attempt: { name: "attempt", type: "TaskRunAttempt", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("attemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "CheckpointRestoreEvent", fields: ["attemptId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, attemptId: { @@ -4679,12 +4679,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "attempt" - ] + ] as readonly string[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "CheckpointRestoreEvent", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -4692,12 +4692,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, runtimeEnvironment: { name: "runtimeEnvironment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runtimeEnvironmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "CheckpointRestoreEvent", fields: ["runtimeEnvironmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, runtimeEnvironmentId: { @@ -4705,7 +4705,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "runtimeEnvironment" - ] + ] as readonly string[] }, taskRunDependency: { name: "taskRunDependency", @@ -4722,20 +4722,20 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("checkpointId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -4748,8 +4748,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, contentHash: { name: "contentHash", @@ -4759,7 +4759,7 @@ export class SchemaType implements SchemaDef { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, shortCode: { name: "shortCode", @@ -4777,8 +4777,8 @@ export class SchemaType implements SchemaDef { imagePlatform: { name: "imagePlatform", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("linux/amd64") }] }], - default: "linux/amd64" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("linux/amd64") }] }] as readonly AttributeApplication[], + default: "linux/amd64" as FieldDefault }, externalBuildData: { name: "externalBuildData", @@ -4788,19 +4788,19 @@ export class SchemaType implements SchemaDef { status: { name: "status", type: "WorkerDeploymentStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, type: { name: "type", type: "WorkerDeploymentType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }], - default: "V1" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("V1") }] }] as readonly AttributeApplication[], + default: "V1" as FieldDefault }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "WorkerDeployment", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -4808,12 +4808,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerDeployments", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -4821,13 +4821,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, worker: { name: "worker", type: "BackgroundWorker", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "deployment", fields: ["workerId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, workerId: { @@ -4835,16 +4835,16 @@ export class SchemaType implements SchemaDef { type: "String", unique: true, optional: true, - attributes: [{ name: "@unique" }], + attributes: [{ name: "@unique" }] as readonly AttributeApplication[], foreignKeyFor: [ "worker" - ] + ] as readonly string[] }, triggeredBy: { name: "triggeredBy", type: "User", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("triggeredById")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("triggeredById")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "deployments", fields: ["triggeredById"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, triggeredById: { @@ -4853,7 +4853,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "triggeredBy" - ] + ] as readonly string[] }, builtAt: { name: "builtAt", @@ -4883,14 +4883,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, promotions: { name: "promotions", @@ -4914,7 +4914,7 @@ export class SchemaType implements SchemaDef { attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("shortCode")]) }] }, { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("version")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4931,8 +4931,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, label: { name: "label", @@ -4941,7 +4941,7 @@ export class SchemaType implements SchemaDef { deployment: { name: "deployment", type: "WorkerDeployment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("deploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("deploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "promotions", fields: ["deploymentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, deploymentId: { @@ -4949,12 +4949,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "deployment" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "workerDeploymentPromotions", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -4962,12 +4962,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId"), ExpressionUtils.field("label")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -4981,20 +4981,20 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, type: { name: "type", type: "ScheduleType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("IMPERATIVE") }] }], - default: "IMPERATIVE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("IMPERATIVE") }] }] as readonly AttributeApplication[], + default: "IMPERATIVE" as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, taskIdentifier: { name: "taskIdentifier", @@ -5003,14 +5003,14 @@ export class SchemaType implements SchemaDef { deduplicationKey: { name: "deduplicationKey", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userProvidedDeduplicationKey: { name: "userProvidedDeduplicationKey", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, generatorExpression: { name: "generatorExpression", @@ -5019,20 +5019,20 @@ export class SchemaType implements SchemaDef { generatorDescription: { name: "generatorDescription", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }], - default: "" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("") }] }] as readonly AttributeApplication[], + default: "" as FieldDefault }, generatorType: { name: "generatorType", type: "ScheduleGeneratorType", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CRON") }] }], - default: "CRON" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("CRON") }] }] as readonly AttributeApplication[], + default: "CRON" as FieldDefault }, timezone: { name: "timezone", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UTC") }] }], - default: "UTC" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UTC") }] }] as readonly AttributeApplication[], + default: "UTC" as FieldDefault }, externalId: { name: "externalId", @@ -5053,7 +5053,7 @@ export class SchemaType implements SchemaDef { project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskSchedules", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -5061,32 +5061,32 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, active: { name: "active", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault } }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("deduplicationKey")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -5101,13 +5101,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, taskSchedule: { name: "taskSchedule", type: "TaskSchedule", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskScheduleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskScheduleId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "instances", fields: ["taskScheduleId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskScheduleId: { @@ -5115,12 +5115,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "taskSchedule" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "taskScheduleInstances", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -5128,25 +5128,25 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, active: { name: "active", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, lastScheduledTimestamp: { name: "lastScheduledTimestamp", @@ -5161,7 +5161,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskScheduleId"), ExpressionUtils.field("environmentId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -5175,8 +5175,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, ipAddress: { name: "ipAddress", @@ -5185,7 +5185,7 @@ export class SchemaType implements SchemaDef { environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "sessions", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -5193,19 +5193,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, disconnectedAt: { name: "disconnectedAt", @@ -5216,7 +5216,7 @@ export class SchemaType implements SchemaDef { name: "currentEnvironments", type: "RuntimeEnvironment", array: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("currentSession") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("currentSession") }] }] as readonly AttributeApplication[], relation: { opposite: "currentSession", name: "currentSession" } } }, @@ -5232,32 +5232,32 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, deduplicationKey: { name: "deduplicationKey", type: "String", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, userProvidedDeduplicationKey: { name: "userProvidedDeduplicationKey", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, integration: { name: "integration", type: "OrganizationIntegration", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("integrationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("integrationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("SetNull") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alertChannels", fields: ["integrationId"], references: ["id"], onDelete: "SetNull", onUpdate: "Cascade" } }, integrationId: { @@ -5266,13 +5266,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "integration" - ] + ] as readonly string[] }, enabled: { name: "enabled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }], - default: true + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(true) }] }] as readonly AttributeApplication[], + default: true as FieldDefault }, type: { name: "type", @@ -5295,13 +5295,13 @@ export class SchemaType implements SchemaDef { name: "environmentTypes", type: "RuntimeEnvironmentType", array: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("RuntimeEnvironmentType", [ExpressionUtils.literal("STAGING"), ExpressionUtils.literal("PRODUCTION")]) }] }], - default: ["STAGING", "PRODUCTION"] + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.array("RuntimeEnvironmentType", [ExpressionUtils.literal("STAGING"), ExpressionUtils.literal("PRODUCTION")]) }] }] as readonly AttributeApplication[], + default: ["STAGING", "PRODUCTION"] as FieldDefault }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alertChannels", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -5309,19 +5309,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, alerts: { name: "alerts", @@ -5338,7 +5338,7 @@ export class SchemaType implements SchemaDef { }, attributes: [ { name: "@@unique", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId"), ExpressionUtils.field("deduplicationKey")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" }, @@ -5353,19 +5353,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -5373,12 +5373,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, environment: { name: "environment", type: "RuntimeEnvironment", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("environmentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["environmentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, environmentId: { @@ -5386,12 +5386,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "environment" - ] + ] as readonly string[] }, channel: { name: "channel", type: "ProjectAlertChannel", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("channelId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("channelId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["channelId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, channelId: { @@ -5399,13 +5399,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "channel" - ] + ] as readonly string[] }, status: { name: "status", type: "ProjectAlertStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, type: { name: "type", @@ -5415,7 +5415,7 @@ export class SchemaType implements SchemaDef { name: "taskRunAttempt", type: "TaskRunAttempt", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunAttemptId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["taskRunAttemptId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskRunAttemptId: { @@ -5424,13 +5424,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "taskRunAttempt" - ] + ] as readonly string[] }, taskRun: { name: "taskRun", type: "TaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("taskRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["taskRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, taskRunId: { @@ -5439,13 +5439,13 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "taskRun" - ] + ] as readonly string[] }, workerDeployment: { name: "workerDeployment", type: "WorkerDeployment", optional: true, - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerDeploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("workerDeploymentId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alerts", fields: ["workerDeploymentId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, workerDeploymentId: { @@ -5454,19 +5454,19 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "workerDeployment" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -5482,13 +5482,13 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alertStorages", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -5496,12 +5496,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, alertChannel: { name: "alertChannel", type: "ProjectAlertChannel", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("alertChannelId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("alertChannelId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "alertStorages", fields: ["alertChannelId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, alertChannelId: { @@ -5509,7 +5509,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "alertChannel" - ] + ] as readonly string[] }, alertType: { name: "alertType", @@ -5526,14 +5526,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -5548,14 +5548,14 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, service: { name: "service", @@ -5568,7 +5568,7 @@ export class SchemaType implements SchemaDef { tokenReference: { name: "tokenReference", type: "SecretReference", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tokenReferenceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("tokenReferenceId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "OrganizationIntegration", fields: ["tokenReferenceId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, tokenReferenceId: { @@ -5576,12 +5576,12 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "tokenReference" - ] + ] as readonly string[] }, organization: { name: "organization", type: "Organization", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("organizationId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "organizationIntegrations", fields: ["organizationId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, organizationId: { @@ -5589,19 +5589,19 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "organization" - ] + ] as readonly string[] }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] }, alertChannels: { name: "alertChannels", @@ -5623,19 +5623,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, project: { name: "project", type: "Project", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("projectId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "bulkActionGroups", fields: ["projectId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, projectId: { @@ -5643,7 +5643,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "project" - ] + ] as readonly string[] }, type: { name: "type", @@ -5658,20 +5658,20 @@ export class SchemaType implements SchemaDef { status: { name: "status", type: "BulkActionStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -5687,19 +5687,19 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, friendlyId: { name: "friendlyId", type: "String", unique: true, - attributes: [{ name: "@unique" }] + attributes: [{ name: "@unique" }] as readonly AttributeApplication[] }, group: { name: "group", type: "BulkActionGroup", - attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("groupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("groupId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "items", fields: ["groupId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, groupId: { @@ -5707,7 +5707,7 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "group" - ] + ] as readonly string[] }, type: { name: "type", @@ -5716,13 +5716,13 @@ export class SchemaType implements SchemaDef { status: { name: "status", type: "BulkActionItemStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }], - default: "PENDING" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("PENDING") }] }] as readonly AttributeApplication[], + default: "PENDING" as FieldDefault }, sourceRun: { name: "sourceRun", type: "TaskRun", - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SourceActionItemRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("sourceRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("SourceActionItemRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("sourceRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "sourceBulkActionItems", name: "SourceActionItemRun", fields: ["sourceRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, sourceRunId: { @@ -5730,13 +5730,13 @@ export class SchemaType implements SchemaDef { type: "String", foreignKeyFor: [ "sourceRun" - ] + ] as readonly string[] }, destinationRun: { name: "destinationRun", type: "TaskRun", optional: true, - attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DestinationActionItemRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("destinationRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }], + attributes: [{ name: "@relation", args: [{ name: "name", value: ExpressionUtils.literal("DestinationActionItemRun") }, { name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("destinationRunId")]) }, { name: "references", value: ExpressionUtils.array("String", [ExpressionUtils.field("id")]) }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }] }] as readonly AttributeApplication[], relation: { opposite: "destinationBulkActionItems", name: "DestinationActionItemRun", fields: ["destinationRunId"], references: ["id"], onDelete: "Cascade", onUpdate: "Cascade" } }, destinationRunId: { @@ -5745,7 +5745,7 @@ export class SchemaType implements SchemaDef { optional: true, foreignKeyFor: [ "destinationRun" - ] + ] as readonly string[] }, error: { name: "error", @@ -5755,14 +5755,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, updatedAt: { name: "updatedAt", type: "DateTime", updatedAt: true, - attributes: [{ name: "@updatedAt" }] + attributes: [{ name: "@updatedAt" }] as readonly AttributeApplication[] } }, idFields: ["id"], @@ -5778,8 +5778,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, key: { name: "key", @@ -5800,14 +5800,14 @@ export class SchemaType implements SchemaDef { createdAt: { name: "createdAt", type: "DateTime", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault } }, attributes: [ { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("DateTime", [ExpressionUtils.field("createdAt")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id"], uniqueFields: { id: { type: "String" } @@ -5820,8 +5820,8 @@ export class SchemaType implements SchemaDef { name: "id", type: "String", id: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], - default: ExpressionUtils.call("cuid") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("cuid") as FieldDefault }, message: { name: "message", @@ -5848,20 +5848,20 @@ export class SchemaType implements SchemaDef { isError: { name: "isError", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isPartial: { name: "isPartial", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, isCancelled: { name: "isCancelled", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, serviceName: { name: "serviceName", @@ -5874,20 +5874,20 @@ export class SchemaType implements SchemaDef { level: { name: "level", type: "TaskEventLevel", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("TRACE") }] }], - default: "TRACE" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("TRACE") }] }] as readonly AttributeApplication[], + default: "TRACE" as FieldDefault }, kind: { name: "kind", type: "TaskEventKind", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("INTERNAL") }] }], - default: "INTERNAL" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("INTERNAL") }] }] as readonly AttributeApplication[], + default: "INTERNAL" as FieldDefault }, status: { name: "status", type: "TaskEventStatus", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNSET") }] }], - default: "UNSET" + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("UNSET") }] }] as readonly AttributeApplication[], + default: "UNSET" as FieldDefault }, links: { name: "links", @@ -5906,8 +5906,8 @@ export class SchemaType implements SchemaDef { duration: { name: "duration", type: "BigInt", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, attemptId: { name: "attemptId", @@ -5946,8 +5946,8 @@ export class SchemaType implements SchemaDef { runIsTest: { name: "runIsTest", type: "Boolean", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], - default: false + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }] as readonly AttributeApplication[], + default: false as FieldDefault }, idempotencyKey: { name: "idempotencyKey", @@ -6031,20 +6031,20 @@ export class SchemaType implements SchemaDef { name: "createdAt", type: "DateTime", id: true, - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], - default: ExpressionUtils.call("now") + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }] as readonly AttributeApplication[], + default: ExpressionUtils.call("now") as FieldDefault }, usageDurationMs: { name: "usageDurationMs", type: "Int", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, usageCostInCents: { name: "usageCostInCents", type: "Float", - attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }], - default: 0 + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(0) }] }] as readonly AttributeApplication[], + default: 0 as FieldDefault }, machinePreset: { name: "machinePreset", @@ -6072,7 +6072,7 @@ export class SchemaType implements SchemaDef { { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("traceId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("spanId")]) }] }, { name: "@@index", args: [{ name: "fields", value: ExpressionUtils.array("String", [ExpressionUtils.field("runId")]) }] } - ], + ] as readonly AttributeApplication[], idFields: ["id", "createdAt"], uniqueFields: { id_createdAt: { id: { type: "String" }, createdAt: { type: "DateTime" } } diff --git a/tests/e2e/orm/client-api/atomicity.test.ts b/tests/e2e/orm/client-api/atomicity.test.ts new file mode 100644 index 000000000..b0cb8ccb3 --- /dev/null +++ b/tests/e2e/orm/client-api/atomicity.test.ts @@ -0,0 +1,473 @@ +import type { ClientContract } from '@zenstackhq/orm'; +import { createTestClient } from '@zenstackhq/testtools'; +import path from 'node:path'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { schema } from '../schemas/basic'; +import { schema as delegateSchema, type SchemaType as DelegateSchemaType } from '../schemas/delegate/schema'; + +describe('Atomicity tests', () => { + describe('basic schema', () => { + let client: ClientContract; + + beforeEach(async () => { + client = await createTestClient(schema); + }); + + afterEach(async () => { + await client?.$disconnect(); + }); + + describe('nested create atomicity', () => { + it('rolls back nested to-one create on failure', async () => { + // Create a user first + await client.user.create({ + data: { email: 'u1@test.com' }, + }); + + // Attempt to create a post with a nested user create that violates unique constraint + await expect( + client.post.create({ + data: { + title: 'Post1', + author: { + create: { email: 'u1@test.com' }, // duplicate email + }, + }, + }), + ).rejects.toThrow(); + + // The post should not have been created either + await expect(client.post.findMany()).toResolveWithLength(0); + // Only the original user should exist + await expect(client.user.findMany()).toResolveWithLength(1); + }); + + it('rolls back nested to-many create on failure', async () => { + const user = await client.user.create({ + data: { email: 'u1@test.com' }, + }); + + // Create a post with a valid comment + const post = await client.post.create({ + data: { + title: 'Post1', + authorId: user.id, + comments: { + create: { content: 'comment1' }, + }, + }, + include: { comments: true }, + }); + expect(post.comments).toHaveLength(1); + + // Attempt to create a user with duplicate email and nested posts + await expect( + client.user.create({ + data: { + email: 'u1@test.com', // duplicate email — will fail + posts: { + create: [{ title: 'Post2' }, { title: 'Post3' }], + }, + profile: { + create: { bio: 'bio' }, + }, + }, + }), + ).rejects.toThrow(); + + // Neither the new user, posts, nor profile should exist + await expect(client.user.findMany()).toResolveWithLength(1); + await expect(client.post.findMany()).toResolveWithLength(1); + await expect(client.profile.findMany()).toResolveWithLength(0); + }); + + it('rolls back deeply nested create on failure', async () => { + // Attempt to create a user with nested post and nested comment, + // where the user email is duplicated + await client.user.create({ + data: { email: 'u1@test.com' }, + }); + + await expect( + client.post.create({ + data: { + title: 'Post1', + author: { + create: { email: 'u1@test.com' }, // duplicate + }, + comments: { + create: [{ content: 'c1' }, { content: 'c2' }], + }, + }, + }), + ).rejects.toThrow(); + + // Nothing should have been created + await expect(client.post.findMany()).toResolveWithLength(0); + await expect(client.comment.findMany()).toResolveWithLength(0); + await expect(client.user.findMany()).toResolveWithLength(1); + }); + }); + + describe('nested update atomicity', () => { + it('rolls back nested update with nested create on unique violation', async () => { + // Create two users, one with a post + const user1 = await client.user.create({ + data: { + email: 'u1@test.com', + posts: { + create: { title: 'Post1' }, + }, + }, + include: { posts: true }, + }); + await client.user.create({ + data: { email: 'u2@test.com' }, + }); + + // Attempt to update user1: change name AND create a nested post + // whose author is a new user with a duplicate email + await expect( + client.user.update({ + where: { id: user1.id }, + data: { + name: 'should not persist', + posts: { + create: { + title: 'Post2', + comments: { + create: { content: 'c1' }, + }, + }, + }, + // This will fail: duplicate unique email + email: 'u2@test.com', + }, + }), + ).rejects.toThrow(); + + // The user's name should not have been updated + const user1After = await client.user.findFirst({ where: { id: user1.id } }); + expect(user1After!.name).toBeNull(); + expect(user1After!.email).toBe('u1@test.com'); + + // Post2 and its comment should not exist + await expect(client.post.findMany()).toResolveWithLength(1); + await expect(client.comment.findMany()).toResolveWithLength(0); + }); + + it('rolls back nested update with delete on unique violation', async () => { + const user1 = await client.user.create({ + data: { + email: 'u1@test.com', + posts: { + create: [{ title: 'Post1' }, { title: 'Post2' }], + }, + }, + include: { posts: true }, + }); + await client.user.create({ + data: { email: 'u2@test.com' }, + }); + + // Attempt to update user1: delete a post AND change email to duplicate + await expect( + client.user.update({ + where: { id: user1.id }, + data: { + email: 'u2@test.com', // duplicate — will fail + posts: { + delete: { id: user1.posts[0]!.id }, + }, + }, + }), + ).rejects.toThrow(); + + // The post should NOT have been deleted (rolled back) + await expect(client.post.findMany()).toResolveWithLength(2); + + // User email should remain unchanged + const user1After = await client.user.findFirst({ where: { id: user1.id } }); + expect(user1After!.email).toBe('u1@test.com'); + }); + }); + }); + + describe('delegate models', () => { + let client: ClientContract; + + beforeEach(async () => { + client = await createTestClient(delegateSchema, { + usePrismaPush: true, + schemaFile: path.join(__dirname, '../schemas/delegate/schema.zmodel'), + }); + }); + + afterEach(async () => { + await client?.$disconnect(); + }); + + describe('cascaded create atomicity', () => { + it('rolls back all delegate levels on unique violation', async () => { + // Create a rated video (creates records in Asset, Video, RatedVideo tables) + await client.ratedVideo.create({ + data: { + duration: 100, + url: 'abc', + rating: 5, + }, + }); + + // Attempt to create another rated video with duplicate url + await expect( + client.ratedVideo.create({ + data: { + duration: 200, + url: 'abc', // duplicate unique constraint + rating: 3, + }, + }), + ).rejects.toSatisfy((e: any) => e.cause.message.toLowerCase().match(/(constraint)|(duplicate)/i)); + + // All levels should have exactly 1 record (the first one) + await expect(client.ratedVideo.findMany()).toResolveWithLength(1); + await expect(client.video.findMany()).toResolveWithLength(1); + await expect(client.asset.findMany()).toResolveWithLength(1); + }); + + it('rolls back nested relation create with delegate model on failure', async () => { + // Create a user + await client.user.create({ + data: { id: 1, email: 'u1@example.com' }, + }); + + // Create a rated video owned by the user + await client.ratedVideo.create({ + data: { + duration: 100, + url: 'abc', + rating: 5, + owner: { connect: { id: 1 } }, + }, + }); + + // Attempt to create another rated video with a nested owner create + // that violates unique email constraint + await expect( + client.ratedVideo.create({ + data: { + duration: 200, + url: 'def', + rating: 3, + owner: { + create: { email: 'u1@example.com' }, // duplicate email + }, + }, + }), + ).rejects.toThrow(); + + // Only the original records should exist + await expect(client.ratedVideo.findMany()).toResolveWithLength(1); + await expect(client.video.findMany()).toResolveWithLength(1); + await expect(client.asset.findMany()).toResolveWithLength(1); + await expect(client.user.findMany()).toResolveWithLength(1); + }); + }); + + describe('cascaded update atomicity', () => { + it('rolls back delegate model update on unique violation', async () => { + await client.ratedVideo.create({ + data: { id: 1, duration: 100, url: 'abc', rating: 5 }, + }); + await client.ratedVideo.create({ + data: { id: 2, duration: 200, url: 'def', rating: 3 }, + }); + + // Attempt to update second video's url to duplicate first one + await expect( + client.ratedVideo.update({ + where: { id: 2 }, + data: { + url: 'abc', // duplicate + rating: 10, + }, + }), + ).rejects.toThrow(); + + // Second video should remain unchanged across all levels + const video = await client.ratedVideo.findFirst({ where: { id: 2 } }); + expect(video!.url).toBe('def'); + expect(video!.rating).toBe(3); + }); + + it('rolls back delegate model update with nested relation on failure', async () => { + await client.user.create({ + data: { id: 1, email: 'u1@example.com' }, + }); + await client.ratedVideo.create({ + data: { + id: 1, + duration: 100, + url: 'abc', + rating: 5, + owner: { connect: { id: 1 } }, + }, + }); + + // Attempt to update a rated video: change rating AND create a nested + // owner with a duplicate email — should fail atomically + await expect( + client.ratedVideo.update({ + where: { id: 1 }, + data: { + rating: 99, + viewCount: 999, + owner: { + create: { email: 'u1@example.com' }, // duplicate email + }, + }, + }), + ).rejects.toThrow(); + + // Rating and viewCount should remain unchanged across all delegate levels + const video = await client.ratedVideo.findFirst({ where: { id: 1 } }); + expect(video!.rating).toBe(5); + expect(video!.viewCount).toBe(0); + + // No extra user should have been created + await expect(client.user.findMany()).toResolveWithLength(1); + }); + }); + + describe('cascaded delete atomicity', () => { + it('deletes all delegate levels atomically', async () => { + await client.ratedVideo.create({ + data: { id: 1, duration: 100, url: 'abc', rating: 5 }, + }); + + // Delete at base level should cascade to all sub-model levels + await client.asset.delete({ where: { id: 1 } }); + + await expect(client.ratedVideo.findMany()).toResolveWithLength(0); + await expect(client.video.findMany()).toResolveWithLength(0); + await expect(client.asset.findMany()).toResolveWithLength(0); + }); + + it('rolls back nested delete of delegate model on failure', async () => { + await client.user.create({ + data: { id: 1, email: 'u1@example.com' }, + }); + await client.user.create({ + data: { id: 2, email: 'u2@example.com' }, + }); + await client.ratedVideo.create({ + data: { + id: 1, + duration: 100, + url: 'abc', + rating: 5, + owner: { connect: { id: 1 } }, + }, + }); + + // Attempt a user update that includes both a nested asset delete + // and a field update that causes a unique violation + await expect( + client.user.update({ + where: { id: 1 }, + data: { + email: 'u2@example.com', // duplicate email + assets: { + delete: { id: 1 }, + }, + }, + }), + ).rejects.toThrow(); + + // The asset should still exist (delete was rolled back) + await expect(client.ratedVideo.findMany()).toResolveWithLength(1); + await expect(client.video.findMany()).toResolveWithLength(1); + await expect(client.asset.findMany()).toResolveWithLength(1); + + // User email should be unchanged + const user = await client.user.findFirst({ where: { id: 1 } }); + expect(user!.email).toBe('u1@example.com'); + }); + + it('cascade delete from parent propagates through delegate hierarchy', async () => { + await client.user.create({ + data: { id: 1, email: 'u1@example.com' }, + }); + await client.ratedVideo.create({ + data: { + id: 1, + duration: 100, + url: 'abc', + rating: 5, + owner: { connect: { id: 1 } }, + comments: { + create: [{ content: 'c1' }, { content: 'c2' }], + }, + }, + }); + await client.image.create({ + data: { + id: 2, + format: 'png', + owner: { connect: { id: 1 } }, + }, + }); + + // Deleting user should cascade delete all owned assets and their comments + await client.user.delete({ where: { id: 1 } }); + + await expect(client.user.findMany()).toResolveWithLength(0); + await expect(client.asset.findMany()).toResolveWithLength(0); + await expect(client.video.findMany()).toResolveWithLength(0); + await expect(client.ratedVideo.findMany()).toResolveWithLength(0); + await expect(client.image.findMany()).toResolveWithLength(0); + await expect(client.comment.findMany()).toResolveWithLength(0); + }); + + it('deleteMany cleans up delegate base hierarchy for related models', async () => { + // This exercises the needsNestedDelete fix: User is NOT a delegate model, + // but it has relations to delegate sub-models (Asset) with cascade delete. + // deleteMany only uses needsNestedDelete (not needReadBack) to decide + // whether to wrap in a transaction, so this is the purest test of the fix. + await client.user.create({ + data: { id: 1, email: 'u1@example.com' }, + }); + await client.user.create({ + data: { id: 2, email: 'u2@example.com' }, + }); + await client.ratedVideo.create({ + data: { + id: 1, + duration: 100, + url: 'abc', + rating: 5, + owner: { connect: { id: 1 } }, + }, + }); + await client.image.create({ + data: { + id: 2, + format: 'png', + owner: { connect: { id: 2 } }, + }, + }); + + // deleteMany users — processDelegateRelationDelete should clean up + // the full base hierarchy (Asset ← Video ← RatedVideo, Asset ← Image) + const result = await client.user.deleteMany({}); + expect(result.count).toBe(2); + + await expect(client.user.findMany()).toResolveWithLength(0); + await expect(client.asset.findMany()).toResolveWithLength(0); + await expect(client.video.findMany()).toResolveWithLength(0); + await expect(client.ratedVideo.findMany()).toResolveWithLength(0); + await expect(client.image.findMany()).toResolveWithLength(0); + }); + }); + }); +}); diff --git a/tests/e2e/orm/client-api/computed-fields.test.ts b/tests/e2e/orm/client-api/computed-fields.test.ts index e915b97bb..d0a75c3e2 100644 --- a/tests/e2e/orm/client-api/computed-fields.test.ts +++ b/tests/e2e/orm/client-api/computed-fields.test.ts @@ -191,7 +191,7 @@ model User { `, { computedFields: { - User: { + user: { upperName: (eb: any) => eb.fn('upper', ['name']), }, }, @@ -204,7 +204,7 @@ async function main() { const client = new ZenStackClient(schema, { dialect: {} as any, computedFields: { - User: { + user: { upperName: (eb) => eb.fn('upper', ['name']), }, } @@ -263,7 +263,7 @@ model User { `, { computedFields: { - User: { + user: { upperName: (eb: any) => eb.lit(null), }, }, @@ -276,7 +276,7 @@ async function main() { const client = new ZenStackClient(schema, { dialect: {} as any, computedFields: { - User: { + user: { upperName: (eb) => eb.lit(null), }, } diff --git a/tests/e2e/orm/client-api/delegate.test.ts b/tests/e2e/orm/client-api/delegate.test.ts index 6ed0b9ea2..e325aaa5b 100644 --- a/tests/e2e/orm/client-api/delegate.test.ts +++ b/tests/e2e/orm/client-api/delegate.test.ts @@ -1,17 +1,17 @@ +import type { ClientContract } from '@zenstackhq/orm'; +import { createTestClient } from '@zenstackhq/testtools'; import path from 'node:path'; import { afterEach, beforeEach, describe, expect, it } from 'vitest'; -import type { ClientContract } from '@zenstackhq/orm'; import { schema, type SchemaType } from '../schemas/delegate/schema'; -import { createTestClient } from '@zenstackhq/testtools'; describe('Delegate model tests ', () => { let client: ClientContract; beforeEach(async () => { - client = (await createTestClient(schema, { + client = await createTestClient(schema, { usePrismaPush: true, schemaFile: path.join(__dirname, '../schemas/delegate/schema.zmodel'), - })) as any; + }); }); afterEach(async () => { @@ -39,7 +39,7 @@ describe('Delegate model tests ', () => { }, }, }), - ).rejects.toThrow('is a delegate'); + ).rejects.toThrow('Unrecognized key: "create"'); // create entity with two levels of delegation await expect( diff --git a/tests/e2e/orm/client-api/diagnostics.test.ts b/tests/e2e/orm/client-api/diagnostics.test.ts new file mode 100644 index 000000000..dbed2eeba --- /dev/null +++ b/tests/e2e/orm/client-api/diagnostics.test.ts @@ -0,0 +1,195 @@ +import { describe, expect, it } from 'vitest'; +import { schema } from '../schemas/basic'; +import { createTestClient } from '@zenstackhq/testtools'; + +describe('Client $diagnostics tests', () => { + describe('without diagnostics option', () => { + it('returns zod cache stats', async () => { + const client = await createTestClient(schema); + try { + const diagnostics = await client.$diagnostics; + expect(diagnostics.zodCache).toEqual({ size: 0, keys: [] }); + } finally { + await client.$disconnect(); + } + }); + + it('returns zod cache stats after queries', async () => { + const client = await createTestClient(schema); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + const diagnostics = await client.$diagnostics; + expect(diagnostics.zodCache.size).toBeGreaterThan(0); + expect(diagnostics.zodCache.keys.length).toBe(diagnostics.zodCache.size); + } finally { + await client.$disconnect(); + } + }); + + it('returns empty slow queries when diagnostics option is not set', async () => { + const client = await createTestClient(schema); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + await client.user.findMany(); + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries).toEqual([]); + } finally { + await client.$disconnect(); + } + }); + }); + + describe('with diagnostics option', () => { + it('records slow queries when threshold is exceeded', async () => { + const client = await createTestClient(schema, { + diagnostics: { slowQueryThresholdMs: 0 }, + }); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + await client.user.findMany(); + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries.length).toBeGreaterThan(0); + for (const query of diagnostics.slowQueries) { + expect(query.startedAt).toBeInstanceOf(Date); + expect(query.durationMs).toBeGreaterThanOrEqual(0); + expect(query.sql).toBeTruthy(); + } + } finally { + await client.$disconnect(); + } + }); + + it('does not record queries below threshold', async () => { + const client = await createTestClient(schema, { + diagnostics: { slowQueryThresholdMs: 999999 }, + }); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + await client.user.findMany(); + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries).toEqual([]); + } finally { + await client.$disconnect(); + } + }); + + it('returns a copy of slow queries', async () => { + const client = await createTestClient(schema, { + diagnostics: { slowQueryThresholdMs: 0 }, + }); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + + const diagnostics1 = await client.$diagnostics; + const diagnostics2 = await client.$diagnostics; + expect(diagnostics1.slowQueries).not.toBe(diagnostics2.slowQueries); + expect(diagnostics1.slowQueries).toEqual(diagnostics2.slowQueries); + } finally { + await client.$disconnect(); + } + }); + + it('shares slow queries across derived clients', async () => { + const client = await createTestClient(schema, { + diagnostics: { slowQueryThresholdMs: 0 }, + }); + try { + await client.user.create({ data: { email: 'u1@test.com' } }); + + const derivedClient = client.$setAuth({ id: '1' }); + await derivedClient.user.findMany(); + + // both clients should see the same slow queries + const parentDiag = await client.$diagnostics; + const derivedDiag = await derivedClient.$diagnostics; + expect(parentDiag.slowQueries).toEqual(derivedDiag.slowQueries); + } finally { + await client.$disconnect(); + } + }); + + it('shares slow queries across transaction clients', async () => { + const client = await createTestClient(schema, { + diagnostics: { slowQueryThresholdMs: 0 }, + }); + try { + await client.$transaction(async (tx) => { + await tx.user.create({ data: { email: 'u1@test.com' } }); + }); + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries.length).toBeGreaterThan(0); + } finally { + await client.$disconnect(); + } + }); + }); + + describe('slowQueryMaxRecords', () => { + it('limits the number of slow query records', async () => { + const maxRecords = 3; + const client = await createTestClient(schema, { + diagnostics: { + slowQueryThresholdMs: 0, + slowQueryMaxRecords: maxRecords, + }, + }); + try { + for (let i = 0; i < 10; i++) { + await client.user.create({ data: { email: `u${i}@test.com` } }); + } + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries.length).toBeLessThanOrEqual(maxRecords); + } finally { + await client.$disconnect(); + } + }); + + it('accepts Infinity as slowQueryMaxRecords', async () => { + const client = await createTestClient(schema, { + diagnostics: { + slowQueryThresholdMs: 0, + slowQueryMaxRecords: Infinity, + }, + }); + try { + for (let i = 0; i < 5; i++) { + await client.user.create({ data: { email: `u${i}@test.com` } }); + } + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries.length).toBeGreaterThanOrEqual(5); + } finally { + await client.$disconnect(); + } + }); + + it('keeps the slowest queries when limit is exceeded', async () => { + const maxRecords = 2; + const client = await createTestClient(schema, { + diagnostics: { + slowQueryThresholdMs: 0, + slowQueryMaxRecords: maxRecords, + }, + }); + try { + for (let i = 0; i < 5; i++) { + await client.user.create({ data: { email: `u${i}@test.com` } }); + } + + const diagnostics = await client.$diagnostics; + expect(diagnostics.slowQueries.length).toBeLessThanOrEqual(maxRecords); + for (const query of diagnostics.slowQueries) { + expect(query.startedAt).toBeInstanceOf(Date); + expect(query.durationMs).toBeGreaterThanOrEqual(0); + expect(query.sql).toBeTruthy(); + } + } finally { + await client.$disconnect(); + } + }); + }); +}); diff --git a/tests/e2e/orm/client-api/omit.test.ts b/tests/e2e/orm/client-api/omit.test.ts index 7cabe4d88..87ee3364b 100644 --- a/tests/e2e/orm/client-api/omit.test.ts +++ b/tests/e2e/orm/client-api/omit.test.ts @@ -37,7 +37,7 @@ describe('Field omission tests', () => { }); it('respects client omit options', async () => { - const options = { omit: { User: { name: true } }, dialect: {} as any } as const; + const options = { omit: { user: { name: true } }, dialect: {} as any } as const; const db = await createTestClient(schema, options); const user = await db.user.create({ @@ -66,7 +66,7 @@ describe('Field omission tests', () => { it('allows override at query options level', async () => { // override schema-level omit - const options = { omit: { User: { password: false } }, dialect: {} as any } as const; + const options = { omit: { user: { password: false } }, dialect: {} as any } as const; const db = await createTestClient(schema, options); const user1 = await db.user.create({ data: { @@ -114,7 +114,7 @@ describe('Field omission tests', () => { it('allows override at query level', async () => { // override options-level omit - const options = { omit: { User: { name: true } }, dialect: {} as any } as const; + const options = { omit: { user: { name: true } }, dialect: {} as any } as const; const db = await createTestClient(schema, options); const user5 = await db.user.create({ data: { id: 2, name: 'User2', password: 'abc' }, diff --git a/tests/e2e/orm/client-api/transaction.test.ts b/tests/e2e/orm/client-api/transaction.test.ts index e4f2192e8..84e267aad 100644 --- a/tests/e2e/orm/client-api/transaction.test.ts +++ b/tests/e2e/orm/client-api/transaction.test.ts @@ -101,6 +101,77 @@ describe('Client raw query tests', () => { await expect(client.user.findMany()).toResolveWithLength(0); }); + + it('$unuseAll preserves transaction isolation', async () => { + await expect( + client.$transaction(async (tx) => { + await tx.$unuseAll().user.create({ + data: { email: 'u1@test.com' }, + }); + throw new Error('rollback'); + }), + ).rejects.toThrow('rollback'); + + await expect(client.user.findMany()).toResolveWithLength(0); + }); + + it('$unuse preserves transaction isolation', async () => { + await expect( + client.$transaction(async (tx) => { + await tx.$unuse('nonexistent').user.create({ + data: { email: 'u1@test.com' }, + }); + throw new Error('rollback'); + }), + ).rejects.toThrow('rollback'); + + await expect(client.user.findMany()).toResolveWithLength(0); + }); + + it('$use preserves transaction isolation', async () => { + await expect( + client.$transaction(async (tx) => { + await (tx as any) + .$use({ + id: 'noop', + onQuery: async ({ args, proceed }: { args: unknown; proceed: (args: unknown) => Promise }) => + proceed(args), + }) + .user.create({ + data: { email: 'u1@test.com' }, + }); + throw new Error('rollback'); + }), + ).rejects.toThrow('rollback'); + + await expect(client.user.findMany()).toResolveWithLength(0); + }); + + it('$setAuth preserves transaction isolation', async () => { + await expect( + client.$transaction(async (tx) => { + await tx.$setAuth(undefined).user.create({ + data: { email: 'u1@test.com' }, + }); + throw new Error('rollback'); + }), + ).rejects.toThrow('rollback'); + + await expect(client.user.findMany()).toResolveWithLength(0); + }); + + it('$setOptions preserves transaction isolation', async () => { + await expect( + client.$transaction(async (tx) => { + await (tx as any).$setOptions((tx as any).$options).user.create({ + data: { email: 'u1@test.com' }, + }); + throw new Error('rollback'); + }), + ).rejects.toThrow('rollback'); + + await expect(client.user.findMany()).toResolveWithLength(0); + }); }); describe('sequential transaction', () => { diff --git a/tests/e2e/orm/client-api/type-coverage.test.ts b/tests/e2e/orm/client-api/type-coverage.test.ts index bbe872773..195af5535 100644 --- a/tests/e2e/orm/client-api/type-coverage.test.ts +++ b/tests/e2e/orm/client-api/type-coverage.test.ts @@ -81,10 +81,6 @@ describe('Zmodel type coverage tests', () => { }); it('supports all types - array', async () => { - if (getTestDbProvider() !== 'postgresql') { - return; - } - const date = new Date(); const data = { id: '1', @@ -117,6 +113,7 @@ describe('Zmodel type coverage tests', () => { Json Json[] } `, + { provider: 'postgresql' }, ); await db.foo.create({ data }); diff --git a/tests/e2e/orm/client-api/unsupported.test-d.ts b/tests/e2e/orm/client-api/unsupported.test-d.ts new file mode 100644 index 000000000..a9797cc90 --- /dev/null +++ b/tests/e2e/orm/client-api/unsupported.test-d.ts @@ -0,0 +1,134 @@ +import type { ClientContract, CreateArgs, FindManyArgs, ModelResult, UpdateArgs } from '@zenstackhq/orm'; +import { describe, expectTypeOf, it } from 'vitest'; +import z from 'zod'; +import { schema } from '../schemas/unsupported/schema'; + +type Schema = typeof schema; + +declare const client: ClientContract; + +describe('Unsupported field exclusion - typing', () => { + // #region Result types + + it('excludes Unsupported fields from result type (optional Unsupported)', () => { + type ItemResult = ModelResult; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toHaveProperty('name'); + // Unsupported field should be excluded + expectTypeOf().not.toHaveProperty('data'); + }); + + it('excludes Unsupported fields from result type (required Unsupported)', () => { + type GeoResult = ModelResult; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toHaveProperty('title'); + // Unsupported field should be excluded + expectTypeOf().not.toHaveProperty('extra'); + }); + + // #endregion + + // #region Find/Where types + + it('excludes Unsupported fields from where filter', () => { + type FindArgs = FindManyArgs; + type Where = NonNullable; + expectTypeOf().toHaveProperty('id'); + expectTypeOf().toHaveProperty('name'); + // Unsupported field should not be filterable + expectTypeOf().not.toHaveProperty('data'); + }); + + // #endregion + + // #region Select/Omit types + + it('excludes Unsupported fields from select', () => { + type FindArgs = FindManyArgs; + type Select = NonNullable; + expectTypeOf().toHaveProperty('name'); + // Unsupported field should not be selectable + expectTypeOf