@aiquants/authz-react-router 0.1.0 → 0.1.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.
- package/README.md +43 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -115,4 +115,47 @@ Multiple roles **union** (wider wins): rows OR'd (any `NULL` ⇒ all rows); colu
|
|
|
115
115
|
- `usePermission(view)` → ○△× display states (`readState`/`writeState`/`deleteState`); pure, safe in render.
|
|
116
116
|
- `<MyPermissionIndicator permission={view} />` → read / write(create∪update) / delete as ○△×. `read` is △ when row/column-restricted; `write` is ○ only when both create & update are held, △ when one.
|
|
117
117
|
|
|
118
|
+
## Demo App
|
|
119
|
+
|
|
120
|
+
This package contains an interactive React Router 7 SPA demo in the `demo/` subdirectory. The demo app runs completely in the browser, using `localStorage` to mock database storage.
|
|
121
|
+
|
|
122
|
+
### Features
|
|
123
|
+
|
|
124
|
+
- **Role-Based Access Control**: Demonstrates role switching (Admin, Manager, Operator, Reader) and how it affects UI elements.
|
|
125
|
+
- **Route Guards**: Uses `authz.requirePermission` to protect routes and handle unauthorized access.
|
|
126
|
+
- **Scope Verification**: Demonstrates `rowScope` (row filters) and `columnScope` (masked values) dynamically applied based on the active role's permissions.
|
|
127
|
+
- **In-Browser Database Reset**: Includes a **「デモデータ初期化」 (Reset Demo Data)** button in the header of key views (Dashboard, Protected Documents, and Sales pages) to wipe customized roles, assignments, permissions, and CRUD data from `localStorage`, instantly restoring default test states.
|
|
128
|
+
|
|
129
|
+
### Running the Demo
|
|
130
|
+
|
|
131
|
+
From the project root:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm --filter authz-react-router-demo dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Open `http://localhost:5178/` in your browser.
|
|
138
|
+
|
|
139
|
+
## Testing
|
|
140
|
+
|
|
141
|
+
Playwright tests are included in the `demo/` package to verify the RBAC features, CRUD interactions, and the data reset functionality.
|
|
142
|
+
|
|
143
|
+
### Running Integration Tests
|
|
144
|
+
|
|
145
|
+
Ensure the dev server is running, then run Playwright tests from the workspace root:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Run all tests in the demo package
|
|
149
|
+
pnpm exec playwright test packages/authz-react-router/demo/
|
|
150
|
+
|
|
151
|
+
# Run specific tests
|
|
152
|
+
pnpm exec playwright test packages/authz-react-router/demo/integration-tests.spec.ts
|
|
153
|
+
pnpm exec playwright test packages/authz-react-router/demo/check.spec.ts
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- **`integration-tests.spec.ts`**: Runs a comprehensive workflow verifying permission guards, dynamic role granting/revocation in the Admin Panel, row/column scoping on sales data, CRUD validation, and the final state reset.
|
|
157
|
+
- **`check.spec.ts`**: Verifies basic CRUD operations (list, create, update, delete) on protected document files.
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
118
161
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/authz-react-router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Router (v7) adapter for @aiquants/authz-core: requirePermission/getMyPermissions guards, usePermission hook, and MyPermissionIndicator component.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
"publish:patch": "npm version patch && pnpm publish --no-git-checks",
|
|
68
68
|
"publish:minor": "npm version minor && pnpm publish --no-git-checks",
|
|
69
69
|
"publish:major": "npm version major && pnpm publish --no-git-checks",
|
|
70
|
+
"demo:dev": "cd demo && pnpm run dev",
|
|
71
|
+
"demo:build": "cd demo && pnpm run build",
|
|
72
|
+
"demo:start": "cd demo && pnpm run start",
|
|
70
73
|
"lint": "biome lint src/",
|
|
71
74
|
"check": "biome check src/",
|
|
72
75
|
"check:fix": "biome check --write src/",
|