@sudobility/starter_lib 0.0.10 → 0.0.12

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 (2) hide show
  1. package/README.md +76 -0
  2. package/package.json +5 -5
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @sudobility/starter_lib
2
+
3
+ Business logic library with Zustand stores for the Starter application.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @sudobility/starter_lib
9
+ ```
10
+
11
+ Peer dependencies:
12
+
13
+ ```bash
14
+ bun add react @tanstack/react-query zustand @sudobility/types
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { useHistoriesManager } from "@sudobility/starter_lib";
21
+
22
+ // In a React component:
23
+ const {
24
+ histories,
25
+ total,
26
+ percentage,
27
+ isCached,
28
+ createHistory,
29
+ updateHistory,
30
+ deleteHistory,
31
+ } = useHistoriesManager({
32
+ baseUrl: "https://api.example.com",
33
+ networkClient,
34
+ userId: "firebase-uid",
35
+ token: firebaseIdToken,
36
+ autoFetch: true, // default
37
+ });
38
+ ```
39
+
40
+ ## API
41
+
42
+ ### useHistoriesManager
43
+
44
+ Unified hook that combines starter_client hooks + Zustand store + business logic:
45
+
46
+ - Percentage calculation: `(userSum / globalTotal) * 100`
47
+ - Cache fallback: returns cached data while server hasn't responded
48
+ - Auto-fetch on mount (configurable)
49
+ - Token reactivity: resets state on token change
50
+
51
+ ### useHistoriesStore
52
+
53
+ Zustand store providing per-user client-side cache with operations: `set`, `get`, `add`, `update`, `remove`. Keyed by user ID.
54
+
55
+ ## Development
56
+
57
+ ```bash
58
+ bun run build # Build ESM
59
+ bun run clean # Remove dist/
60
+ bun test # Run Vitest tests
61
+ bun run typecheck # TypeScript check
62
+ bun run lint # ESLint
63
+ bun run verify # All checks + build (use before commit)
64
+ ```
65
+
66
+ ## Related Packages
67
+
68
+ - **starter_types** -- Shared type definitions (imported transitively via starter_client)
69
+ - **starter_client** -- API client SDK; this library wraps its hooks with business logic
70
+ - **starter_app** -- Web frontend that consumes `useHistoriesManager`
71
+ - **starter_app_rn** -- React Native app that consumes `useHistoriesManager`
72
+ - **starter_api** -- Backend server (communicated with indirectly through starter_client)
73
+
74
+ ## License
75
+
76
+ BUSL-1.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/starter_lib",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Business logic library for Starter with Zustand stores",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,16 +35,16 @@
35
35
  "author": "Sudobility",
36
36
  "license": "BUSL-1.1",
37
37
  "peerDependencies": {
38
- "@sudobility/types": "^1.9.55",
38
+ "@sudobility/types": "^1.9.58",
39
39
  "@tanstack/react-query": ">=5.0.0",
40
40
  "react": ">=18.0.0",
41
41
  "zustand": ">=5.0.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@eslint/js": "^9.38.0",
45
- "@sudobility/starter_client": "^0.0.12",
46
- "@sudobility/starter_types": "^0.0.7",
47
- "@sudobility/types": "^1.9.55",
45
+ "@sudobility/starter_client": "^0.0.14",
46
+ "@sudobility/starter_types": "^0.0.9",
47
+ "@sudobility/types": "^1.9.58",
48
48
  "@tanstack/react-query": "^5.90.5",
49
49
  "@testing-library/react": "^16.3.2",
50
50
  "@testing-library/react-hooks": "^8.0.1",