@fjell/core 4.4.12 → 4.4.16

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 (73) hide show
  1. package/dist/AItemService.d.ts +1 -1
  2. package/dist/index.d.ts +5 -5
  3. package/dist/index.js +7911 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/item/IFactory.d.ts +2 -2
  6. package/dist/item/IQFactory.d.ts +1 -1
  7. package/dist/item/IQUtils.d.ts +3 -3
  8. package/dist/item/IUtils.d.ts +2 -2
  9. package/dist/item/ItemQuery.d.ts +1 -1
  10. package/dist/key/KUtils.d.ts +1 -1
  11. package/dist/logger.d.ts +1 -1
  12. package/package.json +15 -13
  13. package/dist/cjs/AItemService.js +0 -42
  14. package/dist/cjs/AItemService.js.map +0 -1
  15. package/dist/cjs/dictionary.js +0 -71
  16. package/dist/cjs/dictionary.js.map +0 -1
  17. package/dist/cjs/index.js +0 -62
  18. package/dist/cjs/index.js.map +0 -1
  19. package/dist/cjs/item/IFactory.js +0 -93
  20. package/dist/cjs/item/IFactory.js.map +0 -1
  21. package/dist/cjs/item/IQFactory.js +0 -154
  22. package/dist/cjs/item/IQFactory.js.map +0 -1
  23. package/dist/cjs/item/IQUtils.js +0 -335
  24. package/dist/cjs/item/IQUtils.js.map +0 -1
  25. package/dist/cjs/item/IUtils.js +0 -76
  26. package/dist/cjs/item/IUtils.js.map +0 -1
  27. package/dist/cjs/item/ItemQuery.js +0 -10
  28. package/dist/cjs/item/ItemQuery.js.map +0 -1
  29. package/dist/cjs/key/KUtils.js +0 -397
  30. package/dist/cjs/key/KUtils.js.map +0 -1
  31. package/dist/cjs/logger.js +0 -10
  32. package/dist/cjs/logger.js.map +0 -1
  33. package/dist/esm/AItemService.js +0 -38
  34. package/dist/esm/AItemService.js.map +0 -1
  35. package/dist/esm/dictionary.js +0 -67
  36. package/dist/esm/dictionary.js.map +0 -1
  37. package/dist/esm/index.js +0 -9
  38. package/dist/esm/index.js.map +0 -1
  39. package/dist/esm/item/IFactory.js +0 -89
  40. package/dist/esm/item/IFactory.js.map +0 -1
  41. package/dist/esm/item/IQFactory.js +0 -150
  42. package/dist/esm/item/IQFactory.js.map +0 -1
  43. package/dist/esm/item/IQUtils.js +0 -305
  44. package/dist/esm/item/IQUtils.js.map +0 -1
  45. package/dist/esm/item/IUtils.js +0 -69
  46. package/dist/esm/item/IUtils.js.map +0 -1
  47. package/dist/esm/item/ItemQuery.js +0 -6
  48. package/dist/esm/item/ItemQuery.js.map +0 -1
  49. package/dist/esm/key/KUtils.js +0 -365
  50. package/dist/esm/key/KUtils.js.map +0 -1
  51. package/dist/esm/logger.js +0 -6
  52. package/dist/esm/logger.js.map +0 -1
  53. package/dist/index.cjs +0 -1131
  54. package/dist/index.cjs.map +0 -1
  55. package/docs/README.md +0 -53
  56. package/docs/index.html +0 -18
  57. package/docs/package.json +0 -35
  58. package/docs/public/README.md +0 -227
  59. package/docs/public/api.md +0 -230
  60. package/docs/public/basic-usage.ts +0 -293
  61. package/docs/public/examples-README.md +0 -147
  62. package/docs/public/fjell-icon.svg +0 -1
  63. package/docs/public/package.json +0 -56
  64. package/docs/public/pano.png +0 -0
  65. package/docs/src/App.css +0 -1178
  66. package/docs/src/App.tsx +0 -684
  67. package/docs/src/index.css +0 -38
  68. package/docs/src/main.tsx +0 -10
  69. package/docs/tsconfig.node.json +0 -14
  70. package/docs/vitest.config.ts +0 -14
  71. package/examples/README.md +0 -147
  72. package/examples/basic-usage.ts +0 -293
  73. package/vitest.config.ts +0 -37
@@ -1,230 +0,0 @@
1
- # Fjell Core API Reference
2
-
3
- Complete API documentation for all Fjell Core modules and exports.
4
-
5
- ## Overview
6
-
7
- Fjell Core provides a comprehensive set of tools for item management, key utilities, and service coordination. All APIs are built with TypeScript-first design for maximum type safety.
8
-
9
- ## Core Exports
10
-
11
- ### Factory Classes
12
-
13
- #### `IFactory<V, S, L1, L2, L3, L4, L5>`
14
- Generic item factory for creating strongly-typed items with hierarchical key support.
15
-
16
- **Type Parameters:**
17
- - `V extends Item<S, L1, L2, L3, L4, L5>`: The item type being created
18
- - `S extends string`: Primary key type
19
- - `L1-L5 extends string`: Location key types (optional)
20
-
21
- **Constructor:**
22
- ```typescript
23
- new IFactory<V, S, L1, L2, L3, L4, L5>(props?: Record<string, any>)
24
- ```
25
-
26
- **Methods:**
27
-
28
- ##### `addRef(item: Item, name?: string): IFactory`
29
- Adds a reference to another item.
30
-
31
- **Parameters:**
32
- - `item`: The item to reference
33
- - `name`: Optional reference name (defaults to primary type)
34
-
35
- **Returns:** Factory instance for chaining
36
-
37
- ##### `static addRef<V, S, L1, L2, L3, L4, L5>(item: V, name?: string): IFactory`
38
- Static method to create a factory with a reference.
39
-
40
- ##### `addDefaultEvents(): IFactory`
41
- Adds default event timestamps (created, updated).
42
-
43
- **Returns:** Factory instance for chaining
44
-
45
- #### `IQFactory`
46
- Factory for building item queries with filtering, sorting, and pagination.
47
-
48
- ### Utility Classes
49
-
50
- #### `KUtils`
51
- Comprehensive key management utilities for hierarchical key operations.
52
-
53
- **Methods:**
54
-
55
- ##### `createNormalizedHashFunction<T>(): (key: T) => string`
56
- Creates a normalized hash function for consistent key comparison.
57
-
58
- **Returns:** Hash function that normalizes pk/lk values to strings
59
-
60
- ##### `normalizeKeyValue(value: string | number): string`
61
- Normalizes key values for consistent comparison.
62
-
63
- **Parameters:**
64
- - `value`: The value to normalize
65
-
66
- **Returns:** String representation of the value
67
-
68
- ##### `primaryType(key: ComKey | PriKey): string`
69
- Extracts the primary type from a composite or primary key.
70
-
71
- ### Service Classes
72
-
73
- #### `AItemService<S, L1, L2, L3, L4, L5>`
74
- Abstract base class for building domain-specific item services.
75
-
76
- **Type Parameters:**
77
- - `S extends string`: Primary key type
78
- - `L1-L5 extends string`: Location key types (hierarchical)
79
-
80
- **Constructor:**
81
- ```typescript
82
- new AItemService<S, L1, L2, L3, L4, L5>(
83
- pkType: S,
84
- parentService?: AItemService<L1, L2, L3, L4, L5, never>
85
- )
86
- ```
87
-
88
- **Parameters:**
89
- - `pkType`: The primary key type for this service
90
- - `parentService`: Optional parent service for hierarchical structures
91
-
92
- **Methods:**
93
-
94
- ##### `getPkType(): S`
95
- Gets the primary key type for this service.
96
-
97
- **Returns:** The primary key type string
98
-
99
- ##### `getKeyTypes(): AllItemTypeArrays<S, L1, L2, L3, L4, L5>`
100
- Gets all key types managed by this service, including parent service types.
101
-
102
- **Returns:** Array of all key type strings in the hierarchy
103
-
104
- ## Type Definitions
105
-
106
- ### Key Types
107
-
108
- #### `PriKey<S>`
109
- Primary key structure for items.
110
-
111
- #### `ComKey<S, L1, L2, L3, L4, L5>`
112
- Composite key structure supporting hierarchical locations.
113
-
114
- #### `LocKey`
115
- Location key for hierarchical positioning.
116
-
117
- #### `LocKeyArray`
118
- Array of location keys for complex hierarchies.
119
-
120
- ### Item Types
121
-
122
- #### `Item<S, L1, L2, L3, L4, L5>`
123
- Base item interface with hierarchical key support.
124
-
125
- **Properties:**
126
- - `key`: The item's key (PriKey or ComKey)
127
- - `refs?`: Optional references to other items
128
- - `events?`: Optional event timestamps
129
-
130
- ### Query Types
131
-
132
- #### `ItemQuery<S, L1, L2, L3, L4, L5>`
133
- Query structure for filtering and retrieving items.
134
-
135
- ## Utility Functions
136
-
137
- ### Dictionary Operations
138
- Exported from `dictionary` module for key-value operations with normalized hashing.
139
-
140
- ### Key Operations
141
- Exported from `keys` module for advanced key manipulation and validation.
142
-
143
- ### Item Operations
144
- Exported from `items` module for item creation, validation, and transformation.
145
-
146
- ## Query Building
147
-
148
- ### IQFactory
149
- Factory for building complex queries:
150
-
151
- ```typescript
152
- const query = IQFactory.create('user')
153
- .where('status', 'active')
154
- .where('role', 'admin')
155
- .limit(10)
156
- .orderBy('createdAt', 'desc')
157
- ```
158
-
159
- ### IQUtils
160
- Utilities for executing and optimizing queries.
161
-
162
- ### IUtils
163
- General item utilities for validation, transformation, and manipulation.
164
-
165
- ## Best Practices
166
-
167
- ### Type Safety
168
- Always use generic type parameters to ensure compile-time type checking:
169
-
170
- ```typescript
171
- interface User {
172
- id: string
173
- name: string
174
- email: string
175
- }
176
-
177
- const userFactory = new IFactory<User, 'user'>()
178
- const user = userFactory.create({ id: '123', name: 'John', email: 'john@example.com' })
179
- ```
180
-
181
- ### Hierarchical Keys
182
- Use the hierarchical key system for complex data relationships:
183
-
184
- ```typescript
185
- class UserService extends AItemService<'user', 'organization'> {
186
- constructor(orgService: OrganizationService) {
187
- super('user', orgService)
188
- }
189
- }
190
- ```
191
-
192
- ### Key Normalization
193
- Use normalized hash functions for consistent key comparison:
194
-
195
- ```typescript
196
- const hashFn = KUtils.createNormalizedHashFunction<ComKey<'user', 'org'>>()
197
- const hash = hashFn(userKey)
198
- ```
199
-
200
- ## Error Handling
201
-
202
- All methods may throw validation errors or type mismatches. Always wrap operations in try-catch blocks for production code:
203
-
204
- ```typescript
205
- try {
206
- const item = factory.create(data)
207
- const key = KUtils.generateKey(components)
208
- } catch (error) {
209
- console.error('Operation failed:', error.message)
210
- }
211
- ```
212
-
213
- ## Performance Considerations
214
-
215
- - Use normalized hash functions for efficient key comparisons
216
- - Leverage hierarchical services for organized data access
217
- - Implement proper query optimization using IQUtils
218
- - Consider memory usage with large item collections
219
-
220
- ## Integration
221
-
222
- Fjell Core is designed to integrate seamlessly with the entire Fjell ecosystem:
223
-
224
- - **@fjell/registry**: Service location and dependency injection
225
- - **@fjell/cache**: High-performance caching with key-based operations
226
- - **@fjell/lib**: Database abstraction layers
227
- - **@fjell/providers**: React state management
228
- - **@fjell/client-api**: HTTP client utilities
229
-
230
- Each integration maintains the same type safety and hierarchical key principles established in Fjell Core.
@@ -1,293 +0,0 @@
1
- /**
2
- * Basic Usage Example - Fjell Core
3
- *
4
- * This example demonstrates the fundamental operations available in Fjell Core:
5
- * - Item creation with IFactory
6
- * - Key generation and manipulation with KUtils
7
- * - Basic service implementation with AItemService
8
- */
9
-
10
- import { AItemService, IFactory, KUtils } from '@fjell/core'
11
-
12
- // Define our data types
13
- interface User {
14
- id: string
15
- name: string
16
- email: string
17
- createdAt: string
18
- status: 'active' | 'inactive'
19
- }
20
-
21
- interface Product {
22
- id: string
23
- name: string
24
- price: number
25
- category: string
26
- inStock: boolean
27
- }
28
-
29
- /**
30
- * 1. ITEM CREATION WITH IFACTORY
31
- *
32
- * IFactory provides type-safe item creation with validation and defaults.
33
- */
34
- console.log('=== Item Creation Examples ===')
35
-
36
- // Create a user item
37
- const user = IFactory.create<User>('user', {
38
- id: 'user-123',
39
- name: 'John Doe',
40
- email: 'john.doe@example.com',
41
- createdAt: new Date().toISOString(),
42
- status: 'active'
43
- })
44
-
45
- console.log('Created user:', user)
46
-
47
- // Create a product item
48
- const product = IFactory.create<Product>('product', {
49
- id: 'prod-456',
50
- name: 'Wireless Headphones',
51
- price: 199.99,
52
- category: 'Electronics',
53
- inStock: true
54
- })
55
-
56
- console.log('Created product:', product)
57
-
58
- /**
59
- * 2. KEY MANAGEMENT WITH KUTILS
60
- *
61
- * KUtils provides hierarchical key generation and manipulation utilities.
62
- */
63
- console.log('\n=== Key Management Examples ===')
64
-
65
- // Generate hierarchical keys
66
- const userKey = KUtils.generateKey(['users', user.id])
67
- const userProfileKey = KUtils.generateKey(['users', user.id, 'profile'])
68
- const userOrdersKey = KUtils.generateKey(['users', user.id, 'orders'])
69
-
70
- console.log('User key:', userKey)
71
- console.log('User profile key:', userProfileKey)
72
- console.log('User orders key:', userOrdersKey)
73
-
74
- // Parse keys back to components
75
- const userKeyComponents = KUtils.parseKey(userKey)
76
- const profileKeyComponents = KUtils.parseKey(userProfileKey)
77
-
78
- console.log('User key components:', userKeyComponents)
79
- console.log('Profile key components:', profileKeyComponents)
80
-
81
- // Validate keys
82
- const isValidUserKey = KUtils.isValidKey(userKey)
83
- const isValidInvalidKey = KUtils.isValidKey('invalid::key::format')
84
-
85
- console.log('User key is valid:', isValidUserKey)
86
- console.log('Invalid key is valid:', isValidInvalidKey)
87
-
88
- // Get parent keys
89
- const parentOfProfile = KUtils.getParentKey(userProfileKey)
90
- console.log('Parent of profile key:', parentOfProfile)
91
-
92
- /**
93
- * 3. SERVICE LAYER WITH AITEMSERVICE
94
- *
95
- * AItemService provides an abstract base for building domain services.
96
- */
97
- console.log('\n=== Service Layer Examples ===')
98
-
99
- class UserService extends AItemService {
100
- private users = new Map<string, User>()
101
-
102
- async create(userData: Partial<User>): Promise<User> {
103
- console.log('Creating user with data:', userData)
104
-
105
- // Create user with IFactory
106
- const user = IFactory.create<User>('user', {
107
- id: this.generateId(),
108
- createdAt: new Date().toISOString(),
109
- status: 'active',
110
- ...userData
111
- })
112
-
113
- // Validate the user
114
- await this.validate(user)
115
-
116
- // Save the user
117
- await this.save(user)
118
-
119
- console.log('User created successfully:', user.id)
120
- return user
121
- }
122
-
123
- async findById(id: string): Promise<User | null> {
124
- const key = KUtils.generateKey(['users', id])
125
- const user = this.users.get(key)
126
- console.log(`Finding user by ID ${id}:`, user ? 'found' : 'not found')
127
- return user || null
128
- }
129
-
130
- async updateStatus(id: string, status: User['status']): Promise<User | null> {
131
- const user = await this.findById(id)
132
- if (!user) {
133
- console.log(`User ${id} not found for status update`)
134
- return null
135
- }
136
-
137
- const updatedUser = { ...user, status }
138
- await this.save(updatedUser)
139
-
140
- console.log(`User ${id} status updated to ${status}`)
141
- return updatedUser
142
- }
143
-
144
- async listActiveUsers(): Promise<User[]> {
145
- const activeUsers = Array.from(this.users.values())
146
- .filter(user => user.status === 'active')
147
-
148
- console.log(`Found ${activeUsers.length} active users`)
149
- return activeUsers
150
- }
151
-
152
- protected async validate(user: User): Promise<void> {
153
- if (!user.email || !user.email.includes('@')) {
154
- throw new Error('Valid email is required')
155
- }
156
-
157
- if (!user.name || user.name.length < 2) {
158
- throw new Error('Name must be at least 2 characters')
159
- }
160
-
161
- console.log('User validation passed for:', user.email)
162
- }
163
-
164
- protected async save(user: User): Promise<User> {
165
- const key = KUtils.generateKey(['users', user.id])
166
- this.users.set(key, user)
167
- console.log('User saved with key:', key)
168
- return user
169
- }
170
-
171
- private generateId(): string {
172
- return `user-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
173
- }
174
- }
175
-
176
- // Demonstrate service usage
177
- async function demonstrateService() {
178
- const userService = new UserService()
179
-
180
- try {
181
- // Create users
182
- const user1 = await userService.create({
183
- name: 'Alice Smith',
184
- email: 'alice.smith@example.com'
185
- })
186
-
187
- const user2 = await userService.create({
188
- name: 'Bob Johnson',
189
- email: 'bob.johnson@example.com'
190
- })
191
-
192
- // Find users
193
- const foundUser = await userService.findById(user1.id)
194
- console.log('Found user:', foundUser?.name)
195
-
196
- // Update user status
197
- await userService.updateStatus(user2.id, 'inactive')
198
-
199
- // List active users
200
- const activeUsers = await userService.listActiveUsers()
201
- console.log('Active users:', activeUsers.map(u => u.name))
202
-
203
- } catch (error) {
204
- console.error('Service error:', error.message)
205
- }
206
- }
207
-
208
- /**
209
- * 4. PRACTICAL INTEGRATION EXAMPLE
210
- *
211
- * Combining all concepts in a realistic scenario.
212
- */
213
- console.log('\n=== Integration Example ===')
214
-
215
- class OrderService extends AItemService {
216
- private orders = new Map<string, any>()
217
-
218
- constructor(private userService: UserService) {
219
- super()
220
- }
221
-
222
- async createOrder(userId: string, items: any[]): Promise<any> {
223
- // Verify user exists
224
- const user = await this.userService.findById(userId)
225
- if (!user) {
226
- throw new Error(`User ${userId} not found`)
227
- }
228
-
229
- // Create order
230
- const order = IFactory.create('order', {
231
- id: this.generateOrderId(),
232
- userId,
233
- items,
234
- total: this.calculateTotal(items),
235
- status: 'pending',
236
- createdAt: new Date().toISOString()
237
- })
238
-
239
- // Save order
240
- const orderKey = KUtils.generateKey(['orders', order.id])
241
- this.orders.set(orderKey, order)
242
-
243
- console.log(`Order ${order.id} created for user ${user.name}`)
244
- return order
245
- }
246
-
247
- private generateOrderId(): string {
248
- return `order-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
249
- }
250
-
251
- private calculateTotal(items: any[]): number {
252
- return items.reduce((total, item) => total + (item.price * item.quantity), 0)
253
- }
254
- }
255
-
256
- async function demonstrateIntegration() {
257
- const userService = new UserService()
258
- const orderService = new OrderService(userService)
259
-
260
- try {
261
- // Create a user
262
- const user = await userService.create({
263
- name: 'Customer One',
264
- email: 'customer@example.com'
265
- })
266
-
267
- // Create an order for the user
268
- const order = await orderService.createOrder(user.id, [
269
- { name: 'Product A', price: 29.99, quantity: 2 },
270
- { name: 'Product B', price: 15.50, quantity: 1 }
271
- ])
272
-
273
- console.log('Integration completed successfully')
274
- console.log('Order total:', order.total)
275
-
276
- } catch (error) {
277
- console.error('Integration error:', error.message)
278
- }
279
- }
280
-
281
- // Run all demonstrations
282
- async function runExamples() {
283
- await demonstrateService()
284
- await demonstrateIntegration()
285
- console.log('\n=== All examples completed ===')
286
- }
287
-
288
- // Execute if running directly
289
- if (require.main === module) {
290
- runExamples().catch(console.error)
291
- }
292
-
293
- export { UserService, OrderService }
@@ -1,147 +0,0 @@
1
- # Fjell Core Examples
2
-
3
- This directory contains comprehensive examples demonstrating real-world usage patterns for Fjell Core.
4
-
5
- ## Available Examples
6
-
7
- ### Basic Examples
8
-
9
- #### [basic-usage.ts](./basic-usage.ts)
10
- Demonstrates fundamental Fjell Core operations:
11
- - Item creation with IFactory
12
- - Key generation and manipulation with KUtils
13
- - Basic service implementation with AItemService
14
-
15
- #### [service-patterns.ts](./service-patterns.ts)
16
- Shows common service implementation patterns:
17
- - Repository pattern implementation
18
- - Service composition
19
- - Error handling strategies
20
-
21
- #### [query-examples.ts](./query-examples.ts)
22
- Query building and execution examples:
23
- - Basic query construction
24
- - Complex filtering and sorting
25
- - Query optimization techniques
26
-
27
- ### Advanced Examples
28
-
29
- #### [enterprise-example.ts](./enterprise-example.ts)
30
- Production-ready enterprise patterns:
31
- - Multi-layered service architecture
32
- - Transaction management
33
- - Comprehensive error handling
34
- - Performance optimization
35
-
36
- #### [testing-example.ts](./testing-example.ts)
37
- Testing strategies and utilities:
38
- - Unit testing with Fjell Core
39
- - Mock creation and management
40
- - Integration testing patterns
41
-
42
- ## Running the Examples
43
-
44
- All examples are TypeScript files that can be run directly:
45
-
46
- ```bash
47
- # Using ts-node
48
- npx ts-node examples/basic-usage.ts
49
-
50
- # Using tsx
51
- npx tsx examples/basic-usage.ts
52
-
53
- # Compile and run
54
- tsc examples/basic-usage.ts && node examples/basic-usage.js
55
- ```
56
-
57
- ## Prerequisites
58
-
59
- Make sure you have Fjell Core installed:
60
-
61
- ```bash
62
- npm install @fjell/core
63
- ```
64
-
65
- For the examples that integrate with databases or external services, you may need additional dependencies as noted in each example.
66
-
67
- ## Example Structure
68
-
69
- Each example follows a consistent structure:
70
-
71
- 1. **Imports**: Required Fjell Core modules
72
- 2. **Type Definitions**: TypeScript interfaces and types
73
- 3. **Implementation**: Core logic demonstration
74
- 4. **Usage**: Practical usage examples
75
- 5. **Output**: Expected results and explanations
76
-
77
- ## Integration Examples
78
-
79
- Several examples show integration with popular libraries and frameworks:
80
-
81
- - Express.js web applications
82
- - Database ORMs (Sequelize, TypeORM)
83
- - Testing frameworks (Jest, Vitest)
84
- - React applications
85
- - GraphQL APIs
86
-
87
- ## Best Practices
88
-
89
- The examples demonstrate Fjell Core best practices:
90
-
91
- - **Type Safety**: Comprehensive TypeScript usage
92
- - **Error Handling**: Robust error management
93
- - **Performance**: Optimized patterns for production
94
- - **Testing**: Comprehensive test coverage
95
- - **Documentation**: Clear code documentation
96
-
97
- ## Contributing Examples
98
-
99
- We welcome new examples! Please follow these guidelines:
100
-
101
- 1. Create a new TypeScript file with a descriptive name
102
- 2. Include comprehensive comments explaining the concepts
103
- 3. Add proper type definitions
104
- 4. Include usage examples and expected output
105
- 5. Update this README with a description of your example
106
-
107
- ## Getting Help
108
-
109
- If you have questions about any example:
110
-
111
- 1. Check the inline comments for explanations
112
- 2. Review the main Fjell Core documentation
113
- 3. Open an issue on GitHub for specific questions
114
- 4. Join our community discussions
115
-
116
- ## Common Patterns Demonstrated
117
-
118
- ### Factory Pattern
119
- ```typescript
120
- const user = IFactory.create<User>('user', userData)
121
- ```
122
-
123
- ### Repository Pattern
124
- ```typescript
125
- class UserRepository extends AItemService {
126
- async save(user: User): Promise<User> { ... }
127
- async findById(id: string): Promise<User | null> { ... }
128
- }
129
- ```
130
-
131
- ### Service Layer
132
- ```typescript
133
- class UserService extends AItemService {
134
- constructor(private userRepo: UserRepository) { super() }
135
- async registerUser(data: UserData): Promise<User> { ... }
136
- }
137
- ```
138
-
139
- ### Query Building
140
- ```typescript
141
- const query = IQFactory.create('user')
142
- .where('status', 'active')
143
- .orderBy('createdAt', 'desc')
144
- .limit(10)
145
- ```
146
-
147
- These examples provide a solid foundation for building production applications with Fjell Core.
@@ -1 +0,0 @@
1
-