Type updates for plan changed event
This commit is contained in:
parent
eb86127bbe
commit
a20dfa588a
|
@ -3,30 +3,28 @@ import {
|
|||
Event,
|
||||
LicenseActivatedEvent,
|
||||
LicensePlanChangedEvent,
|
||||
LicenseTierChangedEvent,
|
||||
PlanType,
|
||||
Account,
|
||||
LicensePortalOpenedEvent,
|
||||
LicenseCheckoutSuccessEvent,
|
||||
LicenseCheckoutOpenedEvent,
|
||||
LicensePaymentFailedEvent,
|
||||
LicensePaymentRecoveredEvent,
|
||||
LicensePaymentRecoveredEvent, PriceDuration,
|
||||
} from "@budibase/types"
|
||||
|
||||
async function tierChanged(account: Account, from: number, to: number) {
|
||||
const properties: LicenseTierChangedEvent = {
|
||||
accountId: account.accountId,
|
||||
to,
|
||||
from,
|
||||
}
|
||||
await publishEvent(Event.LICENSE_TIER_CHANGED, properties)
|
||||
}
|
||||
|
||||
async function planChanged(account: Account, from: PlanType, to: PlanType) {
|
||||
async function planChanged(
|
||||
account: Account,
|
||||
from: PlanType,
|
||||
to: PlanType,
|
||||
quantity: number | undefined,
|
||||
duration: PriceDuration | undefined
|
||||
) {
|
||||
const properties: LicensePlanChangedEvent = {
|
||||
accountId: account.accountId,
|
||||
to,
|
||||
from,
|
||||
quantity,
|
||||
duration
|
||||
}
|
||||
await publishEvent(Event.LICENSE_PLAN_CHANGED, properties)
|
||||
}
|
||||
|
@ -74,7 +72,6 @@ async function paymentRecovered(account: Account) {
|
|||
}
|
||||
|
||||
export default {
|
||||
tierChanged,
|
||||
planChanged,
|
||||
activated,
|
||||
checkoutOpened,
|
||||
|
|
|
@ -123,7 +123,6 @@ beforeAll(async () => {
|
|||
jest.spyOn(events.plugin, "imported")
|
||||
jest.spyOn(events.plugin, "deleted")
|
||||
|
||||
jest.spyOn(events.license, "tierChanged")
|
||||
jest.spyOn(events.license, "planChanged")
|
||||
jest.spyOn(events.license, "activated")
|
||||
jest.spyOn(events.license, "checkoutOpened")
|
||||
|
|
|
@ -39,6 +39,7 @@ export interface Account extends CreateAccount {
|
|||
// licensing
|
||||
tier: string // deprecated
|
||||
planType?: PlanType
|
||||
/** @deprecated */
|
||||
planTier?: number
|
||||
license?: License
|
||||
installId?: string
|
||||
|
|
|
@ -138,7 +138,6 @@ export enum Event {
|
|||
|
||||
// LICENSE
|
||||
LICENSE_PLAN_CHANGED = "license:plan:changed",
|
||||
LICENSE_TIER_CHANGED = "license:tier:changed",
|
||||
LICENSE_ACTIVATED = "license:activated",
|
||||
LICENSE_PAYMENT_FAILED = "license:payment:failed",
|
||||
LICENSE_PAYMENT_RECOVERED = "license:payment:recovered",
|
||||
|
@ -328,7 +327,6 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
|
|||
|
||||
// LICENSE - NOT AUDITED
|
||||
[Event.LICENSE_PLAN_CHANGED]: undefined,
|
||||
[Event.LICENSE_TIER_CHANGED]: undefined,
|
||||
[Event.LICENSE_ACTIVATED]: undefined,
|
||||
[Event.LICENSE_PAYMENT_FAILED]: undefined,
|
||||
[Event.LICENSE_PAYMENT_RECOVERED]: undefined,
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { PlanType } from "../licensing"
|
||||
|
||||
export interface LicenseTierChangedEvent {
|
||||
accountId: string
|
||||
from: number
|
||||
to: number
|
||||
}
|
||||
import { PlanType, PriceDuration } from "../licensing"
|
||||
|
||||
export interface LicensePlanChangedEvent {
|
||||
accountId: string
|
||||
from: PlanType
|
||||
to: PlanType
|
||||
// may not be on historical events
|
||||
// free plans won't have a duration
|
||||
duration: PriceDuration | undefined
|
||||
// may not be on historical events
|
||||
// free plans won't have a quantity
|
||||
quantity: number | undefined
|
||||
}
|
||||
|
||||
export interface LicenseActivatedEvent {
|
||||
|
|
Loading…
Reference in New Issue