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 _url: true
}) })
// TODO: narrow
export const deploymentUpdateSchema = createUpdateSchema(deployments).pick({ export const deploymentUpdateSchema = createUpdateSchema(deployments).pick({
enabled: true, enabled: true,
published: true, published: true,

Wyświetl plik

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

Wyświetl plik

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