Files
cozsweet-frontend-nextjs/src/data/schemas/auth/checkout_handoff.ts
T

59 lines
1.5 KiB
TypeScript

import { z } from "zod";
import { stringOrEmpty } from "../nullable-defaults";
import { UserSchema } from "../user/user";
export const CheckoutIntentSchema = z
.object({
planId: z.string().min(1).max(120),
autoRenew: z.boolean(),
recipientCharacterId: z.string().min(1).max(80).optional(),
commercialOfferId: z.string().min(1).max(80).optional(),
chatActionId: z.uuid().optional(),
})
.readonly();
export const CheckoutHandoffCreateRequestSchema = CheckoutIntentSchema;
export const CheckoutHandoffCreateResponseSchema = z
.object({
externalUrl: z.url(),
expiresAt: z.string().min(1),
})
.readonly();
export const CheckoutHandoffConsumeRequestSchema = z
.object({
handoffToken: z.string().min(32).max(512),
})
.readonly();
export const CheckoutHandoffConsumeResponseSchema = z
.object({
user: UserSchema,
token: z.string().min(1),
refreshToken: stringOrEmpty,
loginStatus: z.enum([
"email",
"google",
"facebook",
"facebookMessenger",
]),
checkoutIntent: CheckoutIntentSchema,
})
.readonly();
export type CheckoutIntent = z.output<typeof CheckoutIntentSchema>;
export type CheckoutHandoffCreateRequest = z.output<
typeof CheckoutHandoffCreateRequestSchema
>;
export type CheckoutHandoffCreateResponse = z.output<
typeof CheckoutHandoffCreateResponseSchema
>;
export type CheckoutHandoffConsumeRequest = z.output<
typeof CheckoutHandoffConsumeRequestSchema
>;
export type CheckoutHandoffConsumeResponse = z.output<
typeof CheckoutHandoffConsumeResponseSchema
>;