@burdenoff/microfe-botmanor 2026.1027.2 → 2026.1027.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/BotlitRoutes.js +142 -132
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/components/AgentApprovalPanel.js +144 -126
- package/dist/botlit/components/AgentApprovalPanel.js.map +1 -1
- package/dist/botlit/components/ModelRegistrationPanel.js +4 -4
- package/dist/botlit/components/VersionHistoryPanel.js +92 -83
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
- package/dist/botlit/pages/A2AAgentDetailPage.js +212 -203
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/A2ARegistryPage.js +129 -117
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
- package/dist/botlit/pages/AgentApprovalsPage.js +122 -110
- package/dist/botlit/pages/AgentApprovalsPage.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.js +18 -18
- package/dist/botlit/pages/AgentDetailPage.js +298 -273
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentsListPage.js +145 -121
- package/dist/botlit/pages/AgentsListPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +238 -226
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.js +307 -288
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotWorkflowTab.js +125 -116
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.js +159 -144
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/pages/BucketsPage.js +279 -258
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.js +346 -328
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelRoutesPage.js +10 -10
- package/dist/botlit/pages/ChannelsPage.js +163 -148
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/DashboardPage.js +129 -114
- package/dist/botlit/pages/DashboardPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionDetailPage.js +145 -139
- package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.js +14 -14
- package/dist/botlit/pages/InstalledPackagesPage.js +245 -227
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +168 -156
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBasesPage.js +91 -79
- package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -1
- package/dist/botlit/pages/MCPServerDetailPage.js +200 -188
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
- package/dist/botlit/pages/MCPServersPage.js +170 -155
- package/dist/botlit/pages/MCPServersPage.js.map +1 -1
- package/dist/botlit/pages/PoliciesPage.js +113 -104
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.js +145 -133
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.js +106 -97
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.js +359 -347
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplatesPage.js +127 -112
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +219 -210
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfilesPage.js +112 -103
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.js +264 -252
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.js +235 -226
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillsPage.js +115 -106
- package/dist/botlit/pages/SkillsPage.js.map +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.js +194 -188
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.js +161 -155
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/permissions/PermissionRequired.js +45 -0
- package/dist/botlit/permissions/PermissionRequired.js.map +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js +72 -0
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -0
- package/dist/botlit/permissions/index.js +3 -0
- package/dist/botlit/permissions/useBotmanorPermissions.js +19 -0
- package/dist/botlit/permissions/useBotmanorPermissions.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { useBotlit as t } from "../providers/BotlitProvider.js";
|
|
3
|
+
import { BotmanorPermissionGate as n } from "./useBotmanorPermissions.js";
|
|
4
|
+
import { PageLayout as r } from "../components/PageLayout.js";
|
|
5
|
+
import { Button as i } from "../components/Button.js";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
import { Lock as s } from "lucide-react";
|
|
8
|
+
//#region src/botlit/permissions/PermissionRequired.tsx
|
|
9
|
+
var c = ({ title: n, backTo: c, backLabel: l }) => {
|
|
10
|
+
let u = e(), { navigateTo: d } = t();
|
|
11
|
+
return /* @__PURE__ */ a(r, {
|
|
12
|
+
title: n,
|
|
13
|
+
children: /* @__PURE__ */ o("div", {
|
|
14
|
+
role: "status",
|
|
15
|
+
className: "flex flex-col items-center justify-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-4 py-12 text-center",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ a(s, {
|
|
18
|
+
size: 28,
|
|
19
|
+
className: "text-text-secondary"
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ o("div", { children: [/* @__PURE__ */ a("h2", {
|
|
22
|
+
className: "text-lg font-medium text-text-primary",
|
|
23
|
+
children: u("permissions.required.title", "You do not have access to this action")
|
|
24
|
+
}), /* @__PURE__ */ a("p", {
|
|
25
|
+
className: "mt-2 max-w-md text-sm text-text-secondary",
|
|
26
|
+
children: u("permissions.required.description", "Your role in this workspace can view BotManor resources but not change them. Ask a workspace admin for edit access.")
|
|
27
|
+
})] }),
|
|
28
|
+
/* @__PURE__ */ a(i, {
|
|
29
|
+
variant: "outline",
|
|
30
|
+
size: "sm",
|
|
31
|
+
onClick: () => d(c),
|
|
32
|
+
children: l
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}, l = ({ permission: e, children: t, ...r }) => /* @__PURE__ */ a(n, {
|
|
38
|
+
permission: e,
|
|
39
|
+
fallback: /* @__PURE__ */ a(c, { ...r }),
|
|
40
|
+
children: t
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { c as PermissionRequiredState, l as RequirePermission };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=PermissionRequired.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionRequired.js","names":[],"sources":["../../../src/botlit/permissions/PermissionRequired.tsx"],"sourcesContent":["/**\n * Permission-required state\n * @module botlit/permissions\n *\n * Shown in place of a create form when a member opens a `/new` route (from a\n * bookmark or a pasted link) without the permission to create that resource.\n * The member still sees where they are and how to get back; they are not shown\n * a form whose submit the gateway would refuse.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { Lock } from 'lucide-react';\n\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { PageLayout } from '../components/PageLayout';\nimport { Button } from '../components/Button';\nimport type { BotmanorPermission } from './botmanorPermissions';\nimport { BotmanorPermissionGate } from './useBotmanorPermissions';\n\nexport interface PermissionRequiredStateProps {\n /** Page title, e.g. \"Create Policy\". */\n title: string;\n /** Where \"Back\" goes, relative to the BotManor mount (e.g. `policies`). */\n backTo: string;\n /** Label for the back link, e.g. \"Back to policies\". */\n backLabel: string;\n}\n\nexport const PermissionRequiredState: FC<PermissionRequiredStateProps> = ({\n title,\n backTo,\n backLabel,\n}) => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n return (\n <PageLayout title={title}>\n <div\n role=\"status\"\n className=\"flex flex-col items-center justify-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-4 py-12 text-center\"\n >\n <Lock size={28} className=\"text-text-secondary\" />\n <div>\n <h2 className=\"text-lg font-medium text-text-primary\">\n {t('permissions.required.title', 'You do not have access to this action')}\n </h2>\n <p className=\"mt-2 max-w-md text-sm text-text-secondary\">\n {t(\n 'permissions.required.description',\n 'Your role in this workspace can view BotManor resources but not change them. Ask a workspace admin for edit access.'\n )}\n </p>\n </div>\n <Button variant=\"outline\" size=\"sm\" onClick={() => navigateTo(backTo)}>\n {backLabel}\n </Button>\n </div>\n </PageLayout>\n );\n};\n\nexport interface RequirePermissionProps extends PermissionRequiredStateProps {\n permission: BotmanorPermission;\n children: ReactNode;\n}\n\n/**\n * Render a create page only for members who may create; everyone else gets the\n * permission-required state. Nothing renders while permissions load.\n */\nexport const RequirePermission: FC<RequirePermissionProps> = ({\n permission,\n children,\n ...state\n}) => (\n <BotmanorPermissionGate permission={permission} fallback={<PermissionRequiredState {...state} />}>\n {children}\n </BotmanorPermissionGate>\n);\n"],"mappings":";;;;;;;;AA6BA,IAAa,KAA6D,EACxE,UACA,WACA,mBACI;CACJ,IAAM,IAAI,GAAO,EACX,EAAE,kBAAe,GAAW;AAClC,QACE,kBAAC,GAAD;EAAmB;YACjB,kBAAC,OAAD;GACE,MAAK;GACL,WAAU;aAFZ;IAIE,kBAAC,GAAD;KAAM,MAAM;KAAI,WAAU;KAAwB,CAAA;IAClD,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;KAAI,WAAU;eACX,EAAE,8BAA8B,wCAAwC;KACtE,CAAA,EACL,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,oCACA,sHACD;KACC,CAAA,CACA,EAAA,CAAA;IACN,kBAAC,GAAD;KAAQ,SAAQ;KAAU,MAAK;KAAK,eAAe,EAAW,EAAO;eAClE;KACM,CAAA;IACL;;EACK,CAAA;GAaJ,KAAiD,EAC5D,eACA,aACA,GAAG,QAEH,kBAAC,GAAD;CAAoC;CAAY,UAAU,kBAAC,GAAD,EAAyB,GAAI,GAAS,CAAA;CAC7F;CACsB,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/botlit/permissions/botmanorPermissions.ts
|
|
2
|
+
var e = {
|
|
3
|
+
APP_CREATE: "botmanor-app:create",
|
|
4
|
+
APP_UPDATE: "botmanor-app:update",
|
|
5
|
+
APP_DELETE: "botmanor-app:delete",
|
|
6
|
+
APP_PUBLISH: "botmanor-app:publish",
|
|
7
|
+
APP_ROLLBACK: "botmanor-app:rollback",
|
|
8
|
+
APP_AGENT_CREATE: "botmanor-app-agent:create",
|
|
9
|
+
APP_AGENT_UPDATE: "botmanor-app-agent:update",
|
|
10
|
+
APP_AGENT_DELETE: "botmanor-app-agent:delete",
|
|
11
|
+
AGENT_CREATE: "botmanor-agent:create",
|
|
12
|
+
AGENT_UPDATE: "botmanor-agent:update",
|
|
13
|
+
AGENT_DELETE: "botmanor-agent:delete",
|
|
14
|
+
AGENT_PUBLISH: "botmanor-agent:publish",
|
|
15
|
+
AGENT_ROLLBACK: "botmanor-agent:rollback",
|
|
16
|
+
AGENT_EXECUTE: "botmanor-agent:execute",
|
|
17
|
+
AGENT_APPROVE: "botmanor-agent:approve",
|
|
18
|
+
KNOWLEDGE_CREATE: "botmanor-knowledge-base:create",
|
|
19
|
+
KNOWLEDGE_UPDATE: "botmanor-knowledge-base:update",
|
|
20
|
+
KNOWLEDGE_DELETE: "botmanor-knowledge-base:delete",
|
|
21
|
+
KNOWLEDGE_MANAGE: "botmanor-knowledge-base:manage",
|
|
22
|
+
RETRIEVAL_PROFILE_CREATE: "botmanor-retrieval-profile:create",
|
|
23
|
+
RETRIEVAL_PROFILE_UPDATE: "botmanor-retrieval-profile:update",
|
|
24
|
+
RETRIEVAL_PROFILE_DELETE: "botmanor-retrieval-profile:delete",
|
|
25
|
+
MCP_CREATE: "botmanor-mcp:create",
|
|
26
|
+
MCP_UPDATE: "botmanor-mcp:update",
|
|
27
|
+
MCP_DELETE: "botmanor-mcp:delete",
|
|
28
|
+
MCP_TEST: "botmanor-mcp:test",
|
|
29
|
+
MCP_EXECUTE: "botmanor-mcp:execute",
|
|
30
|
+
LLM_CREATE: "botmanor-llm:create",
|
|
31
|
+
LLM_UPDATE: "botmanor-llm:update",
|
|
32
|
+
LLM_DELETE: "botmanor-llm:delete",
|
|
33
|
+
LLM_TEST: "botmanor-llm:test",
|
|
34
|
+
A2A_CREATE: "botmanor-a2a:create",
|
|
35
|
+
A2A_UPDATE: "botmanor-a2a:update",
|
|
36
|
+
A2A_DELETE: "botmanor-a2a:delete",
|
|
37
|
+
A2A_SEND: "botmanor-a2a:send",
|
|
38
|
+
A2A_EXECUTE: "botmanor-a2a:execute",
|
|
39
|
+
A2A_REGISTRY_CREATE: "botmanor-a2a-registry:create",
|
|
40
|
+
A2A_REGISTRY_UPDATE: "botmanor-a2a-registry:update",
|
|
41
|
+
A2A_REGISTRY_DELETE: "botmanor-a2a-registry:delete",
|
|
42
|
+
CHANNEL_CREATE: "botmanor-channel:create",
|
|
43
|
+
CHANNEL_UPDATE: "botmanor-channel:update",
|
|
44
|
+
CHANNEL_DELETE: "botmanor-channel:delete",
|
|
45
|
+
CHANNEL_MESSAGE_CREATE: "botmanor-channel-message:create",
|
|
46
|
+
CHANNEL_MESSAGE_EXECUTE: "botmanor-channel-message:execute",
|
|
47
|
+
POLICY_CREATE: "botmanor-policy:create",
|
|
48
|
+
POLICY_UPDATE: "botmanor-policy:update",
|
|
49
|
+
POLICY_DELETE: "botmanor-policy:delete",
|
|
50
|
+
SKILL_CREATE: "botmanor-skill:create",
|
|
51
|
+
SKILL_UPDATE: "botmanor-skill:update",
|
|
52
|
+
SKILL_DELETE: "botmanor-skill:delete",
|
|
53
|
+
PROMPT_TEMPLATE_CREATE: "botmanor-prompt-template:create",
|
|
54
|
+
PROMPT_TEMPLATE_UPDATE: "botmanor-prompt-template:update",
|
|
55
|
+
PROMPT_TEMPLATE_DELETE: "botmanor-prompt-template:delete",
|
|
56
|
+
PROMPT_TEMPLATE_EXECUTE: "botmanor-prompt-template:execute",
|
|
57
|
+
EXECUTION_CREATE: "botmanor-execution:create",
|
|
58
|
+
EXECUTION_UPDATE: "botmanor-execution:update",
|
|
59
|
+
BUCKET_CREATE: "botmanor-bucket:create",
|
|
60
|
+
BUCKET_UPDATE: "botmanor-bucket:update",
|
|
61
|
+
BUCKET_DELETE: "botmanor-bucket:delete",
|
|
62
|
+
STORE_CREATE: "botmanor-store:create",
|
|
63
|
+
STORE_UPDATE: "botmanor-store:update",
|
|
64
|
+
STORE_DELETE: "botmanor-store:delete",
|
|
65
|
+
TEMPLATE_CREATE: "botmanor-template:create",
|
|
66
|
+
TEMPLATE_UPDATE: "botmanor-template:update",
|
|
67
|
+
TEMPLATE_DELETE: "botmanor-template:delete"
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { e as BOTMANOR_PERMISSIONS };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=botmanorPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"botmanorPermissions.js","names":[],"sources":["../../../src/botlit/permissions/botmanorPermissions.ts"],"sourcesContent":["/**\n * BotManor permission catalogue\n * @module botlit/permissions\n *\n * The `resource:action` pairs the BotManor UI checks before it offers a write\n * control. Every pair mirrors the `@rbac(resource, action)` directive on the\n * wspace-botmanor-svc mutation that the control calls, so the UI hides exactly\n * what the gateway would refuse. The gateway stays the only enforcement point:\n * hiding a button never grants or denies anything, it only stops a member from\n * attempting an action the gateway will answer with FORBIDDEN.\n *\n * Keep this file in step with the service schema. When a mutation's directive\n * changes, change the pair here and the control that calls it.\n */\n\nexport const BOTMANOR_PERMISSIONS = {\n // Bot apps — createBotApp / updateBotApp / deleteBotApp / publishBotAppVersion /\n // rollbackBotAppVersion\n APP_CREATE: 'botmanor-app:create',\n APP_UPDATE: 'botmanor-app:update',\n APP_DELETE: 'botmanor-app:delete',\n APP_PUBLISH: 'botmanor-app:publish',\n APP_ROLLBACK: 'botmanor-app:rollback',\n\n // Agents behind an app — createAppAgent / updateAppAgent / deleteAppAgent\n APP_AGENT_CREATE: 'botmanor-app-agent:create',\n APP_AGENT_UPDATE: 'botmanor-app-agent:update',\n APP_AGENT_DELETE: 'botmanor-app-agent:delete',\n\n // Agents — createBotmanorAgent / updateBotmanorAgent / deleteBotmanorAgent /\n // publishAgentVersion / rollbackAgentVersion / chatWithAgent /\n // approve|rejectBotmanorAgentActivation / updateBotmanorAgentApprovalSettings /\n // configureAssistantRuntime / publishAssistantWebsite / configureAssistantChannel\n AGENT_CREATE: 'botmanor-agent:create',\n AGENT_UPDATE: 'botmanor-agent:update',\n AGENT_DELETE: 'botmanor-agent:delete',\n AGENT_PUBLISH: 'botmanor-agent:publish',\n AGENT_ROLLBACK: 'botmanor-agent:rollback',\n AGENT_EXECUTE: 'botmanor-agent:execute',\n AGENT_APPROVE: 'botmanor-agent:approve',\n\n // Knowledge bases — createKnowledgeBase / addKnowledgeDocument /\n // updateKnowledgeBase / deleteKnowledgeBase / removeKnowledgeDocument /\n // rebuildKnowledgeBaseIndex / queueKnowledgeSource / retry*\n KNOWLEDGE_CREATE: 'botmanor-knowledge-base:create',\n KNOWLEDGE_UPDATE: 'botmanor-knowledge-base:update',\n KNOWLEDGE_DELETE: 'botmanor-knowledge-base:delete',\n KNOWLEDGE_MANAGE: 'botmanor-knowledge-base:manage',\n\n // Retrieval profiles\n RETRIEVAL_PROFILE_CREATE: 'botmanor-retrieval-profile:create',\n RETRIEVAL_PROFILE_UPDATE: 'botmanor-retrieval-profile:update',\n RETRIEVAL_PROFILE_DELETE: 'botmanor-retrieval-profile:delete',\n\n // MCP servers — create/update/deleteMCPConnection, updateMCPTool,\n // testMCPConnection, refreshMCPTools / refreshMCPResources / callMCPTool\n MCP_CREATE: 'botmanor-mcp:create',\n MCP_UPDATE: 'botmanor-mcp:update',\n MCP_DELETE: 'botmanor-mcp:delete',\n MCP_TEST: 'botmanor-mcp:test',\n MCP_EXECUTE: 'botmanor-mcp:execute',\n\n // LLM providers and models — create/update/delete*, testLlmConnection\n LLM_CREATE: 'botmanor-llm:create',\n LLM_UPDATE: 'botmanor-llm:update',\n LLM_DELETE: 'botmanor-llm:delete',\n LLM_TEST: 'botmanor-llm:test',\n\n // A2A — create/update/deleteA2AConnection, sendA2AMessage, delegateA2ATask\n A2A_CREATE: 'botmanor-a2a:create',\n A2A_UPDATE: 'botmanor-a2a:update',\n A2A_DELETE: 'botmanor-a2a:delete',\n A2A_SEND: 'botmanor-a2a:send',\n A2A_EXECUTE: 'botmanor-a2a:execute',\n\n // A2A registry (the external agents the Registry page lists) —\n // create/update/deleteA2ARegistryEntry\n A2A_REGISTRY_CREATE: 'botmanor-a2a-registry:create',\n A2A_REGISTRY_UPDATE: 'botmanor-a2a-registry:update',\n A2A_REGISTRY_DELETE: 'botmanor-a2a-registry:delete',\n\n // Channels — connectors and routes\n CHANNEL_CREATE: 'botmanor-channel:create',\n CHANNEL_UPDATE: 'botmanor-channel:update',\n CHANNEL_DELETE: 'botmanor-channel:delete',\n // sendChannelMessage is :create, handleChannelMessage is :execute\n CHANNEL_MESSAGE_CREATE: 'botmanor-channel-message:create',\n CHANNEL_MESSAGE_EXECUTE: 'botmanor-channel-message:execute',\n\n // Policies\n POLICY_CREATE: 'botmanor-policy:create',\n POLICY_UPDATE: 'botmanor-policy:update',\n POLICY_DELETE: 'botmanor-policy:delete',\n\n // Skills\n SKILL_CREATE: 'botmanor-skill:create',\n SKILL_UPDATE: 'botmanor-skill:update',\n SKILL_DELETE: 'botmanor-skill:delete',\n\n // Prompt templates — create/duplicate share :create; renderPromptTemplate is :execute\n PROMPT_TEMPLATE_CREATE: 'botmanor-prompt-template:create',\n PROMPT_TEMPLATE_UPDATE: 'botmanor-prompt-template:update',\n PROMPT_TEMPLATE_DELETE: 'botmanor-prompt-template:delete',\n PROMPT_TEMPLATE_EXECUTE: 'botmanor-prompt-template:execute',\n\n // Executions — createExecution / triggerBoundWorkflow are :create,\n // runExecution / updateExecutionStatus are :update\n EXECUTION_CREATE: 'botmanor-execution:create',\n EXECUTION_UPDATE: 'botmanor-execution:update',\n\n // Buckets\n BUCKET_CREATE: 'botmanor-bucket:create',\n BUCKET_UPDATE: 'botmanor-bucket:update',\n BUCKET_DELETE: 'botmanor-bucket:delete',\n\n // Store — installPackage / forkInstalledPackage are :create,\n // updateInstalledPackage :update, uninstallPackage :delete\n STORE_CREATE: 'botmanor-store:create',\n STORE_UPDATE: 'botmanor-store:update',\n STORE_DELETE: 'botmanor-store:delete',\n\n // Agent and app templates\n TEMPLATE_CREATE: 'botmanor-template:create',\n TEMPLATE_UPDATE: 'botmanor-template:update',\n TEMPLATE_DELETE: 'botmanor-template:delete',\n} as const;\n\nexport type BotmanorPermission = (typeof BOTMANOR_PERMISSIONS)[keyof typeof BOTMANOR_PERMISSIONS];\n"],"mappings":";AAeA,IAAa,IAAuB;CAGlC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CAGd,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAMlB,cAAc;CACd,cAAc;CACd,cAAc;CACd,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,eAAe;CAKf,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAGlB,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAI1B,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAGb,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAIb,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CAGrB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAEhB,wBAAwB;CACxB,yBAAyB;CAGzB,eAAe;CACf,eAAe;CACf,eAAe;CAGf,cAAc;CACd,cAAc;CACd,cAAc;CAGd,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,yBAAyB;CAIzB,kBAAkB;CAClB,kBAAkB;CAGlB,eAAe;CACf,eAAe;CACf,eAAe;CAIf,cAAc;CACd,cAAc;CACd,cAAc;CAGd,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAClB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback as e } from "react";
|
|
2
|
+
import { Fragment as t, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { useSafePermissions as r } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
4
|
+
//#region src/botlit/permissions/useBotmanorPermissions.tsx
|
|
5
|
+
function i(e, t) {
|
|
6
|
+
return e ? e.isLoading ? "loading" : e.hasPermission(t) ? "allowed" : "denied" : "allowed";
|
|
7
|
+
}
|
|
8
|
+
function a() {
|
|
9
|
+
let t = r();
|
|
10
|
+
return e((e) => i(t, e) === "allowed", [t]);
|
|
11
|
+
}
|
|
12
|
+
var o = ({ permission: e, children: a, fallback: o = null, loading: s = null }) => {
|
|
13
|
+
let c = i(r(), e);
|
|
14
|
+
return c === "allowed" ? /* @__PURE__ */ n(t, { children: a }) : c === "loading" ? /* @__PURE__ */ n(t, { children: s }) : /* @__PURE__ */ n(t, { children: o });
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { o as BotmanorPermissionGate, i as resolvePermission, a as useBotmanorCan };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=useBotmanorPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBotmanorPermissions.js","names":[],"sources":["../../../src/botlit/permissions/useBotmanorPermissions.tsx"],"sourcesContent":["/**\n * BotManor permission hooks and gate\n * @module botlit/permissions\n *\n * Thin wrappers over the shell's fe-libs `PermissionProvider` that decide\n * whether the UI should offer a write control. They follow the fe-libs\n * `PermissionGate` contract (render children when allowed, `fallback` when\n * denied, `loading` while the permission set is still being fetched) with one\n * difference: they read the context through `useSafePermissions`, so the MFE\n * keeps rendering in a host that has not mounted RBAC (the standalone dev\n * host, Storybook, unit tests). With no provider every control is offered,\n * which is exactly the behaviour before gating existed; the gateway's `@rbac`\n * directive remains the enforcement point either way.\n *\n * While permissions load, checks answer `false` so a viewer never sees a\n * control flash on and then disappear.\n */\n\nimport { useCallback, type FC, type ReactNode } from 'react';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\n\nimport type { BotmanorPermission } from './botmanorPermissions';\n\n/** Answers whether the current member may use the control behind `permission`. */\nexport type BotmanorPermissionCheck = (permission: BotmanorPermission) => boolean;\n\n/** Outcome of resolving a permission against the shell context. */\nexport type PermissionDecision = 'allowed' | 'denied' | 'loading';\n\n/**\n * Resolve one permission against a (possibly absent) permission context.\n * Exported for unit tests; components use the hooks below.\n */\nexport function resolvePermission(\n context: ReturnType<typeof useSafePermissions>,\n permission: BotmanorPermission\n): PermissionDecision {\n if (!context) return 'allowed';\n if (context.isLoading) return 'loading';\n return context.hasPermission(permission) ? 'allowed' : 'denied';\n}\n\n/**\n * Returns a stable checker for any number of permissions on one page.\n *\n * @example\n * const can = useBotmanorCan();\n * {can(BOTMANOR_PERMISSIONS.POLICY_DELETE) && <Button onClick={remove}>Delete</Button>}\n */\nexport function useBotmanorCan(): BotmanorPermissionCheck {\n const context = useSafePermissions();\n return useCallback(\n (permission: BotmanorPermission) => resolvePermission(context, permission) === 'allowed',\n [context]\n );\n}\n\n/** Single-permission form of {@link useBotmanorCan}. */\nexport function useBotmanorPermission(permission: BotmanorPermission): boolean {\n return useBotmanorCan()(permission);\n}\n\nexport interface BotmanorPermissionGateProps {\n /** The `resource:action` pair the wrapped control needs. */\n permission: BotmanorPermission;\n /** Rendered when the member has the permission. */\n children: ReactNode;\n /** Rendered when the member lacks the permission. Nothing by default. */\n fallback?: ReactNode;\n /** Rendered while permissions load. Nothing by default. */\n loading?: ReactNode;\n}\n\n/**\n * Render `children` only for members who hold `permission`.\n *\n * @example\n * <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.POLICY_CREATE}>\n * <Button>Create Policy</Button>\n * </BotmanorPermissionGate>\n */\nexport const BotmanorPermissionGate: FC<BotmanorPermissionGateProps> = ({\n permission,\n children,\n fallback = null,\n loading = null,\n}) => {\n const decision = resolvePermission(useSafePermissions(), permission);\n if (decision === 'allowed') return <>{children}</>;\n if (decision === 'loading') return <>{loading}</>;\n return <>{fallback}</>;\n};\n"],"mappings":";;;;AAiCA,SAAgB,EACd,GACA,GACoB;AAGpB,QAFK,IACD,EAAQ,YAAkB,YACvB,EAAQ,cAAc,EAAW,GAAG,YAAY,WAFlC;;AAYvB,SAAgB,IAA0C;CACxD,IAAM,IAAU,GAAoB;AACpC,QAAO,GACJ,MAAmC,EAAkB,GAAS,EAAW,KAAK,WAC/E,CAAC,EAAQ,CACV;;AA2BH,IAAa,KAA2D,EACtE,eACA,aACA,cAAW,MACX,aAAU,WACN;CACJ,IAAM,IAAW,EAAkB,GAAoB,EAAE,EAAW;AAGpE,QAFI,MAAa,YAAkB,kBAAA,GAAA,EAAG,aAAY,CAAA,GAC9C,MAAa,YAAkB,kBAAA,GAAA,EAAA,UAAG,GAAW,CAAA,GAC1C,kBAAA,GAAA,EAAA,UAAG,GAAY,CAAA"}
|
package/package.json
CHANGED