Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,231 @@
|
||||
export const featureKeys = {
|
||||
crmBasic: "crm-basic",
|
||||
files: "files",
|
||||
tasks: "tasks",
|
||||
supportTickets: "support-tickets",
|
||||
knowledgeBaseRead: "knowledge-base-read",
|
||||
knowledgeBaseTenant: "knowledge-base-tenant",
|
||||
users: "users",
|
||||
emailMarketing: "email-marketing",
|
||||
importedLists: "imported-lists",
|
||||
crmBasedLists: "crm-based-lists",
|
||||
onboarding: "onboarding",
|
||||
api: "api",
|
||||
workflowEngine: "workflow-engine",
|
||||
mcp: "mcp",
|
||||
advancedBuilder: "advanced-builder",
|
||||
importExport: "import-export",
|
||||
rateLimitPerMinute: "rate-limit-per-minute",
|
||||
rateLimitPerSecond: "rate-limit-per-second",
|
||||
prioritySupport: "priority-support",
|
||||
credits: "ai-credits",
|
||||
privateGenerations: "private-generations",
|
||||
} as const;
|
||||
|
||||
export type FeatureKey = (typeof featureKeys)[keyof typeof featureKeys];
|
||||
|
||||
export type FeatureCategory = "access" | "usage" | "support" | "generation" | "crm" | "marketing" | "automation" | "customization";
|
||||
|
||||
export type FeatureLimitType = "not-included" | "included" | "monthly" | "max" | "unlimited";
|
||||
|
||||
export interface FeatureGateRegistryItem {
|
||||
readonly key: FeatureKey;
|
||||
readonly title: string;
|
||||
readonly category: FeatureCategory;
|
||||
readonly supportedLimitTypes: readonly FeatureLimitType[];
|
||||
readonly defaultOrder: number;
|
||||
readonly description: string;
|
||||
}
|
||||
|
||||
const accessLimitTypes = ["not-included", "included", "unlimited"] as const satisfies readonly FeatureLimitType[];
|
||||
const quotaLimitTypes = ["not-included", "monthly", "max", "unlimited"] as const satisfies readonly FeatureLimitType[];
|
||||
const rateLimitTypes = ["not-included", "max", "unlimited"] as const satisfies readonly FeatureLimitType[];
|
||||
|
||||
export const featureGateRegistry = Object.freeze([
|
||||
Object.freeze({
|
||||
key: featureKeys.crmBasic,
|
||||
title: "CRM basics",
|
||||
category: "crm",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 5,
|
||||
description: "Controls access to the default CRM account, contact, and opportunity surfaces.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.supportTickets,
|
||||
title: "Support tickets",
|
||||
category: "support",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 6,
|
||||
description: "Controls support ticket creation and ticket volume.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.knowledgeBaseRead,
|
||||
title: "Knowledge base read",
|
||||
category: "support",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 7,
|
||||
description: "Controls read access to the global and product knowledge bases.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.knowledgeBaseTenant,
|
||||
title: "Tenant knowledge base",
|
||||
category: "support",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 8,
|
||||
description: "Controls tenant-owned knowledge base authoring and publishing.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.files,
|
||||
title: "Files",
|
||||
category: "access",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 9,
|
||||
description: "Controls access to the central file storage (chunked upload, preview, sharing).",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.users,
|
||||
title: "Users",
|
||||
category: "access",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 10,
|
||||
description: "Controls the number of workspace members available to an account.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.tasks,
|
||||
title: "Tasks",
|
||||
category: "access",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 11,
|
||||
description: "Controls access to the cross-cutting task module (assignment, reminders, entity links).",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.api,
|
||||
title: "API Access",
|
||||
category: "access",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 20,
|
||||
description: "Controls whether programmatic API access is available.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.emailMarketing,
|
||||
title: "Email marketing",
|
||||
category: "marketing",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 21,
|
||||
description: "Controls email campaign creation and monthly campaign sends.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.importedLists,
|
||||
title: "Imported lists",
|
||||
category: "marketing",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 22,
|
||||
description: "Controls whether imported audience lists can be used.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.crmBasedLists,
|
||||
title: "CRM based lists",
|
||||
category: "marketing",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 23,
|
||||
description: "Controls whether CRM segments can be used as audiences.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.onboarding,
|
||||
title: "Onboarding",
|
||||
category: "access",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 24,
|
||||
description: "Controls tenant onboarding builder access.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.workflowEngine,
|
||||
title: "Workflow engine",
|
||||
category: "automation",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 25,
|
||||
description: "Controls tenant workflow builder and workflow run volume.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.mcp,
|
||||
title: "Tenant MCP",
|
||||
category: "automation",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 26,
|
||||
description: "Controls tenant MCP access when the active product blueprint enables MCP.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.advancedBuilder,
|
||||
title: "Advanced builder",
|
||||
category: "customization",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 27,
|
||||
description: "Controls advanced entity, UI, and product customization tools.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.importExport,
|
||||
title: "Import and export",
|
||||
category: "usage",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 28,
|
||||
description: "Controls import/export heavy workflows and monthly operation volume.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.rateLimitPerMinute,
|
||||
title: "Rate limit per minute",
|
||||
category: "usage",
|
||||
supportedLimitTypes: rateLimitTypes,
|
||||
defaultOrder: 30,
|
||||
description: "Controls the maximum permitted requests in a one minute window.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.rateLimitPerSecond,
|
||||
title: "Rate limit per second",
|
||||
category: "usage",
|
||||
supportedLimitTypes: rateLimitTypes,
|
||||
defaultOrder: 40,
|
||||
description: "Controls the maximum permitted requests in a one second window.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.prioritySupport,
|
||||
title: "Priority support",
|
||||
category: "support",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 50,
|
||||
description: "Controls whether priority support handling is available.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.credits,
|
||||
title: "Credits",
|
||||
category: "usage",
|
||||
supportedLimitTypes: quotaLimitTypes,
|
||||
defaultOrder: 60,
|
||||
description: "Controls the amount of metered product credits available in a billing period.",
|
||||
}),
|
||||
Object.freeze({
|
||||
key: featureKeys.privateGenerations,
|
||||
title: "Private generations",
|
||||
category: "generation",
|
||||
supportedLimitTypes: accessLimitTypes,
|
||||
defaultOrder: 70,
|
||||
description: "Controls whether generated outputs are handled with private visibility.",
|
||||
}),
|
||||
] as const satisfies readonly FeatureGateRegistryItem[]);
|
||||
|
||||
const featureGateRegistryByKey = new Map<FeatureKey, FeatureGateRegistryItem>(featureGateRegistry.map((feature) => [feature.key, feature]));
|
||||
|
||||
export function isFeatureKey(value: string): value is FeatureKey {
|
||||
return featureGateRegistryByKey.has(value as FeatureKey);
|
||||
}
|
||||
|
||||
export function getFeatureGate(featureKey: FeatureKey): FeatureGateRegistryItem;
|
||||
export function getFeatureGate(featureKey: string): FeatureGateRegistryItem | undefined;
|
||||
export function getFeatureGate(featureKey: string): FeatureGateRegistryItem | undefined {
|
||||
return isFeatureKey(featureKey) ? featureGateRegistryByKey.get(featureKey) : undefined;
|
||||
}
|
||||
|
||||
export function assertKnownFeatureKey(value: string): asserts value is FeatureKey {
|
||||
if (!isFeatureKey(value)) {
|
||||
throw new RangeError(`Unknown feature key: ${value}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user