pull/715/head
Travis Fischer 2025-04-22 04:29:05 +07:00
rodzic 9201f9230e
commit adea07a890
3 zmienionych plików z 17 dodań i 14 usunięć

Wyświetl plik

@ -103,7 +103,6 @@ export const deploymentSelectSchema = createSelectSchema(deployments).omit({
_url: true
})
// TODO: narrow
export const deploymentUpdateSchema = createUpdateSchema(deployments).pick({
enabled: true,
published: true,

Wyświetl plik

@ -61,23 +61,23 @@ export const projects = pgTable(
_webhooks: jsonb().$type<Webhook[]>().default([]),
// Stripe products corresponding to the stripe plans across deployments
stripeBaseProduct: stripeId(),
stripeRequestProduct: stripeId(),
stripeBaseProductId: stripeId(),
stripeRequestProductId: stripeId(),
// [metricSlug: string]: string
stripeMetricProducts: jsonb().$type<Record<string, string>>().default({}),
stripeMetricProductIds: jsonb().$type<Record<string, string>>().default({}),
// Stripe coupons associated with this project, mapping from unique coupon
// hash to stripe coupon id.
// `[hash: string]: string`
_stripeCoupons: jsonb().$type<Record<string, string>>().default({}),
_stripeCouponIds: jsonb().$type<Record<string, string>>().default({}),
// Stripe billing plans associated with this project (created lazily),
// mapping from unique plan hash to stripe plan ids for base and request
// respectively.
// `[hash: string]: { basePlan: string, requestPlan: string }`
_stripePlans: jsonb()
.$type<Record<string, { basePlan: string; requestPlan: string }>>()
// `[hash: string]: { basePlanId: string, requestPlanId: string }`
_stripePlanIds: jsonb()
.$type<Record<string, { basePlanId: string; requestPlanId: string }>>()
.default({}),
// Connected Stripe account (standard or express).
@ -87,7 +87,7 @@ export const projects = pgTable(
// the stripeID utility.
// TODO: is it wise to share this between dev and prod?
// TODO: is it okay for this to be public?
_stripeAccount: stripeId()
_stripeAccountId: stripeId()
},
(table) => [
index('project_userId_idx').on(table.userId),
@ -150,9 +150,9 @@ export const projectSelectSchema = createSelectSchema(projects).omit({
_providerToken: true,
_text: true,
_webhooks: true,
_stripeCoupons: true,
_stripePlans: true,
_stripeAccount: true
_stripeCouponIds: true,
_stripePlanIds: true,
_stripeAccountId: true
})
// TODO: narrow update schema

Wyświetl plik

@ -18,6 +18,7 @@ import {
createSelectSchema,
createUpdateSchema,
id,
stripeId,
timestamps,
userRoleEnum
} from './utils'
@ -49,7 +50,7 @@ export const users = pgTable(
// third-party auth providers
providers: jsonb().$type<AuthProviders>().default({}),
stripeCustomerId: text()
stripeCustomerId: stripeId().unique()
},
(table) => [
uniqueIndex('user_email_idx').on(table.email),
@ -69,7 +70,10 @@ export const usersRelations = relations(users, ({ many }) => ({
export type User = typeof users.$inferSelect
export const userInsertSchema = createInsertSchema(users).pick({
export const userInsertSchema = createInsertSchema(users, {
// TODO: username validation
// username: (schema) => schema.min(3).max(20)
}).pick({
username: true,
email: true,
password: true,