@larose-ui/data 0.1.0 → 0.1.2
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 +55 -0
- package/dist/index.js +3 -3
- package/package.json +10 -5
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @larose-ui/data
|
|
2
|
+
|
|
3
|
+
> Backend-aware data fetching with self-healing errors.
|
|
4
|
+
|
|
5
|
+
Part of **[laRose UI](https://github.com/hamdymohamedak/larose-ui)** — the UI Operating System for modern SaaS applications.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @larose-ui/data
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @larose-ui/data
|
|
13
|
+
# or
|
|
14
|
+
yarn add @larose-ui/data
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
**Peer dependency:** `react >=18`
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { DataView } from '@larose-ui/data';
|
|
25
|
+
|
|
26
|
+
<DataView url="/api/employees" permission="employees.read">
|
|
27
|
+
{(rows) => <EmployeeTable data={rows} />}
|
|
28
|
+
</DataView>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- `useQuery`, `useMutation`, `DataView`
|
|
34
|
+
- Self-healing errors with auto-retry on 429/5xx
|
|
35
|
+
- `useUndo` for destructive action recovery
|
|
36
|
+
|
|
37
|
+
## Related packages
|
|
38
|
+
|
|
39
|
+
| Layer | Packages |
|
|
40
|
+
|-------|----------|
|
|
41
|
+
| Foundation | `@larose-ui/core`, `@larose-ui/tokens`, `@larose-ui/react` |
|
|
42
|
+
| Runtime | `@larose-ui/runtime`, `@larose-ui/network`, `@larose-ui/offline` |
|
|
43
|
+
| Intelligence | `@larose-ui/data`, `@larose-ui/forms`, `@larose-ui/permissions` |
|
|
44
|
+
| Platform | `@larose-ui/observability`, `@larose-ui/enterprise`, `@larose-ui/ai` |
|
|
45
|
+
|
|
46
|
+
## Documentation
|
|
47
|
+
|
|
48
|
+
- [Monorepo README](https://github.com/hamdymohamedak/larose-ui#readme)
|
|
49
|
+
- [Architecture](https://github.com/hamdymohamedak/larose-ui/blob/main/docs/architecture/ARCHITECTURE.md)
|
|
50
|
+
- [Roadmap](https://github.com/hamdymohamedak/larose-ui/blob/main/docs/ROADMAP.md)
|
|
51
|
+
- [Report an issue](https://github.com/hamdymohamedak/larose-ui/issues)
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT © [laRose UI](https://github.com/hamdymohamedak/larose-ui)
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function queryReducer(state, action) {
|
|
|
105
105
|
function useQuery(url, options = {}) {
|
|
106
106
|
const { enabled = true, permission, resource, initialData, ...fetchOptions } = options;
|
|
107
107
|
const { check } = usePermissions();
|
|
108
|
-
const
|
|
108
|
+
const permissionAllowed = permission ? check(permission, resource).allowed : true;
|
|
109
109
|
const [state, dispatch] = useReducer(queryReducer, {
|
|
110
110
|
status: "idle",
|
|
111
111
|
data: initialData ?? null,
|
|
@@ -116,7 +116,7 @@ function useQuery(url, options = {}) {
|
|
|
116
116
|
fetchOptionsRef.current = fetchOptions;
|
|
117
117
|
const execute = useCallback(async () => {
|
|
118
118
|
if (!url) return;
|
|
119
|
-
if (
|
|
119
|
+
if (!permissionAllowed) {
|
|
120
120
|
dispatch({ type: "UNAUTHORIZED" });
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -138,7 +138,7 @@ function useQuery(url, options = {}) {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
}, [url,
|
|
141
|
+
}, [url, permissionAllowed]);
|
|
142
142
|
useEffect(() => {
|
|
143
143
|
if (enabled && url) void execute();
|
|
144
144
|
}, [enabled, url, execute, state.retryCount]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larose-ui/data",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Backend-aware data layer for laRose UI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
17
18
|
],
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@larose-ui/core": "0.1.
|
|
20
|
-
"@larose-ui/permissions": "0.1.
|
|
20
|
+
"@larose-ui/core": "0.1.2",
|
|
21
|
+
"@larose-ui/permissions": "0.1.2"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"react": ">=18"
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
},
|
|
40
41
|
"repository": {
|
|
41
42
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/larose-ui
|
|
43
|
+
"url": "git+https://github.com/hamdymohamedak/larose-ui.git",
|
|
43
44
|
"directory": "packages/data"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
@@ -49,6 +50,10 @@
|
|
|
49
50
|
"design-system",
|
|
50
51
|
"saas"
|
|
51
52
|
],
|
|
53
|
+
"homepage": "https://github.com/hamdymohamedak/larose-ui/blob/main/packages/data#readme",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/hamdymohamedak/larose-ui/issues"
|
|
56
|
+
},
|
|
52
57
|
"scripts": {
|
|
53
58
|
"build": "tsup",
|
|
54
59
|
"dev": "tsup --watch",
|