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' } from '@fisch0920/drizzle-orm'
import type { z } from '@hono/zod-openapi' import type { z } from '@hono/zod-openapi'
import type { UndefinedToNullDeep } from '@/lib/types'
import type * as schema from './schema' import type * as schema from './schema'
export type Tables = ExtractTablesWithRelations<typeof schema> export type Tables = ExtractTablesWithRelations<typeof schema>
@ -55,13 +53,11 @@ export type ConsumerWithProjectAndDeployment = BuildQueryResult<
> >
export type RawConsumer = InferSelectModel<typeof schema.consumers> export type RawConsumer = InferSelectModel<typeof schema.consumers>
export type ConsumerUpdate = Partial< export type ConsumerUpdate = Partial<
UndefinedToNullDeep<
Omit< Omit<
InferInsertModel<typeof schema.consumers>, InferInsertModel<typeof schema.consumers>,
'id' | 'projectId' | 'userId' | 'deploymentId' 'id' | 'projectId' | 'userId' | 'deploymentId'
> >
> >
>
export type LogEntry = z.infer<typeof schema.logEntrySelectSchema> export type LogEntry = z.infer<typeof schema.logEntrySelectSchema>
export type RawLogEntry = InferSelectModel<typeof schema.logEntries> export type RawLogEntry = InferSelectModel<typeof schema.logEntries>

Wyświetl plik

@ -336,7 +336,7 @@ export async function upsertStripeSubscription({
} }
} else { } else {
// TODO // TODO
consumerUpdate.stripeSubscriptionMetricItems![metricSlug] = null delete consumerUpdate.stripeSubscriptionMetricItems![metricSlug]
} }
} }
@ -350,7 +350,7 @@ export async function upsertStripeSubscription({
const [updatedConsumer] = await db const [updatedConsumer] = await db
.update(schema.consumers) .update(schema.consumers)
.set(consumerUpdate as any) // TODO .set(consumerUpdate)
.where(eq(schema.consumers.id, consumer.id)) .where(eq(schema.consumers.id, consumer.id))
.returning() .returning()
assert(updatedConsumer, 500, 'Error updating consumer') 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]> } // ? { [K in keyof T]: NullToUndefinedDeep<T[K]> }
// : T // : T
export type UndefinedToNullDeep<T> = T extends undefined // // TODO: currently unused
? T | null // export type UndefinedToNullDeep<T> = T extends undefined
: T extends Date // ? T | null
? T | null // : T extends Date
: T extends readonly (infer U)[] // ? T | null
? UndefinedToNullDeep<U>[] // : T extends readonly (infer U)[]
: T extends object // ? UndefinedToNullDeep<U>[]
? { [K in keyof T]: UndefinedToNullDeep<T[K]> } // : T extends object
: T | null // ? { [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, ...config,
{ {
files: ['**/*.ts', '**/*.tsx'], files: ['**/*.ts', '**/*.tsx'],
ignores: ['**/out/**'],
plugins: { plugins: {
drizzle drizzle
}, },