diff --git a/apps/api/src/db/types.test.ts b/apps/api/src/db/types.test.ts index a8cf2f94..3b912273 100644 --- a/apps/api/src/db/types.test.ts +++ b/apps/api/src/db/types.test.ts @@ -1,3 +1,4 @@ +import type { Simplify } from 'type-fest' import { expectTypeOf, test } from 'vitest' import type { @@ -5,7 +6,9 @@ import type { LogEntry, RawConsumer, RawConsumerUpdate, + RawDeployment, RawLogEntry, + RawProject, RawUser, User } from './types' @@ -14,6 +17,14 @@ type UserKeys = Exclude type LogEntryKeys = keyof RawLogEntry & keyof LogEntry type ConsumerKeys = keyof RawConsumer & keyof Consumer +type TODOFixedConsumer = Simplify< + Omit & { + user?: RawUser | null + project?: RawProject | null + deployment?: RawDeployment | null + } +> + test('User types are compatible', () => { expectTypeOf().toExtend() @@ -29,9 +40,9 @@ test('LogEntry types are compatible', () => { }) test('Consumer types are compatible', () => { - expectTypeOf().toExtend() + expectTypeOf().toExtend() - expectTypeOf().toEqualTypeOf< + expectTypeOf().toEqualTypeOf< RawConsumer[ConsumerKeys] >() diff --git a/apps/api/src/db/types.ts b/apps/api/src/db/types.ts index 2efc7945..5cc6aab9 100644 --- a/apps/api/src/db/types.ts +++ b/apps/api/src/db/types.ts @@ -63,9 +63,9 @@ export type ConsumerWithProjectAndDeployment = BuildQueryResult< > export type RawConsumer = Simplify< InferSelectModel & { - user?: RawUser | null // TODO: remove null (requires drizzle-orm changes) - project?: RawProject | null // TODO: remove null (requires drizzle-orm changes) - deployment?: RawDeployment | null // TODO: remove null (requires drizzle-orm changes) + user?: RawUser | undefined | null // TODO: remove null (requires drizzle-orm changes) + project?: RawProject | undefined | null // TODO: remove null (requires drizzle-orm changes) + deployment?: RawDeployment | undefined | null // TODO: remove null (requires drizzle-orm changes) } > export type RawConsumerUpdate = Partial<