@fjell/core 4.4.7 → 4.4.13
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 +227 -0
- package/dist/cjs/item/IUtils.js.map +1 -1
- package/dist/esm/item/IUtils.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/docs/README.md +53 -0
- package/docs/index.html +18 -0
- package/docs/package.json +35 -0
- package/docs/public/README.md +227 -0
- package/docs/public/api.md +230 -0
- package/docs/public/basic-usage.ts +293 -0
- package/docs/public/examples-README.md +147 -0
- package/docs/public/fjell-icon.svg +1 -0
- package/docs/public/package.json +56 -0
- package/docs/public/pano.png +0 -0
- package/docs/src/App.css +1178 -0
- package/docs/src/App.tsx +683 -0
- package/docs/src/index.css +38 -0
- package/docs/src/main.tsx +10 -0
- package/docs/tsconfig.node.json +14 -0
- package/docs/vitest.config.ts +14 -0
- package/examples/README.md +147 -0
- package/examples/basic-usage.ts +293 -0
- package/package.json +7 -6
- package/src/item/IUtils.ts +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Fjell Core
|
|
2
|
+
|
|
3
|
+
Core Item and Key Framework for Fjell - The foundational library that provides essential item management, key utilities, and service coordination for the entire Fjell ecosystem.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Type-safe item creation** with IFactory
|
|
8
|
+
- **Hierarchical key management** with KUtils
|
|
9
|
+
- **Abstract service layer** with AItemService
|
|
10
|
+
- **Query building and execution** with IQFactory and IQUtils
|
|
11
|
+
- **Comprehensive error handling** with custom error types
|
|
12
|
+
- **Testing utilities** for robust test suites
|
|
13
|
+
- **TypeScript-first design** for excellent developer experience
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @fjell/core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { IFactory, KUtils, AItemService } from '@fjell/core'
|
|
25
|
+
|
|
26
|
+
// Create items with the factory
|
|
27
|
+
const user = IFactory.create('user', {
|
|
28
|
+
id: 'user-123',
|
|
29
|
+
name: 'John Doe',
|
|
30
|
+
email: 'john@example.com'
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// Generate hierarchical keys
|
|
34
|
+
const userKey = KUtils.generateKey(['users', user.id])
|
|
35
|
+
|
|
36
|
+
// Build services
|
|
37
|
+
class UserService extends AItemService {
|
|
38
|
+
async createUser(userData: any) {
|
|
39
|
+
const user = IFactory.create('user', userData)
|
|
40
|
+
await this.validate(user)
|
|
41
|
+
return this.save(user)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Core Modules
|
|
47
|
+
|
|
48
|
+
### IFactory
|
|
49
|
+
Factory for creating strongly-typed items with validation and defaults.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface User {
|
|
53
|
+
id: string
|
|
54
|
+
name: string
|
|
55
|
+
email: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const user = IFactory.create<User>('user', {
|
|
59
|
+
id: 'user-123',
|
|
60
|
+
name: 'John Doe',
|
|
61
|
+
email: 'john@example.com'
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### KUtils
|
|
66
|
+
Utilities for hierarchical key generation and manipulation.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Generate keys
|
|
70
|
+
const userKey = KUtils.generateKey(['users', 'user-123'])
|
|
71
|
+
const profileKey = KUtils.generateKey(['users', 'user-123', 'profile'])
|
|
72
|
+
|
|
73
|
+
// Parse keys
|
|
74
|
+
const components = KUtils.parseKey(userKey) // ['users', 'user-123']
|
|
75
|
+
|
|
76
|
+
// Validate keys
|
|
77
|
+
const isValid = KUtils.isValidKey(userKey) // true
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### AItemService
|
|
81
|
+
Abstract base class for building domain services with lifecycle management.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
class UserService extends AItemService {
|
|
85
|
+
async create(userData: Partial<User>): Promise<User> {
|
|
86
|
+
const user = IFactory.create<User>('user', userData)
|
|
87
|
+
await this.validate(user)
|
|
88
|
+
return this.save(user)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected async validate(user: User): Promise<void> {
|
|
92
|
+
if (!user.email.includes('@')) {
|
|
93
|
+
throw new Error('Invalid email')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Query System
|
|
100
|
+
Build and execute queries with IQFactory and IQUtils.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const query = IQFactory.create('user')
|
|
104
|
+
.where('status', 'active')
|
|
105
|
+
.where('role', 'admin')
|
|
106
|
+
.orderBy('createdAt', 'desc')
|
|
107
|
+
.limit(10)
|
|
108
|
+
|
|
109
|
+
const results = await IQUtils.execute(query)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Architecture Philosophy
|
|
113
|
+
|
|
114
|
+
Fjell Core is designed around **progressive enhancement**:
|
|
115
|
+
|
|
116
|
+
1. **Start Simple**: Basic operations require minimal setup
|
|
117
|
+
2. **Scale Gradually**: Add complexity only when needed
|
|
118
|
+
3. **Maintain Consistency**: Common patterns across all Fjell libraries
|
|
119
|
+
4. **Enable Integration**: Designed to work with the entire ecosystem
|
|
120
|
+
|
|
121
|
+
## Integration with Fjell Ecosystem
|
|
122
|
+
|
|
123
|
+
Fjell Core serves as the foundation for:
|
|
124
|
+
|
|
125
|
+
- **@fjell/registry**: Service location and dependency injection
|
|
126
|
+
- **@fjell/cache**: High-performance caching solutions
|
|
127
|
+
- **@fjell/lib**: Database abstraction layers
|
|
128
|
+
- **@fjell/providers**: React component state management
|
|
129
|
+
- **@fjell/client-api**: HTTP client utilities
|
|
130
|
+
- **@fjell/express-router**: Express.js routing utilities
|
|
131
|
+
|
|
132
|
+
## Type Safety
|
|
133
|
+
|
|
134
|
+
Built with TypeScript-first design for excellent developer experience:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Strongly typed factories
|
|
138
|
+
const user = IFactory.create<UserType>('user', userData)
|
|
139
|
+
|
|
140
|
+
// Type-safe key operations
|
|
141
|
+
const key = KUtils.generateKey(['users', user.id])
|
|
142
|
+
const [collection, id] = KUtils.parseKey(key)
|
|
143
|
+
|
|
144
|
+
// Compile-time validation
|
|
145
|
+
class UserService extends AItemService<User> {
|
|
146
|
+
// Methods are typed to work with User objects
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Error Handling
|
|
151
|
+
|
|
152
|
+
Comprehensive error handling with descriptive messages:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
try {
|
|
156
|
+
const user = await userService.create(invalidData)
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error instanceof CoreValidationError) {
|
|
159
|
+
console.log('Validation failed:', error.details)
|
|
160
|
+
} else if (error instanceof CoreNotFoundError) {
|
|
161
|
+
console.log('User not found:', error.id)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Testing Support
|
|
167
|
+
|
|
168
|
+
Built-in testing utilities for robust test suites:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { TestUtils } from '@fjell/core/testing'
|
|
172
|
+
|
|
173
|
+
// Mock factories
|
|
174
|
+
const mockFactory = TestUtils.createMockFactory()
|
|
175
|
+
const testUser = mockFactory.create('user', { id: 'test-123' })
|
|
176
|
+
|
|
177
|
+
// Assertion helpers
|
|
178
|
+
expect(TestUtils.isValidKey(key)).toBe(true)
|
|
179
|
+
expect(TestUtils.getKeyComponents(key)).toEqual(['users', '123'])
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Performance
|
|
183
|
+
|
|
184
|
+
Optimized for production use:
|
|
185
|
+
|
|
186
|
+
- **Minimal Runtime Overhead**: Core operations are highly optimized
|
|
187
|
+
- **Memory Efficient**: Smart object pooling and reuse strategies
|
|
188
|
+
- **Lazy Loading**: Components load only when needed
|
|
189
|
+
- **Tree Shaking**: Only bundle what you use
|
|
190
|
+
|
|
191
|
+
## Examples
|
|
192
|
+
|
|
193
|
+
Check out the `/examples` directory for comprehensive usage examples:
|
|
194
|
+
|
|
195
|
+
- Basic item and key operations
|
|
196
|
+
- Service implementation patterns
|
|
197
|
+
- Query building and execution
|
|
198
|
+
- Integration with databases and APIs
|
|
199
|
+
- Testing strategies
|
|
200
|
+
|
|
201
|
+
## Documentation
|
|
202
|
+
|
|
203
|
+
- **Getting Started**: Step-by-step setup guide
|
|
204
|
+
- **API Reference**: Complete API documentation
|
|
205
|
+
- **Examples**: Real-world usage patterns
|
|
206
|
+
- **Migration Guide**: Upgrading from previous versions
|
|
207
|
+
|
|
208
|
+
## Contributing
|
|
209
|
+
|
|
210
|
+
We welcome contributions! Please see our contributing guidelines for details on:
|
|
211
|
+
|
|
212
|
+
- Code style and standards
|
|
213
|
+
- Testing requirements
|
|
214
|
+
- Documentation standards
|
|
215
|
+
- Pull request process
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
Licensed under the Apache License 2.0. See LICENSE file for details.
|
|
220
|
+
|
|
221
|
+
## Support
|
|
222
|
+
|
|
223
|
+
- **GitHub Issues**: Report bugs and request features
|
|
224
|
+
- **Discussions**: Community support and questions
|
|
225
|
+
- **Documentation**: Comprehensive guides and API reference
|
|
226
|
+
|
|
227
|
+
Built with love by the Fjell team.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IUtils.js","sources":["../../../src/item/IUtils.ts"],"sourcesContent":["/* eslint-disable indent */\n
|
|
1
|
+
{"version":3,"file":"IUtils.js","sources":["../../../src/item/IUtils.ts"],"sourcesContent":["/* eslint-disable indent */\n \nimport { Item } from \"@/items\";\nimport { isComKey, isPriKey, toKeyTypeArray } from \"@/key/KUtils\";\nimport { AllItemTypeArrays, ComKey, PriKey } from \"@/keys\";\n\nimport LibLogger from '@/logger';\n\nconst logger = LibLogger.get('IUtils');\n\nconst validatePKForItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(item: Item<S, L1, L2, L3, L4, L5>, pkType: S): Item<S, L1, L2, L3, L4, L5> => {\n if (!item) {\n logger.error('Validating PK, Item is undefined', { item });\n throw new Error('Validating PK, Item is undefined');\n }\n if (!item.key) {\n logger.error('Validating PK, Item does not have a key', { item });\n throw new Error('Validating PK, Item does not have a key');\n }\n\n const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);\n if (keyTypeArray[0] !== pkType) {\n logger.error('Key Type Array Mismatch', { keyTypeArray, pkType });\n throw new Error(`Item does not have the correct primary key type. Expected ${pkType}, got ${keyTypeArray[0]}`);\n }\n return item;\n};\n\nexport const validatePK = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n input: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[],\n pkType: S,\n): Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {\n logger.trace('Checking Return Type', { input });\n\n if (Array.isArray(input)) {\n return input.map((item) => validatePKForItem(item, pkType));\n }\n return validatePKForItem(input, pkType);\n};\n\nexport const validateKeys = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>,\n): Item<S, L1, L2, L3, L4, L5> => {\n logger.trace('Checking Return Type', { item });\n if (!item) {\n throw new Error('validating keys, item is undefined');\n }\n if (!item.key) {\n throw new Error('validating keys, item does not have a key: ' + JSON.stringify(item));\n }\n\n const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);\n if (keyTypeArray.length !== keyTypes.length) {\n throw new Error(`Item does not have the correct number of keys. Expected ${keyTypes.length}, but got ${keyTypeArray.length}`);\n }\n\n const match: boolean = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);\n if (!match) {\n logger.error('Key Type Array Mismatch', { keyTypeArray, thisKeyTypes: keyTypes });\n throw new Error(`Item does not have the correct key types. Expected [${keyTypes.join(', ')}], but got [${keyTypeArray.join(', ')}]`);\n }\n return item;\n};\n\nexport const isPriItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n): item is Item<S> & { key: PriKey<S> } => {\n return !!(item && item.key && isPriKey(item.key));\n};\n\nexport const isComItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n): item is Item<S, L1, L2, L3, L4, L5> & { key: ComKey<S, L1, L2, L3, L4, L5> } => {\n return !!(item && item.key && isComKey(item.key));\n};"],"names":["logger","LibLogger","get","validatePKForItem","item","pkType","error","Error","key","keyTypeArray","toKeyTypeArray","validatePK","input","trace","Array","isArray","map","validateKeys","keyTypes","JSON","stringify","length","match","thisKeyTypes","join","isPriItem","isPriKey","isComItem","isComKey"],"mappings":";;;;;;;AAQA,MAAMA,MAAAA,GAASC,gBAAAA,CAAUC,GAAG,CAAC,QAAA,CAAA;AAE7B,MAAMC,iBAAAA,GAAoB,CAOxBC,IAAAA,EAAmCC,MAAAA,GAAAA;AACnC,IAAA,IAAI,CAACD,IAAAA,EAAM;QACTJ,MAAAA,CAAOM,KAAK,CAAC,kCAAA,EAAoC;AAAEF,YAAAA;AAAK,SAAA,CA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AQA,IAAAA,CAAKI,GAAG,IAAIoB,eAAAA,CAASxB,IAAAA,CAAKI,GAAG,CAAA,CAAA;AACjD;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IUtils.js","sources":["../../../src/item/IUtils.ts"],"sourcesContent":["/* eslint-disable indent */\n
|
|
1
|
+
{"version":3,"file":"IUtils.js","sources":["../../../src/item/IUtils.ts"],"sourcesContent":["/* eslint-disable indent */\n \nimport { Item } from \"@/items\";\nimport { isComKey, isPriKey, toKeyTypeArray } from \"@/key/KUtils\";\nimport { AllItemTypeArrays, ComKey, PriKey } from \"@/keys\";\n\nimport LibLogger from '@/logger';\n\nconst logger = LibLogger.get('IUtils');\n\nconst validatePKForItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(item: Item<S, L1, L2, L3, L4, L5>, pkType: S): Item<S, L1, L2, L3, L4, L5> => {\n if (!item) {\n logger.error('Validating PK, Item is undefined', { item });\n throw new Error('Validating PK, Item is undefined');\n }\n if (!item.key) {\n logger.error('Validating PK, Item does not have a key', { item });\n throw new Error('Validating PK, Item does not have a key');\n }\n\n const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);\n if (keyTypeArray[0] !== pkType) {\n logger.error('Key Type Array Mismatch', { keyTypeArray, pkType });\n throw new Error(`Item does not have the correct primary key type. Expected ${pkType}, got ${keyTypeArray[0]}`);\n }\n return item;\n};\n\nexport const validatePK = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n input: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[],\n pkType: S,\n): Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {\n logger.trace('Checking Return Type', { input });\n\n if (Array.isArray(input)) {\n return input.map((item) => validatePKForItem(item, pkType));\n }\n return validatePKForItem(input, pkType);\n};\n\nexport const validateKeys = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>,\n): Item<S, L1, L2, L3, L4, L5> => {\n logger.trace('Checking Return Type', { item });\n if (!item) {\n throw new Error('validating keys, item is undefined');\n }\n if (!item.key) {\n throw new Error('validating keys, item does not have a key: ' + JSON.stringify(item));\n }\n\n const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);\n if (keyTypeArray.length !== keyTypes.length) {\n throw new Error(`Item does not have the correct number of keys. Expected ${keyTypes.length}, but got ${keyTypeArray.length}`);\n }\n\n const match: boolean = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);\n if (!match) {\n logger.error('Key Type Array Mismatch', { keyTypeArray, thisKeyTypes: keyTypes });\n throw new Error(`Item does not have the correct key types. Expected [${keyTypes.join(', ')}], but got [${keyTypeArray.join(', ')}]`);\n }\n return item;\n};\n\nexport const isPriItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n): item is Item<S> & { key: PriKey<S> } => {\n return !!(item && item.key && isPriKey(item.key));\n};\n\nexport const isComItem = <\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n item: Item<S, L1, L2, L3, L4, L5>,\n): item is Item<S, L1, L2, L3, L4, L5> & { key: ComKey<S, L1, L2, L3, L4, L5> } => {\n return !!(item && item.key && isComKey(item.key));\n};"],"names":["logger","LibLogger","get","validatePKForItem","item","pkType","error","Error","key","keyTypeArray","toKeyTypeArray","validatePK","input","trace","Array","isArray","map","validateKeys","keyTypes","JSON","stringify","length","match","this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