kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
05ae5e307e
commit
97e9b9b9c5
|
@ -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'
|
||||
>
|
||||
>
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,6 +5,7 @@ export default [
|
|||
...config,
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
ignores: ['**/out/**'],
|
||||
plugins: {
|
||||
drizzle
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue