pull/715/head
Travis Fischer 2025-05-14 19:52:25 +07:00
rodzic 05ae5e307e
commit 97e9b9b9c5
4 zmienionych plików z 21 dodań i 18 usunięć

Wyświetl plik

@ -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<typeof schema>
@ -55,11 +53,9 @@ export type ConsumerWithProjectAndDeployment = BuildQueryResult<
>
export type RawConsumer = InferSelectModel<typeof schema.consumers>
export type ConsumerUpdate = Partial<
UndefinedToNullDeep<
Omit<
InferInsertModel<typeof schema.consumers>,
'id' | 'projectId' | 'userId' | 'deploymentId'
>
Omit<
InferInsertModel<typeof schema.consumers>,
'id' | 'projectId' | 'userId' | 'deploymentId'
>
>

Wyświetl plik

@ -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')

Wyświetl plik

@ -25,12 +25,18 @@ export type AuthenticatedContext = Context<AuthenticatedEnv>
// ? { [K in keyof T]: NullToUndefinedDeep<T[K]> }
// : T
export type UndefinedToNullDeep<T> = T extends undefined
? T | null
: T extends Date
? T | null
: T extends readonly (infer U)[]
? UndefinedToNullDeep<U>[]
: T extends object
? { [K in keyof T]: UndefinedToNullDeep<T[K]> }
: T | null
// // TODO: currently unused
// export type UndefinedToNullDeep<T> = T extends undefined
// ? T | null
// : T extends Date
// ? T | null
// : T extends readonly (infer U)[]
// ? UndefinedToNullDeep<U>[]
// : T extends object
// ? { [K in keyof T]: UndefinedToNullDeep<T[K]> }
// : T | null
// // TODO: currently unused
// export type UndefinedValuesToNullableValues<T> = T extends object
// ? { [K in keyof T]: T[K] extends undefined ? T[K] | null : T[K] }
// : T

Wyświetl plik

@ -5,6 +5,7 @@ export default [
...config,
{
files: ['**/*.ts', '**/*.tsx'],
ignores: ['**/out/**'],
plugins: {
drizzle
},