@coursebuilder/core
Version:
Core package for Course Builder
1,056 lines (1,055 loc) • 138 kB
text/typescript
import * as xstate from 'xstate';
import { MerchantCoupon } from '../../schemas/merchant-coupon-schema.cjs';
import { Product } from '../../schemas/product-schema.cjs';
import { Purchase } from '../../schemas/purchase-schema.cjs';
import { h as FormattedPrice, i as PricingOptions, j as PricingData } from '../../adapters-DK4L3hbS.cjs';
import 'zod';
import '@auth/core/adapters';
import '../../schemas/coupon-schema.cjs';
import '../../schemas/merchant-customer-schema.cjs';
import '../../schemas/merchant-product-schema.cjs';
import '../../schemas/price-schema.cjs';
import '../../schemas/purchase-user-transfer-schema.cjs';
import '../../schemas/resource-progress-schema.cjs';
import '../../schemas/user-schema.cjs';
import '../../schemas/video-resource.cjs';
import '../../schemas/upgradable-product-schema.cjs';
import '../../schemas/merchant-charge-schema.cjs';
import '../../schemas/merchant-price-schema.cjs';
import '../../schemas/content-resource-schema.cjs';
import '../../schemas/merchant-account-schema.cjs';
import '../../schemas/merchant-session.cjs';
import '../../schemas/merchant-subscription.cjs';
import '../../schemas/organization-member.cjs';
import '../../schemas/organization-schema.cjs';
import '../../schemas/subscription.cjs';
import '@auth/core';
import '@auth/core/providers/nodemailer';
import 'ai';
import 'cookie';
import 'inngest';
import 'stripe';
import '../utils/logger.cjs';
import '@auth/core/providers';
import '../../schemas/subscriber-schema.cjs';
import '../../providers/partykit.cjs';
import '../../providers/slack.cjs';
import '../../schemas/purchase-info.cjs';
import '../../schemas/subscription-info.cjs';
type PricingContextType = {
product: Product;
formattedPrice: FormattedPrice | null;
quantity: number;
isPPPActive: boolean;
isTeamPurchaseActive: boolean;
isCohort: boolean;
couponId: string | null | undefined;
activeMerchantCoupon: MerchantCoupon | null | undefined;
autoApplyPPP: boolean;
isBuyingMoreSeats: boolean;
options: PricingOptions;
userId: string | undefined;
isPreviouslyPurchased: boolean;
purchases?: Purchase[] | null;
allowPurchase: boolean;
pricingData: PricingData;
organizationId?: string | undefined;
};
type PricingMachineInput = {
product: Product;
quantity?: number;
couponId?: string | null;
autoApplyPPP?: boolean;
options?: Partial<PricingOptions>;
userId?: string | undefined;
pricingDataLoader: Promise<PricingData>;
allowPurchase?: boolean;
quantityAvailable?: number;
pricingData?: PricingData;
organizationId?: string | undefined;
};
declare const defaultPricingOptions: {
withImage: boolean;
withTitle: boolean;
withGuaranteeBadge: boolean;
isLiveEvent: boolean;
isCohort: boolean;
isPPPEnabled: boolean;
teamQuantityLimit: number;
allowTeamPurchase: boolean;
cancelUrl: string;
};
declare const pricingMachine: xstate.StateMachine<PricingContextType, {
type: 'UPDATE_QUANTITY';
quantity: number;
} | {
type: 'TOGGLE_TEAM_PURCHASE';
} | {
type: 'TOGGLE_BUYING_MORE_SEATS';
} | {
type: 'PURCHASE_INITIATED';
} | {
type: 'SET_MERCHANT_COUPON';
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
}, {
[x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<FormattedPrice | null, {
productId: string;
quantity?: number | undefined;
couponId?: string | undefined;
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
autoApplyPPP?: boolean | undefined;
}, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
createdAt?: Date | null | undefined;
name?: string | null | undefined;
image?: string | null | undefined;
emailVerified?: Date | null | undefined;
} | null | undefined;
ipAddress?: string | null | undefined;
city?: string | null | undefined;
country?: string | null | undefined;
merchantChargeId?: string | null | undefined;
upgradedFromId?: string | null | undefined;
bulkCouponId?: string | null | undefined;
merchantSessionId?: string | null | undefined;
redeemedBulkCouponId?: string | null | undefined;
bulkCoupon?: {
status: number;
id: string;
createdAt: Date | null;
expires: Date | null;
fields: Record<string, any>;
maxUses: number;
default: boolean;
usedCount: number;
percentageDiscount: number;
bulkPurchases: any[];
redeemedBulkCouponPurchases: any[];
organizationId?: string | null | undefined;
code?: string | null | undefined;
merchantCouponId?: string | null | undefined;
restrictedToProductId?: string | null | undefined;
bulkPurchaseId?: string | null | undefined;
} | null | undefined;
purchasedByorganizationMembershipId?: string | null | undefined;
}[] | undefined;
}, {
userId: string;
productId: string;
}, xstate.EventObject>> | undefined;
}, xstate.Values<{
loadFormattedPrices: {
src: "loadFormattedPrices";
logic: xstate.PromiseActorLogic<FormattedPrice | null, {
productId: string;
quantity?: number | undefined;
couponId?: string | undefined;
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
autoApplyPPP?: boolean | undefined;
}, xstate.EventObject>;
id: string | undefined;
};
loadPurchases: {
src: "loadPurchases";
logic: xstate.PromiseActorLogic<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
createdAt?: Date | null | undefined;
name?: string | null | undefined;
image?: string | null | undefined;
emailVerified?: Date | null | undefined;
} | null | undefined;
ipAddress?: string | null | undefined;
city?: string | null | undefined;
country?: string | null | undefined;
merchantChargeId?: string | null | undefined;
upgradedFromId?: string | null | undefined;
bulkCouponId?: string | null | undefined;
merchantSessionId?: string | null | undefined;
redeemedBulkCouponId?: string | null | undefined;
bulkCoupon?: {
status: number;
id: string;
createdAt: Date | null;
expires: Date | null;
fields: Record<string, any>;
maxUses: number;
default: boolean;
usedCount: number;
percentageDiscount: number;
bulkPurchases: any[];
redeemedBulkCouponPurchases: any[];
organizationId?: string | null | undefined;
code?: string | null | undefined;
merchantCouponId?: string | null | undefined;
restrictedToProductId?: string | null | undefined;
bulkPurchaseId?: string | null | undefined;
} | null | undefined;
purchasedByorganizationMembershipId?: string | null | undefined;
}[] | undefined;
}, {
userId: string;
productId: string;
}, xstate.EventObject>;
id: string | undefined;
};
}>, never, xstate.Values<{
canToggleTeamPurchase: {
type: "canToggleTeamPurchase";
params: unknown;
};
isPPPAvailable: {
type: "isPPPAvailable";
params: unknown;
};
canUpdateQuantity: {
type: "canUpdateQuantity";
params: unknown;
};
}>, never, "Loading Pricing Data" | "Ready To Buy" | "Debouncing Quantity" | "Purchasing", string, PricingMachineInput, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
readonly context: ({ input }: {
spawn: {
<TSrc extends "loadFormattedPrices" | "loadPurchases">(logic: TSrc, ...[options]: ({
src: "loadFormattedPrices";
logic: xstate.PromiseActorLogic<FormattedPrice | null, {
productId: string;
quantity?: number | undefined;
couponId?: string | undefined;
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
autoApplyPPP?: boolean | undefined;
}, xstate.EventObject>;
id: string | undefined;
} extends infer T ? T extends {
src: "loadFormattedPrices";
logic: xstate.PromiseActorLogic<FormattedPrice | null, {
productId: string;
quantity?: number | undefined;
couponId?: string | undefined;
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
autoApplyPPP?: boolean | undefined;
}, xstate.EventObject>;
id: string | undefined;
} ? T extends {
src: TSrc;
} ? xstate.ConditionalRequired<[options?: ({
id?: T["id"] | undefined;
systemId?: string | undefined;
input?: xstate.InputFrom<T["logic"]> | undefined;
syncSnapshot?: boolean | undefined;
} & { [K in xstate.RequiredActorOptions<T>]: unknown; }) | undefined], xstate.IsNotNever<xstate.RequiredActorOptions<T>>> : never : never : never) | ({
src: "loadPurchases";
logic: xstate.PromiseActorLogic<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
createdAt?: Date | null | undefined;
name?: string | null | undefined;
image?: string | null | undefined;
emailVerified?: Date | null | undefined;
} | null | undefined;
ipAddress?: string | null | undefined;
city?: string | null | undefined;
country?: string | null | undefined;
merchantChargeId?: string | null | undefined;
upgradedFromId?: string | null | undefined;
bulkCouponId?: string | null | undefined;
merchantSessionId?: string | null | undefined;
redeemedBulkCouponId?: string | null | undefined;
bulkCoupon?: {
status: number;
id: string;
createdAt: Date | null;
expires: Date | null;
fields: Record<string, any>;
maxUses: number;
default: boolean;
usedCount: number;
percentageDiscount: number;
bulkPurchases: any[];
redeemedBulkCouponPurchases: any[];
organizationId?: string | null | undefined;
code?: string | null | undefined;
merchantCouponId?: string | null | undefined;
restrictedToProductId?: string | null | undefined;
bulkPurchaseId?: string | null | undefined;
} | null | undefined;
purchasedByorganizationMembershipId?: string | null | undefined;
}[] | undefined;
}, {
userId: string;
productId: string;
}, xstate.EventObject>;
id: string | undefined;
} extends infer T_1 ? T_1 extends {
src: "loadPurchases";
logic: xstate.PromiseActorLogic<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
createdAt?: Date | null | undefined;
name?: string | null | undefined;
image?: string | null | undefined;
emailVerified?: Date | null | undefined;
} | null | undefined;
ipAddress?: string | null | undefined;
city?: string | null | undefined;
country?: string | null | undefined;
merchantChargeId?: string | null | undefined;
upgradedFromId?: string | null | undefined;
bulkCouponId?: string | null | undefined;
merchantSessionId?: string | null | undefined;
redeemedBulkCouponId?: string | null | undefined;
bulkCoupon?: {
status: number;
id: string;
createdAt: Date | null;
expires: Date | null;
fields: Record<string, any>;
maxUses: number;
default: boolean;
usedCount: number;
percentageDiscount: number;
bulkPurchases: any[];
redeemedBulkCouponPurchases: any[];
organizationId?: string | null | undefined;
code?: string | null | undefined;
merchantCouponId?: string | null | undefined;
restrictedToProductId?: string | null | undefined;
bulkPurchaseId?: string | null | undefined;
} | null | undefined;
purchasedByorganizationMembershipId?: string | null | undefined;
}[] | undefined;
}, {
userId: string;
productId: string;
}, xstate.EventObject>;
id: string | undefined;
} ? T_1 extends {
src: TSrc;
} ? xstate.ConditionalRequired<[options?: ({
id?: T_1["id"] | undefined;
systemId?: string | undefined;
input?: xstate.InputFrom<T_1["logic"]> | undefined;
syncSnapshot?: boolean | undefined;
} & { [K_1 in xstate.RequiredActorOptions<T_1>]: unknown; }) | undefined], xstate.IsNotNever<xstate.RequiredActorOptions<T_1>>> : never : never : never)): xstate.ActorRefFromLogic<xstate.GetConcreteByKey<xstate.Values<{
loadFormattedPrices: {
src: "loadFormattedPrices";
logic: xstate.PromiseActorLogic<FormattedPrice | null, {
productId: string;
quantity?: number | undefined;
couponId?: string | undefined;
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
autoApplyPPP?: boolean | undefined;
}, xstate.EventObject>;
id: string | undefined;
};
loadPurchases: {
src: "loadPurchases";
logic: xstate.PromiseActorLogic<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
createdAt?: Date | null | undefined;
name?: string | null | undefined;
image?: string | null | undefined;
emailVerified?: Date | null | undefined;
} | null | undefined;
ipAddress?: string | null | undefined;
city?: string | null | undefined;
country?: string | null | undefined;
merchantChargeId?: string | null | undefined;
upgradedFromId?: string | null | undefined;
bulkCouponId?: string | null | undefined;
merchantSessionId?: string | null | undefined;
redeemedBulkCouponId?: string | null | undefined;
bulkCoupon?: {
status: number;
id: string;
createdAt: Date | null;
expires: Date | null;
fields: Record<string, any>;
maxUses: number;
default: boolean;
usedCount: number;
percentageDiscount: number;
bulkPurchases: any[];
redeemedBulkCouponPurchases: any[];
organizationId?: string | null | undefined;
code?: string | null | undefined;
merchantCouponId?: string | null | undefined;
restrictedToProductId?: string | null | undefined;
bulkPurchaseId?: string | null | undefined;
} | null | undefined;
purchasedByorganizationMembershipId?: string | null | undefined;
}[] | undefined;
}, {
userId: string;
productId: string;
}, xstate.EventObject>;
id: string | undefined;
};
}>, "src", TSrc>["logic"]>;
<TLogic extends xstate.AnyActorLogic>(src: TLogic, ...[options]: xstate.ConditionalRequired<[options?: ({
id?: undefined;
systemId?: string | undefined;
input?: xstate.InputFrom<TLogic> | undefined;
syncSnapshot?: boolean | undefined;
} & { [K_2 in xstate.RequiredLogicInput<TLogic>]: unknown; }) | undefined], xstate.IsNotNever<xstate.RequiredLogicInput<TLogic>>>): xstate.ActorRefFromLogic<TLogic>;
};
input: PricingMachineInput;
self: xstate.ActorRef<xstate.MachineSnapshot<PricingContextType, {
type: 'UPDATE_QUANTITY';
quantity: number;
} | {
type: 'TOGGLE_TEAM_PURCHASE';
} | {
type: 'TOGGLE_BUYING_MORE_SEATS';
} | {
type: 'PURCHASE_INITIATED';
} | {
type: 'SET_MERCHANT_COUPON';
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
}, Record<string, xstate.AnyActorRef | undefined>, xstate.StateValue, string, unknown, any, any>, {
type: 'UPDATE_QUANTITY';
quantity: number;
} | {
type: 'TOGGLE_TEAM_PURCHASE';
} | {
type: 'TOGGLE_BUYING_MORE_SEATS';
} | {
type: 'PURCHASE_INITIATED';
} | {
type: 'SET_MERCHANT_COUPON';
merchantCoupon?: {
type: string;
status: number;
id: string;
percentageDiscount: number;
merchantAccountId: string;
identifier?: string | null | undefined;
} | undefined;
}, xstate.AnyEventObject>;
}) => {
product: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
};
formattedPrice: null;
quantity: number;
isPPPActive: false;
isTeamPurchaseActive: false;
isCohort: boolean;
couponId: string | null;
activeMerchantCoupon: null;
autoApplyPPP: boolean;
isBuyingMoreSeats: false;
options: {
withImage: boolean;
withTitle: boolean;
withGuaranteeBadge: boolean;
isLiveEvent: boolean;
isCohort: boolean;
isPPPEnabled: boolean;
teamQuantityLimit: number;
allowTeamPurchase: boolean;
cancelUrl: string;
};
userId: string | undefined;
isPreviouslyPurchased: false;
allowPurchase: true;
pricingData: PricingData;
purchases: null;
organizationId: string | undefined;
};
readonly id: "Pricing Display";
readonly initial: "Loading Pricing Data";
readonly states: {
readonly 'Loading Pricing Data': {
readonly invoke: readonly [{
readonly id: "load-purchases";
readonly src: "loadPurchases";
readonly input: ({ context }: any) => {
userId: any;
productId: any;
};
readonly onDone: {
readonly actions: xstate.ActionFunction<PricingContextType, xstate.DoneActorEvent<{
isPreviouslyPurchased: boolean;
purchases?: {
productId: string;
status: string;
id: string;
createdAt: Date;
fields: Record<string, any>;
totalAmount: number;
couponId?: string | null | undefined;
userId?: string | null | undefined;
organizationId?: string | null | undefined;
product?: {
type: "live" | "self-paced" | "membership" | "cohort";
status: number;
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;
};
resources: {
productId: string;
createdAt: Date | null;
resourceId: string;
position: number;
metadata: Record<string, any> | null;
updatedAt: Date | null;
deletedAt: Date | null;
resource?: any;
product?: any;
}[] | null;
name: string;
quantityAvailable: number;
organizationId?: string | null | undefined;
key?: string | null | undefined;
price?: {
status: number;
id: string;
createdAt: Date | null;
fields: Record<string, any>;
unitAmount: number;
productId?: string | null | undefined;
organizationId?: string | null | undefined;
nickname?: string | null | undefined;
} | null | undefined;
} | null | undefined;
state?: string | null | undefined;
user?: {
id: string;
role: "user" | "admin";
email: string;
memberships: {
organizationId: string;
id: string;
}[] | null;
roles: {
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefined;
updatedAt?: Date | null | undefined;
deletedAt?: Date | null | undefined;
}[];
organizationRoles: {
organizationId: string;
id: string;
name: string;
description: string | null;
active: boolean;
createdAt?: Date | null | undefine