UNPKG

@coursebuilder/core

Version:

Core package for Course Builder

561 lines (558 loc) 21.8 kB
import { z } from 'zod'; import { c as CourseBuilderAdapter, M as MinimalMerchantCoupon } from '../../adapters-BjQ3VSch.js'; import '@auth/core/adapters'; import '../../schemas/coupon-schema.js'; import '../../schemas/merchant-coupon-schema.js'; import '../../schemas/merchant-customer-schema.js'; import '../../schemas/merchant-product-schema.js'; import '../../schemas/price-schema.js'; import '../../schemas/product-schema.js'; import '../../schemas/purchase-schema.js'; import '../../schemas/purchase-user-transfer-schema.js'; import '../../schemas/resource-progress-schema.js'; import '../../schemas/user-schema.js'; import '../../schemas/video-resource.js'; import '../../schemas/upgradable-product-schema.js'; import '../../schemas/merchant-charge-schema.js'; import '../../schemas/merchant-price-schema.js'; import '../../schemas/content-resource-schema.js'; import '../../schemas/merchant-account-schema.js'; import '../../schemas/merchant-session.js'; import '../../schemas/merchant-subscription.js'; import '../../schemas/organization-member.js'; import '../../schemas/organization-schema.js'; import '../../schemas/subscription.js'; import '@auth/core'; import '@auth/core/providers/nodemailer'; import 'ai'; import 'cookie'; import 'inngest'; import 'stripe'; import '../utils/logger.js'; import '@auth/core/providers'; import '../../schemas/subscriber-schema.js'; import '../../providers/partykit.js'; import '../../providers/slack.js'; import '../../schemas/purchase-info.js'; import '../../schemas/subscription-info.js'; declare const DetermineCouponToApplyParamsSchema: z.ZodObject<{ prismaCtx: z.ZodType<CourseBuilderAdapter<any>, z.ZodTypeDef, CourseBuilderAdapter<any>>; merchantCouponId: z.ZodOptional<z.ZodString>; country: z.ZodString; quantity: z.ZodNumber; userId: z.ZodOptional<z.ZodString>; productId: z.ZodString; purchaseToBeUpgraded: z.ZodNullable<z.ZodType<{ id: string; createdAt: Date; fields: Record<string, any>; status: string; productId: string; totalAmount: number; organizationId?: string | null | undefined; userId?: string | null | undefined; product?: { type: "live" | "self-paced" | "membership" | "cohort"; name: string; id: string; createdAt: Date | null; fields: { slug: string; action: string | null; state: "draft" | "published" | "archived" | "deleted"; visibility: "public" | "private" | "unlisted"; body?: string | null | undefined; description?: string | null | undefined; image?: { url: string; alt?: string | null | undefined; width?: number | null | undefined; height?: number | null | undefined; } | null | undefined; }; status: number; resources: { createdAt: Date | null; productId: string; resourceId: string; position: number; metadata: Record<string, any> | null; updatedAt: Date | null; deletedAt: Date | null; resource?: any; product?: any; }[] | null; quantityAvailable: number; organizationId?: string | null | undefined; key?: string | null | undefined; price?: { id: string; createdAt: Date | null; fields: Record<string, any>; status: number; unitAmount: number; organizationId?: string | null | undefined; productId?: string | null | undefined; nickname?: string | null | undefined; } | null | undefined; } | null | undefined; state?: string | null | undefined; user?: { id: string; role: "user" | "admin"; email: string; memberships: { id: string; organizationId: string; }[] | null; roles: { name: string; id: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; organizationRoles: { name: string; id: string; organizationId: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; name?: string | null | undefined; createdAt?: Date | null | undefined; image?: string | null | undefined; emailVerified?: Date | null | undefined; } | null | undefined; ipAddress?: string | null | undefined; city?: string | null | undefined; country?: string | null | undefined; couponId?: string | null | undefined; merchantChargeId?: string | null | undefined; upgradedFromId?: string | null | undefined; bulkCouponId?: string | null | undefined; merchantSessionId?: string | null | undefined; redeemedBulkCouponId?: string | null | undefined; bulkCoupon?: { id: string; createdAt: Date | null; expires: Date | null; fields: Record<string, any>; maxUses: number; default: boolean; status: number; usedCount: number; percentageDiscount: number; bulkPurchases: any[]; redeemedBulkCouponPurchases: any[]; code?: string | null | undefined; merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; bulkPurchaseId?: string | null | undefined; organizationId?: string | null | undefined; } | null | undefined; purchasedByorganizationMembershipId?: string | null | undefined; }, z.ZodTypeDef, { id: string; createdAt: Date; fields: Record<string, any>; status: string; productId: string; totalAmount: number; organizationId?: string | null | undefined; userId?: string | null | undefined; product?: { type: "live" | "self-paced" | "membership" | "cohort"; name: string; id: string; createdAt: Date | null; fields: { slug: string; action: string | null; state: "draft" | "published" | "archived" | "deleted"; visibility: "public" | "private" | "unlisted"; body?: string | null | undefined; description?: string | null | undefined; image?: { url: string; alt?: string | null | undefined; width?: number | null | undefined; height?: number | null | undefined; } | null | undefined; }; status: number; resources: { createdAt: Date | null; productId: string; resourceId: string; position: number; metadata: Record<string, any> | null; updatedAt: Date | null; deletedAt: Date | null; resource?: any; product?: any; }[] | null; quantityAvailable: number; organizationId?: string | null | undefined; key?: string | null | undefined; price?: { id: string; createdAt: Date | null; fields: Record<string, any>; status: number; unitAmount: number; organizationId?: string | null | undefined; productId?: string | null | undefined; nickname?: string | null | undefined; } | null | undefined; } | null | undefined; state?: string | null | undefined; user?: { id: string; role: "user" | "admin"; email: string; memberships: { id: string; organizationId: string; }[] | null; roles: { name: string; id: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; organizationRoles: { name: string; id: string; organizationId: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; name?: string | null | undefined; createdAt?: Date | null | undefined; image?: string | null | undefined; emailVerified?: Date | null | undefined; } | null | undefined; ipAddress?: string | null | undefined; city?: string | null | undefined; country?: string | null | undefined; couponId?: string | null | undefined; merchantChargeId?: string | null | undefined; upgradedFromId?: string | null | undefined; bulkCouponId?: string | null | undefined; merchantSessionId?: string | null | undefined; redeemedBulkCouponId?: string | null | undefined; bulkCoupon?: { id: string; createdAt: Date | null; expires: Date | null; fields: Record<string, any>; maxUses: number; default: boolean; status: number; usedCount: number; percentageDiscount: number; bulkPurchases: any[]; redeemedBulkCouponPurchases: any[]; code?: string | null | undefined; merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; bulkPurchaseId?: string | null | undefined; organizationId?: string | null | undefined; } | null | undefined; purchasedByorganizationMembershipId?: string | null | undefined; }>>; autoApplyPPP: z.ZodBoolean; usedCoupon: z.ZodOptional<z.ZodNullable<z.ZodObject<{ merchantCouponId: z.ZodOptional<z.ZodNullable<z.ZodString>>; restrictedToProductId: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; }, { merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { productId: string; country: string; prismaCtx: CourseBuilderAdapter<any>; quantity: number; purchaseToBeUpgraded: { id: string; createdAt: Date; fields: Record<string, any>; status: string; productId: string; totalAmount: number; organizationId?: string | null | undefined; userId?: string | null | undefined; product?: { type: "live" | "self-paced" | "membership" | "cohort"; name: string; id: string; createdAt: Date | null; fields: { slug: string; action: string | null; state: "draft" | "published" | "archived" | "deleted"; visibility: "public" | "private" | "unlisted"; body?: string | null | undefined; description?: string | null | undefined; image?: { url: string; alt?: string | null | undefined; width?: number | null | undefined; height?: number | null | undefined; } | null | undefined; }; status: number; resources: { createdAt: Date | null; productId: string; resourceId: string; position: number; metadata: Record<string, any> | null; updatedAt: Date | null; deletedAt: Date | null; resource?: any; product?: any; }[] | null; quantityAvailable: number; organizationId?: string | null | undefined; key?: string | null | undefined; price?: { id: string; createdAt: Date | null; fields: Record<string, any>; status: number; unitAmount: number; organizationId?: string | null | undefined; productId?: string | null | undefined; nickname?: string | null | undefined; } | null | undefined; } | null | undefined; state?: string | null | undefined; user?: { id: string; role: "user" | "admin"; email: string; memberships: { id: string; organizationId: string; }[] | null; roles: { name: string; id: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; organizationRoles: { name: string; id: string; organizationId: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; name?: string | null | undefined; createdAt?: Date | null | undefined; image?: string | null | undefined; emailVerified?: Date | null | undefined; } | null | undefined; ipAddress?: string | null | undefined; city?: string | null | undefined; country?: string | null | undefined; couponId?: string | null | undefined; merchantChargeId?: string | null | undefined; upgradedFromId?: string | null | undefined; bulkCouponId?: string | null | undefined; merchantSessionId?: string | null | undefined; redeemedBulkCouponId?: string | null | undefined; bulkCoupon?: { id: string; createdAt: Date | null; expires: Date | null; fields: Record<string, any>; maxUses: number; default: boolean; status: number; usedCount: number; percentageDiscount: number; bulkPurchases: any[]; redeemedBulkCouponPurchases: any[]; code?: string | null | undefined; merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; bulkPurchaseId?: string | null | undefined; organizationId?: string | null | undefined; } | null | undefined; purchasedByorganizationMembershipId?: string | null | undefined; } | null; autoApplyPPP: boolean; merchantCouponId?: string | undefined; userId?: string | undefined; usedCoupon?: { merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; } | null | undefined; }, { productId: string; country: string; prismaCtx: CourseBuilderAdapter<any>; quantity: number; purchaseToBeUpgraded: { id: string; createdAt: Date; fields: Record<string, any>; status: string; productId: string; totalAmount: number; organizationId?: string | null | undefined; userId?: string | null | undefined; product?: { type: "live" | "self-paced" | "membership" | "cohort"; name: string; id: string; createdAt: Date | null; fields: { slug: string; action: string | null; state: "draft" | "published" | "archived" | "deleted"; visibility: "public" | "private" | "unlisted"; body?: string | null | undefined; description?: string | null | undefined; image?: { url: string; alt?: string | null | undefined; width?: number | null | undefined; height?: number | null | undefined; } | null | undefined; }; status: number; resources: { createdAt: Date | null; productId: string; resourceId: string; position: number; metadata: Record<string, any> | null; updatedAt: Date | null; deletedAt: Date | null; resource?: any; product?: any; }[] | null; quantityAvailable: number; organizationId?: string | null | undefined; key?: string | null | undefined; price?: { id: string; createdAt: Date | null; fields: Record<string, any>; status: number; unitAmount: number; organizationId?: string | null | undefined; productId?: string | null | undefined; nickname?: string | null | undefined; } | null | undefined; } | null | undefined; state?: string | null | undefined; user?: { id: string; role: "user" | "admin"; email: string; memberships: { id: string; organizationId: string; }[] | null; roles: { name: string; id: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; organizationRoles: { name: string; id: string; organizationId: string; description: string | null; active: boolean; createdAt?: Date | null | undefined; updatedAt?: Date | null | undefined; deletedAt?: Date | null | undefined; }[]; name?: string | null | undefined; createdAt?: Date | null | undefined; image?: string | null | undefined; emailVerified?: Date | null | undefined; } | null | undefined; ipAddress?: string | null | undefined; city?: string | null | undefined; country?: string | null | undefined; couponId?: string | null | undefined; merchantChargeId?: string | null | undefined; upgradedFromId?: string | null | undefined; bulkCouponId?: string | null | undefined; merchantSessionId?: string | null | undefined; redeemedBulkCouponId?: string | null | undefined; bulkCoupon?: { id: string; createdAt: Date | null; expires: Date | null; fields: Record<string, any>; maxUses: number; default: boolean; status: number; usedCount: number; percentageDiscount: number; bulkPurchases: any[]; redeemedBulkCouponPurchases: any[]; code?: string | null | undefined; merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; bulkPurchaseId?: string | null | undefined; organizationId?: string | null | undefined; } | null | undefined; purchasedByorganizationMembershipId?: string | null | undefined; } | null; autoApplyPPP: boolean; merchantCouponId?: string | undefined; userId?: string | undefined; usedCoupon?: { merchantCouponId?: string | null | undefined; restrictedToProductId?: string | null | undefined; } | null | undefined; }>; type DetermineCouponToApplyParams = z.infer<typeof DetermineCouponToApplyParamsSchema>; declare const determineCouponToApply: (params: DetermineCouponToApplyParams) => Promise<{ appliedMerchantCoupon: MinimalMerchantCoupon | undefined; appliedCouponType: "bulk" | "special" | "ppp" | "none"; availableCoupons: never[] | { country?: string | undefined; type: string; id: string; status: number; percentageDiscount: number; merchantAccountId: string; }[]; bulk: boolean; }>; export { determineCouponToApply };