@medha-analytics/medha-one-access-react 1.0.3 → 1.0.4
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/README.md +132 -132
- package/dist/MedhaOneAccess.d.ts.map +1 -1
- package/dist/components/dialogs/UserDialog.d.ts +1 -1
- package/dist/components/dialogs/UserDialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +57 -50
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
# @medha-analytics/medha-one-access-react
|
|
2
|
-
|
|
3
|
-
ACL admin dashboard React library — drop-in Users / Groups / Artifacts / Access Rules / Hierarchy management UI, backed by the Medha One Access API.
|
|
4
|
-
|
|
5
|
-
For instructions on building and distributing this package itself (local link, GitHub, or npm), see [PUBLISHING.md](./PUBLISHING.md).
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @medha-analytics/medha-one-access-react
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Peer dependencies
|
|
14
|
-
|
|
15
|
-
The host app must provide these (they are not bundled):
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install react react-dom @tanstack/react-query
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Quick start
|
|
22
|
-
|
|
23
|
-
Wrap your app (or the relevant section of it) in `MedhaOneAccessProvider`, then render `MedhaOneAccess`:
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { MedhaOneAccessProvider, MedhaOneAccess } from '@medha-analytics/medha-one-access-react'
|
|
27
|
-
|
|
28
|
-
function App() {
|
|
29
|
-
return (
|
|
30
|
-
<MedhaOneAccessProvider
|
|
31
|
-
apiUrl="https://your-medha-api.example.com"
|
|
32
|
-
secretKey="your-secret-key"
|
|
33
|
-
currentApplication="your-app-id"
|
|
34
|
-
>
|
|
35
|
-
<MedhaOneAccess />
|
|
36
|
-
</MedhaOneAccessProvider>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default App
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
> Styles are auto-injected — importing anything from this package pulls in `dist/index.css` automatically, as long as your bundler processes CSS imports from `node_modules` (Vite, Next.js, and Create React App all do this by default). If your setup doesn't, import it explicitly: `import '@medha-analytics/medha-one-access-react/dist/index.css'`.
|
|
44
|
-
|
|
45
|
-
### Provider config (`MedhaOneAccessConfig`)
|
|
46
|
-
|
|
47
|
-
| Prop | Type | Required | Description |
|
|
48
|
-
|---|---|---|---|
|
|
49
|
-
| `apiUrl` | `string` | yes | Base URL of the Medha One Access API |
|
|
50
|
-
| `secretKey` | `string` | yes | Shared secret used to sign requests (see `generateToken`) |
|
|
51
|
-
| `currentApplication` | `string` | yes | Application identifier scoping access rules/artifacts |
|
|
52
|
-
| `isAdmin` | `boolean` | no | Enables admin-only actions in the UI |
|
|
53
|
-
| `debugMode` | `boolean` | no | Verbose request/response logging |
|
|
54
|
-
| `queryClient` | `QueryClient` | no | Supply your own TanStack Query client instead of the library's internal one (e.g. to share a cache with the host app) |
|
|
55
|
-
|
|
56
|
-
## Using individual pieces
|
|
57
|
-
|
|
58
|
-
You don't have to render the full `MedhaOneAccess` shell — every view, dialog, and hook is exported individually so you can compose your own layout.
|
|
59
|
-
|
|
60
|
-
### Views
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
import {
|
|
64
|
-
MedhaOneAccessProvider,
|
|
65
|
-
UsersView,
|
|
66
|
-
GroupsView,
|
|
67
|
-
ArtifactsView,
|
|
68
|
-
AccessRulesView,
|
|
69
|
-
} from '@medha-analytics/medha-one-access-react'
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Dialogs
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
import {
|
|
76
|
-
UserDialog,
|
|
77
|
-
GroupDialog,
|
|
78
|
-
ArtifactDialog,
|
|
79
|
-
AccessRuleDialog,
|
|
80
|
-
} from '@medha-analytics/medha-one-access-react'
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Hooks
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
import {
|
|
87
|
-
useUsers, useUser, useCreateUser, useUpdateUser, useDeleteUser,
|
|
88
|
-
useGroups, useGroup, useGroupMembers, useAddGroupMember, useRemoveGroupMember,
|
|
89
|
-
useArtifacts, useArtifact, useArtifactGroups, useArtifactGroupContents,
|
|
90
|
-
useAccessRules, useAccessRule, useCheckAccess, useValidateExpression,
|
|
91
|
-
useOrgChart, useCombinedHierarchy, useArtifactCombinedHierarchy,
|
|
92
|
-
} from '@medha-analytics/medha-one-access-react'
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
All data hooks must be called from inside a `MedhaOneAccessProvider` — they read the API URL and HTTP client from context via `useMedhaConfig` / `useMedhaHttp`.
|
|
96
|
-
|
|
97
|
-
### Shared UI primitives
|
|
98
|
-
|
|
99
|
-
`Button`, `Badge`, `Input`, `Label`, `DataTable`, `ExpressionInput`, `ConfirmDialog`, `HierarchyTree`, and the `cn` class-name helper are also exported, in case you want to build custom screens that match the library's look and feel.
|
|
100
|
-
|
|
101
|
-
### Types
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
import type {
|
|
105
|
-
MedhaOneAccessConfig,
|
|
106
|
-
User, UserGroup, GroupMember, HierarchyNode,
|
|
107
|
-
Artifact, ArtifactGroup, ArtifactHierarchyNode, Permission,
|
|
108
|
-
AccessRule, TimeConstraint, ExpressionValidationResult,
|
|
109
|
-
} from '@medha-analytics/medha-one-access-react'
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Styling notes
|
|
113
|
-
|
|
114
|
-
- The library ships with Tailwind-based styles pre-built into `dist/index.css`, and the built JS auto-imports it (`import './index.css'` / `require('./index.css')` runs whenever you import anything from the package). You don't need Tailwind configured in the host app.
|
|
115
|
-
- If your bundler doesn't process CSS imports from `node_modules` (rare with modern tooling, but possible with some custom webpack/esbuild setups), import the stylesheet explicitly: `import '@medha-analytics/medha-one-access-react/dist/index.css'`.
|
|
116
|
-
- If the host app also uses Tailwind, check for class-name collisions; the library's classes are scoped to its own components but share Tailwind's utility naming.
|
|
117
|
-
|
|
118
|
-
## Requirements
|
|
119
|
-
|
|
120
|
-
- React 19+
|
|
121
|
-
- A `QueryClientProvider` is created automatically unless you pass your own `queryClient` to `MedhaOneAccessProvider`.
|
|
122
|
-
|
|
123
|
-
## Troubleshooting
|
|
124
|
-
|
|
125
|
-
**"useMedhaConfig must be used inside `<MedhaOneAccessProvider>`"**
|
|
126
|
-
A hook or component from this library was rendered outside the provider. Make sure `MedhaOneAccessProvider` wraps any tree using these hooks/views.
|
|
127
|
-
|
|
128
|
-
**Invalid hook call / two copies of React**
|
|
129
|
-
Usually happens when consuming the library via `npm link` and the host app resolves its own `react` separately. See the "Local link" section in [PUBLISHING.md](./PUBLISHING.md) for the fix.
|
|
130
|
-
|
|
131
|
-
**Styles look unstyled / broken layout**
|
|
132
|
-
Styles are auto-injected as of this version — if you previously added a manual `import '@medha-analytics/medha-one-access-react/dist/medha-one-access-react.css'`, remove it (that file no longer exists; it's now `dist/index.css`, imported automatically). If styles still don't appear, your bundler likely isn't processing CSS imports from `node_modules` — import `@medha-analytics/medha-one-access-react/dist/index.css` explicitly as a fallback.
|
|
1
|
+
# @medha-analytics/medha-one-access-react
|
|
2
|
+
|
|
3
|
+
ACL admin dashboard React library — drop-in Users / Groups / Artifacts / Access Rules / Hierarchy management UI, backed by the Medha One Access API.
|
|
4
|
+
|
|
5
|
+
For instructions on building and distributing this package itself (local link, GitHub, or npm), see [PUBLISHING.md](./PUBLISHING.md).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @medha-analytics/medha-one-access-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer dependencies
|
|
14
|
+
|
|
15
|
+
The host app must provide these (they are not bundled):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install react react-dom @tanstack/react-query
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
Wrap your app (or the relevant section of it) in `MedhaOneAccessProvider`, then render `MedhaOneAccess`:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { MedhaOneAccessProvider, MedhaOneAccess } from '@medha-analytics/medha-one-access-react'
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<MedhaOneAccessProvider
|
|
31
|
+
apiUrl="https://your-medha-api.example.com"
|
|
32
|
+
secretKey="your-secret-key"
|
|
33
|
+
currentApplication="your-app-id"
|
|
34
|
+
>
|
|
35
|
+
<MedhaOneAccess />
|
|
36
|
+
</MedhaOneAccessProvider>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default App
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> Styles are auto-injected — importing anything from this package pulls in `dist/index.css` automatically, as long as your bundler processes CSS imports from `node_modules` (Vite, Next.js, and Create React App all do this by default). If your setup doesn't, import it explicitly: `import '@medha-analytics/medha-one-access-react/dist/index.css'`.
|
|
44
|
+
|
|
45
|
+
### Provider config (`MedhaOneAccessConfig`)
|
|
46
|
+
|
|
47
|
+
| Prop | Type | Required | Description |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `apiUrl` | `string` | yes | Base URL of the Medha One Access API |
|
|
50
|
+
| `secretKey` | `string` | yes | Shared secret used to sign requests (see `generateToken`) |
|
|
51
|
+
| `currentApplication` | `string` | yes | Application identifier scoping access rules/artifacts |
|
|
52
|
+
| `isAdmin` | `boolean` | no | Enables admin-only actions in the UI |
|
|
53
|
+
| `debugMode` | `boolean` | no | Verbose request/response logging |
|
|
54
|
+
| `queryClient` | `QueryClient` | no | Supply your own TanStack Query client instead of the library's internal one (e.g. to share a cache with the host app) |
|
|
55
|
+
|
|
56
|
+
## Using individual pieces
|
|
57
|
+
|
|
58
|
+
You don't have to render the full `MedhaOneAccess` shell — every view, dialog, and hook is exported individually so you can compose your own layout.
|
|
59
|
+
|
|
60
|
+
### Views
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import {
|
|
64
|
+
MedhaOneAccessProvider,
|
|
65
|
+
UsersView,
|
|
66
|
+
GroupsView,
|
|
67
|
+
ArtifactsView,
|
|
68
|
+
AccessRulesView,
|
|
69
|
+
} from '@medha-analytics/medha-one-access-react'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Dialogs
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import {
|
|
76
|
+
UserDialog,
|
|
77
|
+
GroupDialog,
|
|
78
|
+
ArtifactDialog,
|
|
79
|
+
AccessRuleDialog,
|
|
80
|
+
} from '@medha-analytics/medha-one-access-react'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Hooks
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import {
|
|
87
|
+
useUsers, useUser, useCreateUser, useUpdateUser, useDeleteUser,
|
|
88
|
+
useGroups, useGroup, useGroupMembers, useAddGroupMember, useRemoveGroupMember,
|
|
89
|
+
useArtifacts, useArtifact, useArtifactGroups, useArtifactGroupContents,
|
|
90
|
+
useAccessRules, useAccessRule, useCheckAccess, useValidateExpression,
|
|
91
|
+
useOrgChart, useCombinedHierarchy, useArtifactCombinedHierarchy,
|
|
92
|
+
} from '@medha-analytics/medha-one-access-react'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
All data hooks must be called from inside a `MedhaOneAccessProvider` — they read the API URL and HTTP client from context via `useMedhaConfig` / `useMedhaHttp`.
|
|
96
|
+
|
|
97
|
+
### Shared UI primitives
|
|
98
|
+
|
|
99
|
+
`Button`, `Badge`, `Input`, `Label`, `DataTable`, `ExpressionInput`, `ConfirmDialog`, `HierarchyTree`, and the `cn` class-name helper are also exported, in case you want to build custom screens that match the library's look and feel.
|
|
100
|
+
|
|
101
|
+
### Types
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import type {
|
|
105
|
+
MedhaOneAccessConfig,
|
|
106
|
+
User, UserGroup, GroupMember, HierarchyNode,
|
|
107
|
+
Artifact, ArtifactGroup, ArtifactHierarchyNode, Permission,
|
|
108
|
+
AccessRule, TimeConstraint, ExpressionValidationResult,
|
|
109
|
+
} from '@medha-analytics/medha-one-access-react'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Styling notes
|
|
113
|
+
|
|
114
|
+
- The library ships with Tailwind-based styles pre-built into `dist/index.css`, and the built JS auto-imports it (`import './index.css'` / `require('./index.css')` runs whenever you import anything from the package). You don't need Tailwind configured in the host app.
|
|
115
|
+
- If your bundler doesn't process CSS imports from `node_modules` (rare with modern tooling, but possible with some custom webpack/esbuild setups), import the stylesheet explicitly: `import '@medha-analytics/medha-one-access-react/dist/index.css'`.
|
|
116
|
+
- If the host app also uses Tailwind, check for class-name collisions; the library's classes are scoped to its own components but share Tailwind's utility naming.
|
|
117
|
+
|
|
118
|
+
## Requirements
|
|
119
|
+
|
|
120
|
+
- React 19+
|
|
121
|
+
- A `QueryClientProvider` is created automatically unless you pass your own `queryClient` to `MedhaOneAccessProvider`.
|
|
122
|
+
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
**"useMedhaConfig must be used inside `<MedhaOneAccessProvider>`"**
|
|
126
|
+
A hook or component from this library was rendered outside the provider. Make sure `MedhaOneAccessProvider` wraps any tree using these hooks/views.
|
|
127
|
+
|
|
128
|
+
**Invalid hook call / two copies of React**
|
|
129
|
+
Usually happens when consuming the library via `npm link` and the host app resolves its own `react` separately. See the "Local link" section in [PUBLISHING.md](./PUBLISHING.md) for the fix.
|
|
130
|
+
|
|
131
|
+
**Styles look unstyled / broken layout**
|
|
132
|
+
Styles are auto-injected as of this version — if you previously added a manual `import '@medha-analytics/medha-one-access-react/dist/medha-one-access-react.css'`, remove it (that file no longer exists; it's now `dist/index.css`, imported automatically). If styles still don't appear, your bundler likely isn't processing CSS imports from `node_modules` — import `@medha-analytics/medha-one-access-react/dist/index.css` explicitly as a fallback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MedhaOneAccess.d.ts","sourceRoot":"","sources":["../src/MedhaOneAccess.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"MedhaOneAccess.d.ts","sourceRoot":"","sources":["../src/MedhaOneAccess.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,cAAc,gCAyC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserDialog.d.ts","sourceRoot":"","sources":["../../../src/components/dialogs/UserDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UserDialog.d.ts","sourceRoot":"","sources":["../../../src/components/dialogs/UserDialog.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAiBzD,UAAU,eAAe;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;CACf;AA0DD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,+BA2QlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/components/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAMpD,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK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