@sudobility/entity_client 0.0.25 → 0.0.27

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 +98 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @sudobility/entity_client
2
+
3
+ React client library for entity/organization management with TanStack Query v5 hooks for CRUD operations on entities, members, and invitations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @sudobility/entity_client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import {
15
+ EntityClient,
16
+ useEntities,
17
+ useCreateEntity,
18
+ useEntityMembers,
19
+ useMyInvitations,
20
+ useAcceptInvitation,
21
+ CurrentEntityProvider,
22
+ useCurrentEntity,
23
+ } from '@sudobility/entity_client';
24
+
25
+ const client = new EntityClient({
26
+ baseUrl: 'https://api.example.com/api/v1',
27
+ networkClient: myNetworkClient,
28
+ });
29
+
30
+ // In components
31
+ const { data: entities } = useEntities(client);
32
+ const createEntity = useCreateEntity(client);
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### Client
38
+
39
+ | Export | Description |
40
+ |--------|-------------|
41
+ | `EntityClient` | HTTP client wrapping authenticated fetch calls to the entity API |
42
+ | `EntityClientConfig` | Config: `{ baseUrl, networkClient }` |
43
+
44
+ ### Entity Hooks
45
+
46
+ | Hook | Description |
47
+ |------|-------------|
48
+ | `useEntities(client)` | List all entities for current user |
49
+ | `useEntity(client, slug)` | Get single entity by slug |
50
+ | `useCreateEntity(client)` | Create organization (invalidates list) |
51
+ | `useUpdateEntity(client)` | Update entity (invalidates detail + list) |
52
+ | `useDeleteEntity(client)` | Delete entity (invalidates list) |
53
+
54
+ ### Member Hooks
55
+
56
+ | Hook | Description |
57
+ |------|-------------|
58
+ | `useEntityMembers(client, slug)` | List members of an entity |
59
+ | `useUpdateMemberRole(client)` | Update member role |
60
+ | `useRemoveMember(client)` | Remove member from entity |
61
+
62
+ ### Invitation Hooks
63
+
64
+ | Hook | Description |
65
+ |------|-------------|
66
+ | `useMyInvitations(client)` | List pending invitations for current user |
67
+ | `useEntityInvitations(client, slug)` | List invitations for an entity |
68
+ | `useCreateInvitation(client)` | Create invitation |
69
+ | `useCancelInvitation(client)` | Cancel invitation |
70
+ | `useAcceptInvitation(client)` | Accept invitation by token |
71
+ | `useDeclineInvitation(client)` | Decline invitation by token |
72
+
73
+ ### Context
74
+
75
+ | Export | Description |
76
+ |--------|-------------|
77
+ | `CurrentEntityProvider` | Manages workspace/entity selection with localStorage persistence |
78
+ | `useCurrentEntity()` | Access current entity context (throws if outside provider) |
79
+ | `useCurrentEntityOptional()` | Access current entity context (returns null if outside) |
80
+
81
+ ### Query Key Factories
82
+
83
+ `entityKeys`, `memberKeys`, `invitationKeys` -- for cache management.
84
+
85
+ ## Development
86
+
87
+ ```bash
88
+ bun run build # Compile TypeScript to dist/
89
+ bun run build:watch # Watch mode
90
+ bun run typecheck # Type-check (no emit)
91
+ bun run lint # ESLint
92
+ bun run test # Run tests (vitest)
93
+ bun run format # Prettier format
94
+ ```
95
+
96
+ ## License
97
+
98
+ BUSL-1.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/entity_client",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "description": "Frontend client library for entity/organization management",
6
6
  "main": "dist/index.js",
@@ -26,11 +26,11 @@
26
26
  "peerDependencies": {
27
27
  "react": "^18.0.0 || ^19.0.0",
28
28
  "@tanstack/react-query": "^5.0.0",
29
- "@sudobility/types": "^1.9.55"
29
+ "@sudobility/types": "^1.9.57"
30
30
  },
31
31
  "devDependencies": {
32
32
  "vitest": "^4.0.4",
33
- "@sudobility/types": "^1.9.55",
33
+ "@sudobility/types": "^1.9.57",
34
34
  "@eslint/js": "^9.0.0",
35
35
  "@tanstack/react-query": "^5.0.0",
36
36
  "@types/bun": "^1.2.8",