diff --git a/apps/api/src/db/types.ts b/apps/api/src/db/types.ts index 8c39bb5e..f876d7ce 100644 --- a/apps/api/src/db/types.ts +++ b/apps/api/src/db/types.ts @@ -6,8 +6,6 @@ import type { } from '@fisch0920/drizzle-orm' import type { z } from '@hono/zod-openapi' -import type { UndefinedToNullDeep } from '@/lib/types' - import type * as schema from './schema' export type Tables = ExtractTablesWithRelations @@ -55,11 +53,9 @@ export type ConsumerWithProjectAndDeployment = BuildQueryResult< > export type RawConsumer = InferSelectModel export type ConsumerUpdate = Partial< - UndefinedToNullDeep< - Omit< - InferInsertModel, - 'id' | 'projectId' | 'userId' | 'deploymentId' - > + Omit< + InferInsertModel, + 'id' | 'projectId' | 'userId' | 'deploymentId' > > diff --git a/apps/api/src/lib/billing/upsert-stripe-subscription.ts b/apps/api/src/lib/billing/upsert-stripe-subscription.ts index 348ea597..e3a7605f 100644 --- a/apps/api/src/lib/billing/upsert-stripe-subscription.ts +++ b/apps/api/src/lib/billing/upsert-stripe-subscription.ts @@ -336,7 +336,7 @@ export async function upsertStripeSubscription({ } } else { // TODO - consumerUpdate.stripeSubscriptionMetricItems![metricSlug] = null + delete consumerUpdate.stripeSubscriptionMetricItems![metricSlug] } } @@ -350,7 +350,7 @@ export async function upsertStripeSubscription({ const [updatedConsumer] = await db .update(schema.consumers) - .set(consumerUpdate as any) // TODO + .set(consumerUpdate) .where(eq(schema.consumers.id, consumer.id)) .returning() assert(updatedConsumer, 500, 'Error updating consumer') diff --git a/apps/api/src/lib/types.ts b/apps/api/src/lib/types.ts index 18bcfe0b..ea39f9c3 100644 --- a/apps/api/src/lib/types.ts +++ b/apps/api/src/lib/types.ts @@ -25,12 +25,18 @@ export type AuthenticatedContext = Context // ? { [K in keyof T]: NullToUndefinedDeep } // : T -export type UndefinedToNullDeep = T extends undefined - ? T | null - : T extends Date - ? T | null - : T extends readonly (infer U)[] - ? UndefinedToNullDeep[] - : T extends object - ? { [K in keyof T]: UndefinedToNullDeep } - : T | null +// // TODO: currently unused +// export type UndefinedToNullDeep = T extends undefined +// ? T | null +// : T extends Date +// ? T | null +// : T extends readonly (infer U)[] +// ? UndefinedToNullDeep[] +// : T extends object +// ? { [K in keyof T]: UndefinedToNullDeep } +// : T | null + +// // TODO: currently unused +// export type UndefinedValuesToNullableValues = T extends object +// ? { [K in keyof T]: T[K] extends undefined ? T[K] | null : T[K] } +// : T diff --git a/eslint.config.js b/eslint.config.js index 0dabe36f..e3403519 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,6 +5,7 @@ export default [ ...config, { files: ['**/*.ts', '**/*.tsx'], + ignores: ['**/out/**'], plugins: { drizzle },