chore: move common workspace plan/feature config to @speckle/shared (#4064)
fix: gqlgen regenerated
This commit is contained in:
committed by
GitHub
parent
735a14279e
commit
ec092fb042
@@ -0,0 +1,186 @@
|
||||
import { WorkspaceRoles } from '../../core/constants.js'
|
||||
import {
|
||||
PaidWorkspacePlans,
|
||||
UnpaidWorkspacePlans,
|
||||
WorkspacePlanBillingIntervals,
|
||||
WorkspacePlans
|
||||
} from './plans.js'
|
||||
|
||||
type StringTemplate<Data extends object> = (data: Data) => string
|
||||
|
||||
/**
|
||||
* WORKSPACE FEATURES
|
||||
*/
|
||||
|
||||
export const WorkspacePlanFeatures = <const>{
|
||||
// Core features pretty much available to everyone
|
||||
Workspace: 'workspace',
|
||||
RoleManagement: 'roleManagement',
|
||||
GuestUsers: 'guestUsers',
|
||||
PrivateAutomateFunctions: 'privateAutomateFunctions',
|
||||
// Optional/plan specific
|
||||
DomainSecurity: 'domainBasedSecurityPolicies',
|
||||
PrioritySupport: 'prioritySupport',
|
||||
SSO: 'oidcSso',
|
||||
CustomDataRegion: 'workspaceDataRegionSpecificity'
|
||||
}
|
||||
|
||||
export type WorkspacePlanFeatures =
|
||||
(typeof WorkspacePlanFeatures)[keyof typeof WorkspacePlanFeatures]
|
||||
|
||||
export const WorkspacePlanFeaturesMetadata = (<const>{
|
||||
// Old
|
||||
[WorkspacePlanFeatures.Workspace]: {
|
||||
displayName: 'Workspace',
|
||||
description: 'A shared space for your team and projects'
|
||||
},
|
||||
[WorkspacePlanFeatures.RoleManagement]: {
|
||||
displayName: 'Role management',
|
||||
description: "Control individual members' access and edit rights"
|
||||
},
|
||||
[WorkspacePlanFeatures.GuestUsers]: {
|
||||
displayName: 'Guest users',
|
||||
description: (params: { price: number | string }) =>
|
||||
`Give guests access to specific projects in the workspace at £${params.price}/month/guest`
|
||||
},
|
||||
[WorkspacePlanFeatures.PrivateAutomateFunctions]: {
|
||||
displayName: 'Private automate functions',
|
||||
description:
|
||||
'Create and manage private automation functions securely within your workspace'
|
||||
},
|
||||
[WorkspacePlanFeatures.DomainSecurity]: {
|
||||
displayName: 'Domain security',
|
||||
description: 'Require workspace members to use a verified company email'
|
||||
},
|
||||
[WorkspacePlanFeatures.SSO]: {
|
||||
displayName: 'Single Sign-On (SSO)',
|
||||
description: 'Require workspace members to log in with your SSO provider'
|
||||
},
|
||||
[WorkspacePlanFeatures.CustomDataRegion]: {
|
||||
displayName: 'Custom data residency',
|
||||
description: 'Store the workspace data in a custom region'
|
||||
},
|
||||
[WorkspacePlanFeatures.PrioritySupport]: {
|
||||
displayName: 'Priority support',
|
||||
description: 'Personal and fast support'
|
||||
}
|
||||
}) satisfies Record<
|
||||
WorkspacePlanFeatures,
|
||||
{
|
||||
displayName: string
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
description: string | StringTemplate<any>
|
||||
}
|
||||
>
|
||||
|
||||
/**
|
||||
* PLAN CONFIG - PRICES & FEATURES
|
||||
*/
|
||||
|
||||
export type WorkspacePlanPriceStructure = {
|
||||
[interval in WorkspacePlanBillingIntervals]: {
|
||||
[role in WorkspaceRoles]: number
|
||||
}
|
||||
}
|
||||
|
||||
export type WorkspacePlanConfig<Plan extends WorkspacePlans = WorkspacePlans> = {
|
||||
plan: Plan
|
||||
features: readonly WorkspacePlanFeatures[]
|
||||
}
|
||||
|
||||
const baseFeatures = [
|
||||
WorkspacePlanFeatures.Workspace,
|
||||
WorkspacePlanFeatures.RoleManagement,
|
||||
WorkspacePlanFeatures.GuestUsers,
|
||||
WorkspacePlanFeatures.PrivateAutomateFunctions
|
||||
] as const
|
||||
|
||||
export const WorkspacePaidPlanConfigs: {
|
||||
[plan in PaidWorkspacePlans]: WorkspacePlanConfig<plan>
|
||||
} = {
|
||||
// Old
|
||||
[PaidWorkspacePlans.Starter]: {
|
||||
plan: PaidWorkspacePlans.Starter,
|
||||
features: [...baseFeatures, WorkspacePlanFeatures.DomainSecurity]
|
||||
},
|
||||
[PaidWorkspacePlans.Plus]: {
|
||||
plan: PaidWorkspacePlans.Plus,
|
||||
features: [
|
||||
...baseFeatures,
|
||||
WorkspacePlanFeatures.DomainSecurity,
|
||||
WorkspacePlanFeatures.SSO
|
||||
]
|
||||
},
|
||||
[PaidWorkspacePlans.Business]: {
|
||||
plan: PaidWorkspacePlans.Business,
|
||||
features: [
|
||||
...baseFeatures,
|
||||
WorkspacePlanFeatures.DomainSecurity,
|
||||
WorkspacePlanFeatures.SSO,
|
||||
WorkspacePlanFeatures.CustomDataRegion,
|
||||
WorkspacePlanFeatures.PrioritySupport
|
||||
]
|
||||
},
|
||||
[PaidWorkspacePlans.Team]: {
|
||||
plan: PaidWorkspacePlans.Team,
|
||||
features: baseFeatures
|
||||
},
|
||||
[PaidWorkspacePlans.Pro]: {
|
||||
plan: PaidWorkspacePlans.Pro,
|
||||
features: [
|
||||
...baseFeatures,
|
||||
WorkspacePlanFeatures.DomainSecurity,
|
||||
WorkspacePlanFeatures.SSO,
|
||||
WorkspacePlanFeatures.CustomDataRegion,
|
||||
WorkspacePlanFeatures.PrioritySupport
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export const WorkspaceUnpaidPlanConfigs: {
|
||||
[plan in UnpaidWorkspacePlans]: WorkspacePlanConfig<plan>
|
||||
} = {
|
||||
// Old
|
||||
[UnpaidWorkspacePlans.Unlimited]: {
|
||||
plan: UnpaidWorkspacePlans.Unlimited,
|
||||
features: [
|
||||
...baseFeatures,
|
||||
WorkspacePlanFeatures.DomainSecurity,
|
||||
WorkspacePlanFeatures.SSO,
|
||||
WorkspacePlanFeatures.CustomDataRegion,
|
||||
WorkspacePlanFeatures.PrioritySupport
|
||||
]
|
||||
},
|
||||
[UnpaidWorkspacePlans.Academia]: {
|
||||
plan: UnpaidWorkspacePlans.Academia,
|
||||
features: [
|
||||
...baseFeatures,
|
||||
WorkspacePlanFeatures.DomainSecurity,
|
||||
WorkspacePlanFeatures.SSO,
|
||||
WorkspacePlanFeatures.CustomDataRegion,
|
||||
WorkspacePlanFeatures.PrioritySupport
|
||||
]
|
||||
},
|
||||
[UnpaidWorkspacePlans.StarterInvoiced]: {
|
||||
...WorkspacePaidPlanConfigs.starter,
|
||||
plan: UnpaidWorkspacePlans.StarterInvoiced
|
||||
},
|
||||
[UnpaidWorkspacePlans.PlusInvoiced]: {
|
||||
...WorkspacePaidPlanConfigs.plus,
|
||||
plan: UnpaidWorkspacePlans.PlusInvoiced
|
||||
},
|
||||
[UnpaidWorkspacePlans.BusinessInvoiced]: {
|
||||
...WorkspacePaidPlanConfigs.business,
|
||||
plan: UnpaidWorkspacePlans.BusinessInvoiced
|
||||
},
|
||||
// New
|
||||
[UnpaidWorkspacePlans.Free]: {
|
||||
plan: UnpaidWorkspacePlans.Free,
|
||||
features: baseFeatures
|
||||
}
|
||||
}
|
||||
|
||||
export const WorkspacePlanConfigs = {
|
||||
...WorkspacePaidPlanConfigs,
|
||||
...WorkspaceUnpaidPlanConfigs
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* PLANS
|
||||
*/
|
||||
|
||||
export const TrialEnabledPaidWorkspacePlans = <const>{
|
||||
Starter: 'starter'
|
||||
}
|
||||
|
||||
export type TrialEnabledPaidWorkspacePlans =
|
||||
(typeof TrialEnabledPaidWorkspacePlans)[keyof typeof TrialEnabledPaidWorkspacePlans]
|
||||
|
||||
export const PaidWorkspacePlansOld = <const>{
|
||||
...TrialEnabledPaidWorkspacePlans,
|
||||
Plus: 'plus',
|
||||
Business: 'business'
|
||||
}
|
||||
|
||||
export type PaidWorkspacePlansOld =
|
||||
(typeof PaidWorkspacePlansOld)[keyof typeof PaidWorkspacePlansOld]
|
||||
|
||||
export const PaidWorkspacePlansNew = <const>{
|
||||
Team: 'team',
|
||||
Pro: 'pro'
|
||||
}
|
||||
|
||||
export type PaidWorkspacePlansNew =
|
||||
(typeof PaidWorkspacePlansNew)[keyof typeof PaidWorkspacePlansNew]
|
||||
|
||||
export const PaidWorkspacePlans = <const>{
|
||||
...PaidWorkspacePlansOld,
|
||||
...PaidWorkspacePlansNew
|
||||
}
|
||||
|
||||
export type PaidWorkspacePlans =
|
||||
(typeof PaidWorkspacePlans)[keyof typeof PaidWorkspacePlans]
|
||||
|
||||
export const UnpaidWorkspacePlans = <const>{
|
||||
// Old
|
||||
Unlimited: 'unlimited',
|
||||
Academia: 'academia',
|
||||
StarterInvoiced: 'starterInvoiced',
|
||||
PlusInvoiced: 'plusInvoiced',
|
||||
BusinessInvoiced: 'businessInvoiced',
|
||||
// New
|
||||
Free: 'free'
|
||||
}
|
||||
|
||||
export type UnpaidWorkspacePlans =
|
||||
(typeof UnpaidWorkspacePlans)[keyof typeof UnpaidWorkspacePlans]
|
||||
|
||||
export const WorkspacePlans = <const>{
|
||||
...PaidWorkspacePlans,
|
||||
...UnpaidWorkspacePlans
|
||||
}
|
||||
|
||||
export type WorkspacePlans = (typeof WorkspacePlans)[keyof typeof WorkspacePlans]
|
||||
|
||||
/**
|
||||
* BILLING INTERVALS
|
||||
*/
|
||||
|
||||
export const WorkspacePlanBillingIntervals = <const>{
|
||||
Monthly: 'monthly',
|
||||
Yearly: 'yearly'
|
||||
}
|
||||
|
||||
export type WorkspacePlanBillingIntervals =
|
||||
(typeof WorkspacePlanBillingIntervals)[keyof typeof WorkspacePlanBillingIntervals]
|
||||
|
||||
/**
|
||||
* PLAN STATUSES
|
||||
*/
|
||||
|
||||
export const UnpaidWorkspacePlanStatuses = <const>{
|
||||
Valid: 'valid'
|
||||
}
|
||||
|
||||
export type UnpaidWorkspacePlanStatuses =
|
||||
(typeof UnpaidWorkspacePlanStatuses)[keyof typeof UnpaidWorkspacePlanStatuses]
|
||||
|
||||
export const PaidWorkspacePlanStatuses = <const>{
|
||||
...UnpaidWorkspacePlanStatuses,
|
||||
PaymentFailed: 'paymentFailed',
|
||||
CancelationScheduled: 'cancelationScheduled',
|
||||
Canceled: 'canceled'
|
||||
}
|
||||
|
||||
export type PaidWorkspacePlanStatuses =
|
||||
(typeof PaidWorkspacePlanStatuses)[keyof typeof PaidWorkspacePlanStatuses]
|
||||
|
||||
export const TrialWorkspacePlanStatuses = <const>{
|
||||
Trial: 'trial',
|
||||
Expired: 'expired'
|
||||
}
|
||||
|
||||
export type TrialWorkspacePlanStatuses =
|
||||
(typeof TrialWorkspacePlanStatuses)[keyof typeof TrialWorkspacePlanStatuses]
|
||||
|
||||
export const WorkspacePlanStatuses = <const>{
|
||||
...PaidWorkspacePlanStatuses,
|
||||
...TrialWorkspacePlanStatuses,
|
||||
...UnpaidWorkspacePlanStatuses
|
||||
}
|
||||
|
||||
export type WorkspacePlanStatuses =
|
||||
(typeof WorkspacePlanStatuses)[keyof typeof WorkspacePlanStatuses]
|
||||
@@ -1 +1,3 @@
|
||||
export * from './errors/index.js'
|
||||
export * from './helpers/plans.js'
|
||||
export * from './helpers/features.js'
|
||||
|
||||
Reference in New Issue
Block a user