@startsoft/lumina 0.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,131 @@
1
+ # Changelog
2
+
3
+ All notable changes to @startsoft/lumina will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2024-XX-XX
9
+
10
+ ### Added
11
+
12
+ #### Core CRUD Hooks
13
+ - `useModelIndex()` - Fetch paginated model lists with filtering, sorting, and search
14
+ - `useModelShow()` - Fetch single model by ID with relationships
15
+ - `useModelStore()` - Create new model instances
16
+ - `useModelUpdate()` - Update existing models
17
+ - `useModelDelete()` - Soft delete models (moves to trash)
18
+
19
+ #### Soft Delete Operations
20
+ - `useModelTrashed()` - Fetch soft-deleted models with pagination
21
+ - `useModelRestore()` - Restore soft-deleted models
22
+ - `useModelForceDelete()` - Permanently delete models (cannot be recovered)
23
+
24
+ #### Advanced Features
25
+ - `useNestedOperations()` - Execute multi-model transactions with reference support
26
+ - `useModelAudit()` - Fetch audit trail for model instances
27
+
28
+ #### Authentication & Organization
29
+ - `useAuth()` - Authentication state and methods (login, logout, setOrganization)
30
+ - `useOrganization()` - Get current organization slug from context
31
+ - `useOwner()` - Fetch organization data with related users
32
+ - `useOrganizationExists()` - Validate organization existence
33
+
34
+ #### Invitations System
35
+ - `useInvitations()` - List organization invitations with status filtering
36
+ - `useInviteUser()` - Create new invitation
37
+ - `useResendInvitation()` - Resend invitation email
38
+ - `useCancelInvitation()` - Cancel pending invitation
39
+ - `useAcceptInvitation()` - Accept invitation (public route)
40
+
41
+ #### Query Features
42
+ - **Pagination** - Automatic metadata extraction from response headers (X-Current-Page, X-Last-Page, X-Per-Page, X-Total)
43
+ - **Filtering** - Field-level filters with `filter[field]=value` syntax
44
+ - **Search** - Full-text search across models
45
+ - **Relationships** - Eager loading with `includes` parameter
46
+ - **Field Selection** - Select specific fields to reduce payload size
47
+ - **Sorting** - Sort by any field (ascending/descending with `-` prefix)
48
+ - **Multi-tenant Routing** - Organization-based URL routing
49
+
50
+ #### Utilities
51
+ - `extractPaginationFromHeaders()` - Parse pagination metadata from API responses
52
+ - Configured Axios client with:
53
+ - Base URL configuration via environment variables
54
+ - Bearer token injection from localStorage
55
+ - CORS support with credentials
56
+ - 401 auto-logout and redirect
57
+ - Request/response interceptors
58
+
59
+ #### Infrastructure
60
+ - **TanStack Query 5.62.11** - Data fetching, caching, and state management
61
+ - **React 19 support** - Compatible with latest React features
62
+ - **TypeScript support** - Full type definitions and IntelliSense
63
+ - **Barrel exports** - Clean import paths from `@startsoft/lumina`
64
+ - **Comprehensive documentation** - API reference, guides, and examples
65
+ - **Example components** - Demo components for testing features
66
+
67
+ ### Changed
68
+ - `useModelIndex` now returns `{ data, pagination }` instead of just `data` for consistency
69
+ - All hooks use organization context from `useOrganization()` for multi-tenancy
70
+ - React Query cache keys include organization and options for proper isolation
71
+
72
+ ### Infrastructure
73
+ - Built with Vite 6.0.1 for fast development and optimized builds
74
+ - ESLint 9 with React and React Hooks plugins
75
+ - Tailwind CSS 3.4.0 with dark mode support
76
+ - Radix UI components for accessible UI primitives
77
+
78
+ ## [Unreleased]
79
+
80
+ ### Planned Features
81
+ - **WebSocket Support** - Real-time updates for model changes
82
+ - **Offline Mode** - Queue operations and sync when online
83
+ - **Advanced Caching** - Configurable cache strategies per model
84
+ - **Optimistic Updates** - Helpers for optimistic UI updates
85
+ - **File Uploads** - Dedicated hooks for file upload with progress
86
+ - **Batch Operations** - Bulk create, update, delete operations
87
+ - **Query Builder UI** - Visual query builder component
88
+ - **Subscriptions** - Model subscription for live updates
89
+
90
+ ### Planned Improvements
91
+ - **Performance** - Virtual scrolling for large lists
92
+ - **DevTools** - React Query DevTools integration
93
+ - **Testing** - Jest/Vitest setup with testing utilities
94
+ - **Storybook** - Component documentation and testing
95
+ - **CI/CD** - Automated testing and npm publishing
96
+
97
+ ---
98
+
99
+ ## Version History
100
+
101
+ - **1.0.0** - Initial release with complete CRUD, soft deletes, nested operations, pagination, and multi-tenant support
102
+
103
+ ---
104
+
105
+ ## Migration Guides
106
+
107
+ ### Upgrading to 1.0.0
108
+
109
+ If you were using the template/demo version, you'll need to update imports:
110
+
111
+ **Before:**
112
+ ```typescript
113
+ import { useModelIndex } from './hooks/useModel';
114
+ ```
115
+
116
+ **After:**
117
+ ```typescript
118
+ import { useModelIndex } from '@startsoft/lumina';
119
+ ```
120
+
121
+ **Breaking Changes:**
122
+ - `useModelIndex` now returns `{ data, pagination }` instead of direct array
123
+ - Update: `const users = useModelIndex('users')` → `const { data: response } = useModelIndex('users'); const users = response?.data || [];`
124
+
125
+ ---
126
+
127
+ ## Support
128
+
129
+ - [Documentation](./docs/)
130
+ - [Issues](https://github.com/yourusername/rhino-client/issues)
131
+ - [Discussions](https://github.com/yourusername/rhino-client/discussions)
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ # @startsoft/lumina
2
+
3
+ > A comprehensive React library for Laravel backend applications with full CRUD, pagination, soft deletes, and multi-tenant support.
4
+
5
+ [![npm version](https://badge.fury.io/js/@rhino%2Fclient.svg)](https://www.npmjs.com/package/@startsoft/lumina)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ---
9
+
10
+ ## ✨ Features
11
+
12
+ - 🔐 **Authentication** - Built-in auth hooks with Laravel Sanctum support
13
+ - 🏢 **Multi-tenancy** - Organization-based routing and data scoping
14
+ - 📊 **Complete CRUD** - Index, show, create, update, delete operations
15
+ - 🗑️ **Soft Deletes** - Trash, restore, and force delete support
16
+ - 🔍 **Advanced Querying** - Search, filters, sorting, field selection, pagination
17
+ - 🔗 **Relationships** - Eager loading with includes
18
+ - 🔄 **Nested Operations** - Multi-model transactions
19
+ - 📝 **Audit Trails** - Track changes and history
20
+ - ⚡ **React Query** - Built on TanStack Query for caching and state management
21
+ - 📘 **TypeScript** - Full TypeScript support with type definitions
22
+
23
+ ---
24
+
25
+ ## 📦 Installation
26
+
27
+ ```bash
28
+ npm install @startsoft/lumina
29
+ # or
30
+ yarn add @startsoft/lumina
31
+ # or
32
+ pnpm add @startsoft/lumina
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 🚀 Quick Start
38
+
39
+ ```tsx
40
+ import { useModelIndex, useModelStore } from '@startsoft/lumina';
41
+
42
+ function PostsList() {
43
+ // Fetch posts with pagination
44
+ const { data: response, isLoading } = useModelIndex('posts', {
45
+ page: 1,
46
+ perPage: 20,
47
+ search: 'react',
48
+ includes: ['author'],
49
+ sort: '-created_at'
50
+ });
51
+
52
+ const posts = response?.data || [];
53
+ const pagination = response?.pagination;
54
+
55
+ // Create new post
56
+ const createPost = useModelStore('posts');
57
+
58
+ const handleCreate = () => {
59
+ createPost.mutate({
60
+ title: 'My Post',
61
+ content: 'Post content'
62
+ });
63
+ };
64
+
65
+ if (isLoading) return <div>Loading...</div>;
66
+
67
+ return (
68
+ <div>
69
+ <button onClick={handleCreate}>Create Post</button>
70
+
71
+ {posts.map(post => (
72
+ <div key={post.id}>
73
+ <h3>{post.title}</h3>
74
+ {post.author && <p>By: {post.author.name}</p>}
75
+ </div>
76
+ ))}
77
+
78
+ {pagination && (
79
+ <div>
80
+ Page {pagination.currentPage} of {pagination.lastPage}
81
+ </div>
82
+ )}
83
+ </div>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 📚 Documentation
91
+
92
+ - **[Getting Started](./docs/getting-started.md)** - Installation and setup
93
+ - **[API Reference](./docs/API.md)** - Complete hook documentation
94
+ - **[Features Guide](./docs/features/)** - Detailed feature explanations
95
+ - [Pagination](./docs/features/pagination.md)
96
+ - [Soft Deletes](./docs/features/soft-deletes.md)
97
+ - [Filtering & Search](./docs/features/filtering.md)
98
+ - [Relationships](./docs/features/relationships.md)
99
+ - [Nested Operations](./docs/features/nested-operations.md)
100
+ - **[Examples](./docs/examples/)** - Real-world usage examples
101
+
102
+ ---
103
+
104
+ ## 🎯 Core Hooks
105
+
106
+ ### CRUD Operations
107
+
108
+ | Hook | Purpose |
109
+ |------|---------|
110
+ | `useModelIndex` | Fetch list of models with pagination, filtering, search |
111
+ | `useModelShow` | Fetch single model by ID |
112
+ | `useModelStore` | Create new model |
113
+ | `useModelUpdate` | Update existing model |
114
+ | `useModelDelete` | Soft delete model |
115
+
116
+ ### Soft Deletes
117
+
118
+ | Hook | Purpose |
119
+ |------|---------|
120
+ | `useModelTrashed` | Fetch soft-deleted models |
121
+ | `useModelRestore` | Restore soft-deleted model |
122
+ | `useModelForceDelete` | Permanently delete model |
123
+
124
+ ### Advanced Features
125
+
126
+ | Hook | Purpose |
127
+ |------|---------|
128
+ | `useNestedOperations` | Multi-model transactions |
129
+ | `useModelAudit` | Fetch audit trail for a model |
130
+
131
+ ### Authentication & Organization
132
+
133
+ | Hook | Purpose |
134
+ |------|---------|
135
+ | `useAuth` | Authentication state and methods |
136
+ | `useOrganization` | Current organization slug |
137
+ | `useOwner` | Organization data |
138
+ | `useOrganizationExists` | Validate organization |
139
+
140
+ ### Invitations
141
+
142
+ | Hook | Purpose |
143
+ |------|---------|
144
+ | `useInvitations` | List invitations |
145
+ | `useInviteUser` | Create invitation |
146
+ | `useResendInvitation` | Resend invitation |
147
+ | `useCancelInvitation` | Cancel invitation |
148
+ | `useAcceptInvitation` | Accept invitation |
149
+
150
+ **[View complete API reference →](./docs/API.md)**
151
+
152
+ ---
153
+
154
+ ## 🏗️ Architecture
155
+
156
+ Built with modern technologies:
157
+
158
+ - **React 19** - Latest React features and performance
159
+ - **TanStack Query 5** - Powerful data fetching and caching
160
+ - **Axios** - HTTP client with interceptors
161
+ - **TypeScript** - Full type safety
162
+
163
+ ### Design Principles
164
+
165
+ - **Composable** - Small, focused hooks that work together
166
+ - **Type-Safe** - Full TypeScript support with IntelliSense
167
+ - **Cached** - Automatic caching and background refetching
168
+ - **Optimized** - Only re-renders when data changes
169
+ - **Laravel-First** - Designed specifically for Laravel backends
170
+
171
+ ---
172
+
173
+ ## 💡 Key Features
174
+
175
+ ### Pagination
176
+
177
+ Automatic pagination metadata extraction from Laravel response headers:
178
+
179
+ ```tsx
180
+ const { data: response } = useModelIndex('posts', {
181
+ page: 2,
182
+ perPage: 20
183
+ });
184
+
185
+ const posts = response?.data || [];
186
+ const pagination = response?.pagination;
187
+ // { currentPage: 2, lastPage: 10, perPage: 20, total: 195 }
188
+ ```
189
+
190
+ ### Filtering & Search
191
+
192
+ Powerful query building with filters and full-text search:
193
+
194
+ ```tsx
195
+ const { data: response } = useModelIndex('posts', {
196
+ search: 'react hooks',
197
+ filters: {
198
+ status: 'published',
199
+ category: 'tech'
200
+ },
201
+ sort: '-created_at'
202
+ });
203
+ ```
204
+
205
+ ### Relationships
206
+
207
+ Eager load related data with includes:
208
+
209
+ ```tsx
210
+ const { data: post } = useModelShow('posts', 123, {
211
+ includes: ['author', 'comments', 'tags']
212
+ });
213
+ ```
214
+
215
+ ### Soft Deletes
216
+
217
+ Complete soft delete workflow:
218
+
219
+ ```tsx
220
+ const deletePost = useModelDelete('posts');
221
+ const trashedPosts = useModelTrashed('posts');
222
+ const restore = useModelRestore('posts');
223
+ const forceDelete = useModelForceDelete('posts');
224
+
225
+ // Soft delete
226
+ deletePost.mutate(postId);
227
+
228
+ // Restore
229
+ restore.mutate(postId);
230
+
231
+ // Permanently delete
232
+ forceDelete.mutate(postId);
233
+ ```
234
+
235
+ ### Nested Operations
236
+
237
+ Execute multiple operations in a single transaction:
238
+
239
+ ```tsx
240
+ const nestedOps = useNestedOperations();
241
+
242
+ nestedOps.mutate({
243
+ operations: [
244
+ {
245
+ action: 'create',
246
+ model: 'blogs',
247
+ data: { title: 'My Blog' }
248
+ },
249
+ {
250
+ action: 'create',
251
+ model: 'posts',
252
+ data: {
253
+ title: 'First Post',
254
+ blog_id: '$0.id' // Reference first operation's result
255
+ }
256
+ }
257
+ ]
258
+ });
259
+ ```
260
+
261
+ ---
262
+
263
+ ## 🔧 Requirements
264
+
265
+ - **React:** 18.0.0 or higher
266
+ - **Node.js:** 18.0.0 or higher
267
+ - **Laravel Backend:** with [laravel-global-controller](https://github.com/yourusername/laravel-global-controller) package
268
+
269
+ ---
270
+
271
+ ## 🤝 Contributing
272
+
273
+ Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
274
+
275
+ ### Development Setup
276
+
277
+ ```bash
278
+ # Clone the repository
279
+ git clone https://github.com/yourusername/rhino-client.git
280
+ cd rhino-client
281
+
282
+ # Install dependencies
283
+ npm install
284
+
285
+ # Run development server
286
+ npm run dev
287
+
288
+ # Build library
289
+ npm run build
290
+
291
+ # Run tests
292
+ npm test
293
+ ```
294
+
295
+ ---
296
+
297
+ ## 📄 License
298
+
299
+ MIT © [Your Name]
300
+
301
+ See [LICENSE](./LICENSE) for more information.
302
+
303
+ ---
304
+
305
+ ## 🔗 Links
306
+
307
+ - [Documentation](./docs/)
308
+ - [Changelog](./CHANGELOG.md)
309
+ - [Issues](https://github.com/yourusername/rhino-client/issues)
310
+ - [Laravel Backend Package](https://github.com/yourusername/laravel-global-controller)
311
+ - [npm Package](https://www.npmjs.com/package/@startsoft/lumina)
312
+
313
+ ---
314
+
315
+ ## 🙏 Acknowledgments
316
+
317
+ Inspired by the [Rhino Framework](https://rhino-framework.com) for Rails. Built to bring the same powerful patterns to Laravel + React applications.
318
+
319
+ ---
320
+
321
+ <p align="center">
322
+ Made with ❤️ for the Laravel community
323
+ </p>
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Barrel exports for all hooks in @rhino/client
3
+ */
4
+ export { useAuth } from './useAuth';
5
+ export { useOrganization } from './useOrganization';
6
+ export { useOwner } from './useOwner';
7
+ export { useOrganizationExists } from './useOrganizationExists';
8
+ export { useModelIndex, useModelShow, useModelStore, useModelUpdate, useModelDelete, } from './useModel';
9
+ export { useModelTrashed, useModelRestore, useModelForceDelete, } from './useModel';
10
+ export { useNestedOperations, useModelAudit, } from './useModel';
11
+ export { useInvitations, useInviteUser, useResendInvitation, useCancelInvitation, useAcceptInvitation, } from './useInvitations';
12
+ export { useToast } from './use-toast';
13
+ export { useModelQuery } from './useModelQuery';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @startsoft/lumina - Main entry point
3
+ *
4
+ * A comprehensive React library for Laravel backend applications with
5
+ * full CRUD, pagination, soft deletes, and multi-tenant support.
6
+ */
7
+ export * from './hooks';
8
+ export * from './lib';
9
+ export { AuthProvider, useAuth } from './context/AuthContext';
10
+ export { ThemeProvider, useTheme } from './context/ThemeContext';
11
+ export type { PaginationMeta, ModelQueryOptions, NestedOperation, AuditLog, LoginResult, QueryResponse, InvitationStatus, Invitation, Organization, User, Role, } from './types';