diff --git a/packages/server/modules/gatekeeper/domain/constants.ts b/packages/server/modules/gatekeeper/domain/constants.ts deleted file mode 100644 index cfc6f3607..000000000 --- a/packages/server/modules/gatekeeper/domain/constants.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { z } from 'zod' - -export const workspacePlanStatusValid = z.literal('valid') -export const workspacePlanStatusPaymentFailed = z.literal('paymentFailed') -export const workspacePlanStatusCancelationScheduled = z.literal('cancelationScheduled') -export const workspacePlanStatusCanceled = z.literal('canceled') -export const workspacePlanStatusExpired = z.literal('expired') diff --git a/packages/server/modules/gatekeeper/services/readOnly.ts b/packages/server/modules/gatekeeper/services/readOnly.ts index 1e2fefcab..9c4936574 100644 --- a/packages/server/modules/gatekeeper/services/readOnly.ts +++ b/packages/server/modules/gatekeeper/services/readOnly.ts @@ -1,17 +1,6 @@ import { GetWorkspacePlan } from '@/modules/gatekeeper/domain/billing' import { Workspace } from '@/modules/workspacesCore/domain/types' -import { z } from 'zod' -import { - workspacePlanStatusCanceled, - workspacePlanStatusExpired, - workspacePlanStatusPaymentFailed -} from '@/modules/gatekeeper/domain/constants' - -const readOnlyWorkspacePlanStatuses = z.union([ - workspacePlanStatusPaymentFailed, - workspacePlanStatusCanceled, - workspacePlanStatusExpired -]) +import { throwUncoveredError } from '@speckle/shared' export const isWorkspaceReadOnlyFactory = ({ getWorkspacePlan }: { getWorkspacePlan: GetWorkspacePlan }) => @@ -20,9 +9,16 @@ export const isWorkspaceReadOnlyFactory = // Should never happen if (!workspacePlan) return true - const { success: workspaceReadOnly } = readOnlyWorkspacePlanStatuses.safeParse( - workspacePlan.status - ) - - return workspaceReadOnly + switch (workspacePlan.status) { + case 'cancelationScheduled': + case 'valid': + case 'trial': + case 'paymentFailed': + return false + case 'expired': + case 'canceled': + return true + default: + throwUncoveredError(workspacePlan) + } }