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,82 @@
|
||||
import { featureKeys, type FeatureKey } from "./features.js";
|
||||
|
||||
export const productBlueprintIds = Object.freeze({
|
||||
crmSaas: "crm-saas",
|
||||
} as const);
|
||||
|
||||
export type ProductBlueprintId = (typeof productBlueprintIds)[keyof typeof productBlueprintIds];
|
||||
|
||||
export interface ProductBlueprintFeatureDefinition {
|
||||
readonly featureKey: FeatureKey;
|
||||
readonly defaultEnabled: boolean;
|
||||
readonly tenantToggleable: boolean;
|
||||
readonly requiresTenantRolePermission?: string;
|
||||
}
|
||||
|
||||
export interface ProductBlueprintDefinition {
|
||||
readonly id: ProductBlueprintId;
|
||||
readonly version: string;
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
readonly defaultShowcase: boolean;
|
||||
readonly features: readonly ProductBlueprintFeatureDefinition[];
|
||||
}
|
||||
|
||||
function blueprintFeature(
|
||||
featureKey: FeatureKey,
|
||||
defaultEnabled: boolean,
|
||||
tenantToggleable: boolean,
|
||||
requiresTenantRolePermission?: string
|
||||
): ProductBlueprintFeatureDefinition {
|
||||
return Object.freeze({
|
||||
featureKey,
|
||||
defaultEnabled,
|
||||
tenantToggleable,
|
||||
...(requiresTenantRolePermission ? { requiresTenantRolePermission } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
export const productBlueprints = Object.freeze([
|
||||
Object.freeze({
|
||||
id: productBlueprintIds.crmSaas,
|
||||
version: "2026.05.15",
|
||||
title: "CRM SaaS",
|
||||
description: "Default CRM SaaS product core with support, knowledge base, marketing, API, AI credits, workflow automation, and optional tenant MCP.",
|
||||
defaultShowcase: true,
|
||||
features: Object.freeze([
|
||||
blueprintFeature(featureKeys.crmBasic, true, false, "app.dashboard.view"),
|
||||
blueprintFeature(featureKeys.files, true, true, "files.read_own"),
|
||||
blueprintFeature(featureKeys.tasks, true, true, "tasks.read_own"),
|
||||
blueprintFeature(featureKeys.supportTickets, true, true, "app.dashboard.view"),
|
||||
blueprintFeature(featureKeys.knowledgeBaseRead, true, true, "app.dashboard.view"),
|
||||
blueprintFeature(featureKeys.knowledgeBaseTenant, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.emailMarketing, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.importedLists, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.crmBasedLists, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.onboarding, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.api, true, true, "app.settings.apiKeys.create"),
|
||||
blueprintFeature(featureKeys.workflowEngine, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.mcp, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.advancedBuilder, true, true, "app.settings.roles.set"),
|
||||
blueprintFeature(featureKeys.importExport, true, true, "app.dashboard.view"),
|
||||
blueprintFeature(featureKeys.credits, true, false, "app.dashboard.view"),
|
||||
blueprintFeature(featureKeys.users, true, false, "app.settings.members.view"),
|
||||
]),
|
||||
}),
|
||||
] as const satisfies readonly ProductBlueprintDefinition[]);
|
||||
|
||||
const blueprintById = new Map<ProductBlueprintId, ProductBlueprintDefinition>(productBlueprints.map((blueprint) => [blueprint.id, blueprint]));
|
||||
|
||||
export function getProductBlueprint(blueprintId: ProductBlueprintId): ProductBlueprintDefinition;
|
||||
export function getProductBlueprint(blueprintId: string): ProductBlueprintDefinition | undefined;
|
||||
export function getProductBlueprint(blueprintId: string): ProductBlueprintDefinition | undefined {
|
||||
return blueprintById.get(blueprintId as ProductBlueprintId);
|
||||
}
|
||||
|
||||
export function getDefaultProductBlueprint(): ProductBlueprintDefinition {
|
||||
const blueprint = productBlueprints.find((item) => item.defaultShowcase);
|
||||
if (!blueprint) {
|
||||
throw new Error("No default product blueprint is configured.");
|
||||
}
|
||||
return blueprint;
|
||||
}
|
||||
Reference in new issue
Block a user