@invect/rbac 0.0.1

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -0
  3. package/dist/backend/index.cjs +1365 -0
  4. package/dist/backend/index.cjs.map +1 -0
  5. package/dist/backend/index.d.ts +3 -0
  6. package/dist/backend/index.d.ts.map +1 -0
  7. package/dist/backend/index.mjs +1363 -0
  8. package/dist/backend/index.mjs.map +1 -0
  9. package/dist/backend/plugin.d.ts +60 -0
  10. package/dist/backend/plugin.d.ts.map +1 -0
  11. package/dist/frontend/components/AccessControlPage.d.ts +2 -0
  12. package/dist/frontend/components/AccessControlPage.d.ts.map +1 -0
  13. package/dist/frontend/components/FlowAccessPanel.d.ts +10 -0
  14. package/dist/frontend/components/FlowAccessPanel.d.ts.map +1 -0
  15. package/dist/frontend/components/ShareButton.d.ts +9 -0
  16. package/dist/frontend/components/ShareButton.d.ts.map +1 -0
  17. package/dist/frontend/components/ShareFlowModal.d.ts +12 -0
  18. package/dist/frontend/components/ShareFlowModal.d.ts.map +1 -0
  19. package/dist/frontend/components/TeamsPage.d.ts +5 -0
  20. package/dist/frontend/components/TeamsPage.d.ts.map +1 -0
  21. package/dist/frontend/components/UserMenuSection.d.ts +14 -0
  22. package/dist/frontend/components/UserMenuSection.d.ts.map +1 -0
  23. package/dist/frontend/components/access-control/AccessControlPage.d.ts +2 -0
  24. package/dist/frontend/components/access-control/AccessControlPage.d.ts.map +1 -0
  25. package/dist/frontend/components/access-control/AccessTable.d.ts +17 -0
  26. package/dist/frontend/components/access-control/AccessTable.d.ts.map +1 -0
  27. package/dist/frontend/components/access-control/FlowDetailPanel.d.ts +11 -0
  28. package/dist/frontend/components/access-control/FlowDetailPanel.d.ts.map +1 -0
  29. package/dist/frontend/components/access-control/FormDialog.d.ts +7 -0
  30. package/dist/frontend/components/access-control/FormDialog.d.ts.map +1 -0
  31. package/dist/frontend/components/access-control/MemberCombobox.d.ts +8 -0
  32. package/dist/frontend/components/access-control/MemberCombobox.d.ts.map +1 -0
  33. package/dist/frontend/components/access-control/MoveConfirmationDialog.d.ts +9 -0
  34. package/dist/frontend/components/access-control/MoveConfirmationDialog.d.ts.map +1 -0
  35. package/dist/frontend/components/access-control/PrincipalCombobox.d.ts +11 -0
  36. package/dist/frontend/components/access-control/PrincipalCombobox.d.ts.map +1 -0
  37. package/dist/frontend/components/access-control/ScopeDetailPanel.d.ts +11 -0
  38. package/dist/frontend/components/access-control/ScopeDetailPanel.d.ts.map +1 -0
  39. package/dist/frontend/components/access-control/index.d.ts +4 -0
  40. package/dist/frontend/components/access-control/index.d.ts.map +1 -0
  41. package/dist/frontend/components/access-control/types.d.ts +36 -0
  42. package/dist/frontend/components/access-control/types.d.ts.map +1 -0
  43. package/dist/frontend/components/access-control/useUsers.d.ts +3 -0
  44. package/dist/frontend/components/access-control/useUsers.d.ts.map +1 -0
  45. package/dist/frontend/hooks/useFlowAccess.d.ts +15 -0
  46. package/dist/frontend/hooks/useFlowAccess.d.ts.map +1 -0
  47. package/dist/frontend/hooks/useScopes.d.ts +15 -0
  48. package/dist/frontend/hooks/useScopes.d.ts.map +1 -0
  49. package/dist/frontend/hooks/useTeams.d.ts +25 -0
  50. package/dist/frontend/hooks/useTeams.d.ts.map +1 -0
  51. package/dist/frontend/index.cjs +2928 -0
  52. package/dist/frontend/index.cjs.map +1 -0
  53. package/dist/frontend/index.d.ts +23 -0
  54. package/dist/frontend/index.d.ts.map +1 -0
  55. package/dist/frontend/index.mjs +2899 -0
  56. package/dist/frontend/index.mjs.map +1 -0
  57. package/dist/frontend/providers/RbacProvider.d.ts +33 -0
  58. package/dist/frontend/providers/RbacProvider.d.ts.map +1 -0
  59. package/dist/frontend/stores/accessControlStore.d.ts +49 -0
  60. package/dist/frontend/stores/accessControlStore.d.ts.map +1 -0
  61. package/dist/frontend/types.d.ts +95 -0
  62. package/dist/frontend/types.d.ts.map +1 -0
  63. package/dist/shared/types.cjs +0 -0
  64. package/dist/shared/types.d.ts +172 -0
  65. package/dist/shared/types.d.ts.map +1 -0
  66. package/dist/shared/types.mjs +1 -0
  67. package/package.json +107 -0
@@ -0,0 +1,49 @@
1
+ import type { MovePreviewResponse, ScopeTreeNode } from '../../shared/types';
2
+ import type { PendingMove, SelectedItem } from '../components/access-control/types';
3
+ export type HierarchyDragItem = {
4
+ type: 'scope' | 'flow';
5
+ id: string;
6
+ name: string;
7
+ /** Current parent scope id, or null if at root */
8
+ parentId: string | null;
9
+ };
10
+ interface AccessControlState {
11
+ selected: SelectedItem | null;
12
+ setSelected: (item: SelectedItem | null) => void;
13
+ expandedNodes: Set<string>;
14
+ setExpandedNodes: (nodes: Set<string>) => void;
15
+ toggleNode: (scopeId: string) => void;
16
+ expandAll: (ids: string[]) => void;
17
+ search: string;
18
+ setSearch: (q: string) => void;
19
+ showNewTeam: boolean;
20
+ setShowNewTeam: (show: boolean) => void;
21
+ newTeamName: string;
22
+ setNewTeamName: (name: string) => void;
23
+ draggedItem: HierarchyDragItem | null;
24
+ dropTarget: string | null;
25
+ startDrag: (item: HierarchyDragItem) => void;
26
+ endDrag: () => void;
27
+ /**
28
+ * Called on dragover for a specific target.
29
+ * Returns true if the drop is valid (caller should call event.preventDefault).
30
+ */
31
+ setDropTarget: (targetId: string | null) => void;
32
+ pendingMove: PendingMove | null;
33
+ movePreview: MovePreviewResponse | null;
34
+ moveError: string | null;
35
+ setPendingMove: (move: PendingMove | null) => void;
36
+ setMovePreview: (preview: MovePreviewResponse | null) => void;
37
+ setMoveError: (error: string | null) => void;
38
+ clearMove: () => void;
39
+ }
40
+ export declare const useAccessControlStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AccessControlState>>;
41
+ declare function collectScopeIds(scopes: ScopeTreeNode[]): string[];
42
+ export declare function isDescendantScope(scopes: ScopeTreeNode[], draggedScopeId: string, potentialTargetId: string): boolean;
43
+ export { collectScopeIds };
44
+ /**
45
+ * Returns true if dropping `dragged` onto `targetId` is a valid move.
46
+ * targetId of null means "move to root".
47
+ */
48
+ export declare function canDropOnTarget(dragged: HierarchyDragItem, targetId: string | null, allScopes: ScopeTreeNode[]): boolean;
49
+ //# sourceMappingURL=accessControlStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessControlStore.d.ts","sourceRoot":"","sources":["../../../src/frontend/stores/accessControlStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,UAAU,kBAAkB;IAE1B,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IAGjD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,gBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAGnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAG/B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,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+ * @invect/frontend to render plugin-contributed UI.
6
+ */
7
+ import type { ComponentType, ReactNode } from 'react';
8
+ /**
9
+ * A frontend plugin that contributes UI to the Invect application.
10
+ * Plugins are registered via `<Invect plugins={[myPlugin]} />`.
11
+ */
12
+ export interface InvectFrontendPlugin {
13
+ /** Unique plugin ID — should match backend plugin ID for manifest resolution */
14
+ id: string;
15
+ /** Display name */
16
+ name?: string;
17
+ /** Add items to the sidebar navigation */
18
+ sidebar?: PluginSidebarContribution[];
19
+ /** Add top-level routes (pages) */
20
+ routes?: PluginRouteContribution[];
21
+ /** Add tabs to contextual panels (flow editor right panel, etc.) */
22
+ panelTabs?: PluginPanelTabContribution[];
23
+ /** Add action buttons/components to contextual headers */
24
+ headerActions?: PluginHeaderActionContribution[];
25
+ /**
26
+ * Named component implementations — resolved from backend componentIds.
27
+ * Key = componentId (e.g. 'rbac.FlowAccessPanel'), value = React component.
28
+ */
29
+ components?: Record<string, ComponentType<Record<string, unknown>>>;
30
+ /** Wrap the React tree with additional providers (auth context, etc.) */
31
+ providers?: ComponentType<{
32
+ children: ReactNode;
33
+ }>[];
34
+ /**
35
+ * Inject headers into every API request.
36
+ * Called before each request. Return headers to merge.
37
+ */
38
+ apiHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
39
+ /**
40
+ * Check if the current user has a specific permission.
41
+ * Returns true/false to override, or undefined to defer to default.
42
+ */
43
+ checkPermission?: (permission: string, context?: PermissionContext) => boolean | undefined;
44
+ }
45
+ export interface PluginSidebarContribution {
46
+ label: string;
47
+ icon: ComponentType<{
48
+ className?: string;
49
+ }>;
50
+ path: string;
51
+ /** Position hint: 'top' (after defaults), 'bottom' (before theme toggle) */
52
+ position?: 'top' | 'bottom';
53
+ /** Required permission — item hidden if check fails */
54
+ permission?: string;
55
+ }
56
+ export interface PluginRouteContribution {
57
+ path: string;
58
+ component: ComponentType<{
59
+ basePath: string;
60
+ }>;
61
+ /** If true, route is nested under the flow layout */
62
+ flowScoped?: boolean;
63
+ }
64
+ export interface PluginPanelTabContribution {
65
+ /** Where the tab appears */
66
+ context: 'flowEditor' | 'nodeConfig';
67
+ label: string;
68
+ icon?: ComponentType<{
69
+ className?: string;
70
+ }>;
71
+ component: ComponentType<PanelTabProps>;
72
+ /** Required permission — tab hidden if check fails */
73
+ permission?: string;
74
+ }
75
+ export interface PluginHeaderActionContribution {
76
+ /** Where the action appears */
77
+ context: 'flowHeader' | 'flowList';
78
+ component: ComponentType<HeaderActionProps>;
79
+ /** Required permission — action hidden if check fails */
80
+ permission?: string;
81
+ }
82
+ export interface PanelTabProps {
83
+ flowId: string;
84
+ basePath: string;
85
+ }
86
+ export interface HeaderActionProps {
87
+ flowId?: string;
88
+ basePath: string;
89
+ }
90
+ export interface PermissionContext {
91
+ resourceType?: string;
92
+ resourceId?: string;
93
+ flowId?: string;
94
+ }
95
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/frontend/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMtD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,gFAAgF;IAChF,EAAE,EAAE,MAAM,CAAC;IAEX,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,0CAA0C;IAC1C,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAEtC,mCAAmC;IACnC,MAAM,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAEnC,oEAAoE;IACpE,SAAS,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAEzC,0DAA0D;IAC1D,aAAa,CAAC,EAAE,8BAA8B,EAAE,CAAC;IAEjD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAEpE,y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AY,GAAG,UAAU,CAAC;IACnC,SAAS,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC5C,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
File without changes
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @invect/rbac — Shared Types
3
+ *
4
+ * Serializable types shared between backend and frontend.
5
+ * No runtime code, no React, no Node.js dependencies.
6
+ */
7
+ export interface Team {
8
+ id: string;
9
+ name: string;
10
+ description?: string | null;
11
+ parentId?: string | null;
12
+ createdBy?: string | null;
13
+ createdAt: string;
14
+ updatedAt?: string | null;
15
+ }
16
+ export interface TeamMember {
17
+ id: string;
18
+ teamId: string;
19
+ userId: string;
20
+ createdAt: string;
21
+ }
22
+ export interface CreateTeamRequest {
23
+ name: string;
24
+ description?: string;
25
+ parentId?: string | null;
26
+ }
27
+ export interface UpdateTeamRequest {
28
+ name?: string;
29
+ description?: string;
30
+ parentId?: string | null;
31
+ }
32
+ export interface AddTeamMemberRequest {
33
+ userId: string;
34
+ }
35
+ export interface TeamWithMembers extends Team {
36
+ members: TeamMember[];
37
+ }
38
+ export interface FlowSummary {
39
+ id: string;
40
+ name: string;
41
+ scopeId?: string | null;
42
+ }
43
+ export interface ScopeTreeNode extends Team {
44
+ children: ScopeTreeNode[];
45
+ flows: FlowSummary[];
46
+ directAccessCount: number;
47
+ memberCount: number;
48
+ teamPermission?: FlowAccessPermission | null;
49
+ }
50
+ export interface ScopeTreeResponse {
51
+ scopes: ScopeTreeNode[];
52
+ unscopedFlows: FlowSummary[];
53
+ }
54
+ export type FlowAccessPermission = 'owner' | 'editor' | 'operator' | 'viewer';
55
+ export interface FlowAccessRecord {
56
+ id: string;
57
+ flowId: string;
58
+ userId?: string | null;
59
+ teamId?: string | null;
60
+ permission: FlowAccessPermission;
61
+ grantedBy?: string | null;
62
+ grantedAt: string;
63
+ expiresAt?: string | null;
64
+ }
65
+ export interface ScopeAccessRecord {
66
+ id: string;
67
+ scopeId: string;
68
+ userId?: string | null;
69
+ teamId?: string | null;
70
+ permission: FlowAccessPermission;
71
+ grantedBy?: string | null;
72
+ grantedAt: string;
73
+ }
74
+ export interface EffectiveAccessRecord extends FlowAccessRecord {
75
+ source: 'direct' | 'inherited';
76
+ scopeId?: string | null;
77
+ scopeName?: string | null;
78
+ }
79
+ export interface GrantFlowAccessRequest {
80
+ userId?: string;
81
+ teamId?: string;
82
+ permission: FlowAccessPermission;
83
+ expiresAt?: string;
84
+ }
85
+ export interface GrantScopeAccessRequest {
86
+ userId?: string;
87
+ teamId?: string;
88
+ permission: FlowAccessPermission;
89
+ }
90
+ export interface AccessibleFlowsResponse {
91
+ flowIds: string[];
92
+ permissions: Record<string, FlowAccessPermission | null>;
93
+ isAdmin?: boolean;
94
+ }
95
+ export interface EffectiveFlowAccessResponse {
96
+ flowId: string;
97
+ scopeId?: string | null;
98
+ records: EffectiveAccessRecord[];
99
+ }
100
+ export interface MovePreviewRequest {
101
+ type: 'flow' | 'scope';
102
+ id: string;
103
+ targetScopeId: string | null;
104
+ }
105
+ export interface MovePreviewAccessChange {
106
+ userId?: string;
107
+ teamId?: string;
108
+ name: string;
109
+ permission: FlowAccessPermission;
110
+ source: string;
111
+ }
112
+ export interface MovePreviewResponse {
113
+ item: {
114
+ id: string;
115
+ name: string;
116
+ type: 'flow' | 'scope';
117
+ };
118
+ target: {
119
+ id: string | null;
120
+ name: string;
121
+ path: string[];
122
+ };
123
+ affectedFlows: number;
124
+ accessChanges: {
125
+ gained: MovePreviewAccessChange[];
126
+ unchanged: number;
127
+ };
128
+ }
129
+ export type RolePermissionEntry = {
130
+ role: string;
131
+ permissions: string[];
132
+ };
133
+ export interface AuthMeResponse {
134
+ identity: {
135
+ id: string;
136
+ name?: string;
137
+ role?: string;
138
+ resolvedRole: string | null;
139
+ } | null;
140
+ permissions: string[];
141
+ isAuthenticated: boolean;
142
+ }
143
+ export interface PluginUIManifest {
144
+ sidebar?: PluginUISidebarItem[];
145
+ pages?: PluginUIPage[];
146
+ panelTabs?: PluginUIPanelTab[];
147
+ headerActions?: PluginUIHeaderAction[];
148
+ }
149
+ export interface PluginUISidebarItem {
150
+ label: string;
151
+ /** Lucide icon name as string (e.g. 'Shield', 'Users') */
152
+ icon: string;
153
+ path: string;
154
+ permission?: string;
155
+ }
156
+ export interface PluginUIPage {
157
+ path: string;
158
+ componentId: string;
159
+ title?: string;
160
+ }
161
+ export interface PluginUIPanelTab {
162
+ context: string;
163
+ label: string;
164
+ componentId: string;
165
+ permission?: string;
166
+ }
167
+ export interface PluginUIHeaderAction {
168
+ context: string;
169
+ componentId: string;
170
+ permission?: string;
171
+ }
172
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,E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CAC1B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "@invect/rbac",
3
+ "version": "0.0.1",
4
+ "description": "RBAC plugin for Invect — adds role-based access control UI, flow sharing, and permission management. Requires @invect/user-auth.",
5
+ "author": "robase",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/backend/index.cjs",
9
+ "module": "dist/backend/index.mjs",
10
+ "types": "dist/backend/index.d.ts",
11
+ "files": [
12
+ "dist/**/*"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/backend/index.d.ts",
17
+ "import": "./dist/backend/index.mjs",
18
+ "require": "./dist/backend/index.cjs"
19
+ },
20
+ "./ui": {
21
+ "types": "./dist/frontend/index.d.ts",
22
+ "import": "./dist/frontend/index.mjs",
23
+ "require": "./dist/frontend/index.cjs"
24
+ },
25
+ "./types": {
26
+ "types": "./dist/shared/types.d.ts",
27
+ "import": "./dist/shared/types.mjs",
28
+ "require": "./dist/shared/types.cjs"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "@invect/core": "0.0.1"
33
+ },
34
+ "peerDependencies": {
35
+ "@invect/user-auth": ">=0.1.0",
36
+ "@invect/frontend": ">=2.0.0",
37
+ "react": ">=18.0.0",
38
+ "react-dom": ">=18.0.0",
39
+ "@tanstack/react-query": ">=5.0.0",
40
+ "clsx": ">=2.0.0",
41
+ "tailwind-merge": ">=2.0.0",
42
+ "zustand": ">=4.0.0"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@invect/frontend": {
46
+ "optional": true
47
+ },
48
+ "clsx": {
49
+ "optional": true
50
+ },
51
+ "zustand": {
52
+ "optional": true
53
+ },
54
+ "tailwind-merge": {
55
+ "optional": true
56
+ },
57
+ "react": {
58
+ "optional": true
59
+ },
60
+ "react-dom": {
61
+ "optional": true
62
+ },
63
+ "@tanstack/react-query": {
64
+ "optional": true
65
+ }
66
+ },
67
+ "devDependencies": {
68
+ "@tanstack/react-query": "^5.0.0",
69
+ "@types/node": "^20.11.20",
70
+ "@types/react": "18.3.7",
71
+ "@types/react-dom": "18.3.7",
72
+ "lucide-react": "^0.475.0",
73
+ "prettier": "^3.6.2",
74
+ "react": "^18.3.1",
75
+ "react-dom": "^18.3.1",
76
+ "tsdown": "^0.21.1",
77
+ "typescript": "^5.3.3",
78
+ "vitest": "^1.2.2",
79
+ "zustand": "^4.5.7",
80
+ "@invect/user-auth": "0.0.1",
81
+ "@invect/frontend": "0.0.1"
82
+ },
83
+ "repository": {
84
+ "type": "git",
85
+ "url": "https://github.com/robase/invect.git",
86
+ "directory": "pkg/plugins/rbac"
87
+ },
88
+ "bugs": {
89
+ "url": "https://github.com/robase/invect/issues"
90
+ },
91
+ "homepage": "https://invect.dev",
92
+ "publishConfig": {
93
+ "access": "public"
94
+ },
95
+ "scripts": {
96
+ "build": "tsdown && tsc --emitDeclarationOnly --outDir dist",
97
+ "build:w": "tsdown --watch",
98
+ "dev": "tsdown --watch",
99
+ "clean": "rm -rf dist",
100
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
101
+ "typecheck": "tsc --noEmit",
102
+ "lint": "eslint src",
103
+ "lint:fix": "eslint src --fix",
104
+ "test": "echo \"No tests configured\"",
105
+ "test:watch": "vitest --watch"
106
+ }
107
+ }