@ooneex/entity 0.0.18 → 1.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/README.md +109 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1 +1,110 @@
|
|
|
1
1
|
# @ooneex/entity
|
|
2
|
+
|
|
3
|
+
Base entity classes and decorators for defining database models with type-safe column mappings, relationships, and lifecycle hooks. This package provides the foundational `IEntity` interface and `EntityClassType` used across the Ooneex framework for domain-driven design patterns.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
✅ **Base Interface** - `IEntity` interface with required `id` field for all domain entities
|
|
12
|
+
|
|
13
|
+
✅ **Class Type** - `EntityClassType` for type-safe entity class references in DI and repositories
|
|
14
|
+
|
|
15
|
+
✅ **Domain-Driven Design** - Foundation for building domain models in the Ooneex framework
|
|
16
|
+
|
|
17
|
+
✅ **Type-Safe** - Full TypeScript support with proper type definitions
|
|
18
|
+
|
|
19
|
+
✅ **Lightweight** - Minimal package with zero runtime dependencies
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun add @ooneex/entity
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Implementing an Entity
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import type { IEntity } from '@ooneex/entity';
|
|
33
|
+
|
|
34
|
+
class UserEntity implements IEntity {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
email: string;
|
|
38
|
+
|
|
39
|
+
constructor(id: string, name: string, email: string) {
|
|
40
|
+
this.id = id;
|
|
41
|
+
this.name = name;
|
|
42
|
+
this.email = email;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Using EntityClassType
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import type { EntityClassType, IEntity } from '@ooneex/entity';
|
|
51
|
+
|
|
52
|
+
function createRepository(entityClass: EntityClassType) {
|
|
53
|
+
// Use entity class reference for DI or repository creation
|
|
54
|
+
const instance = new entityClass();
|
|
55
|
+
return instance;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API Reference
|
|
60
|
+
|
|
61
|
+
### Interfaces
|
|
62
|
+
|
|
63
|
+
#### `IEntity`
|
|
64
|
+
|
|
65
|
+
Base interface for all domain entities.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
interface IEntity {
|
|
69
|
+
id: string;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Properties:**
|
|
74
|
+
- `id` - Unique string identifier for the entity
|
|
75
|
+
|
|
76
|
+
### Types
|
|
77
|
+
|
|
78
|
+
#### `EntityClassType`
|
|
79
|
+
|
|
80
|
+
Constructor type for entity classes implementing `IEntity`.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
type EntityClassType = new (...args: any[]) => IEntity;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
89
|
+
|
|
90
|
+
## Contributing
|
|
91
|
+
|
|
92
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
93
|
+
|
|
94
|
+
### Development Setup
|
|
95
|
+
|
|
96
|
+
1. Clone the repository
|
|
97
|
+
2. Install dependencies: `bun install`
|
|
98
|
+
3. Run tests: `bun run test`
|
|
99
|
+
4. Build the project: `bun run build`
|
|
100
|
+
|
|
101
|
+
### Guidelines
|
|
102
|
+
|
|
103
|
+
- Write tests for new features
|
|
104
|
+
- Follow the existing code style
|
|
105
|
+
- Update documentation for API changes
|
|
106
|
+
- Ensure all tests pass before submitting PR
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
Made with ❤️ by the Ooneex team
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/entity",
|
|
3
|
-
"description": "Base entity classes and decorators for defining database models and
|
|
4
|
-
"version": "
|
|
3
|
+
"description": "Base entity classes and decorators for defining database models with type-safe column mappings, relationships, and lifecycle hooks",
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "bunup",
|
|
26
26
|
"lint": "tsgo --noEmit && bunx biome lint",
|
|
27
|
-
"npm:publish": "bun publish --tolerate-republish --access public",
|
|
27
|
+
"npm:publish": "bun publish --tolerate-republish --force --production --access public",
|
|
28
28
|
"test": "bun test tests"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|