@meridianjs/user 0.1.7 → 0.1.8
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 +89 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @meridianjs/user
|
|
2
|
+
|
|
3
|
+
User, Team, and session management module for MeridianJS. Provides the `User` and `Team` data models, auto-generated CRUD, and custom helpers for email/Google ID lookups, login tracking, and session management.
|
|
4
|
+
|
|
5
|
+
Auto-loaded by `@meridianjs/meridian` — you do not need to add this to `modules[]` yourself.
|
|
6
|
+
|
|
7
|
+
## Service: `userModuleService`
|
|
8
|
+
|
|
9
|
+
Resolve from the DI container in a route handler:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const svc = req.scope.resolve("userModuleService") as any
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Auto-generated CRUD
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Users
|
|
19
|
+
await svc.listUsers(filters?, options?)
|
|
20
|
+
await svc.listAndCountUsers(filters?, options?)
|
|
21
|
+
await svc.retrieveUser(id)
|
|
22
|
+
await svc.createUser(data)
|
|
23
|
+
await svc.updateUser(id, data)
|
|
24
|
+
await svc.deleteUser(id)
|
|
25
|
+
await svc.softDeleteUser(id)
|
|
26
|
+
|
|
27
|
+
// Teams
|
|
28
|
+
await svc.listTeams(filters?, options?)
|
|
29
|
+
await svc.retrieveTeam(id)
|
|
30
|
+
await svc.createTeam(data)
|
|
31
|
+
await svc.updateTeam(id, data)
|
|
32
|
+
await svc.deleteTeam(id)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Custom Methods
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// Find a user by email address (returns null if not found)
|
|
39
|
+
const user = await svc.retrieveUserByEmail("alice@example.com")
|
|
40
|
+
|
|
41
|
+
// Find a user by their Google OAuth ID
|
|
42
|
+
const user = await svc.retrieveUserByGoogleId(googleId)
|
|
43
|
+
|
|
44
|
+
// Update last_login_at timestamp
|
|
45
|
+
await svc.recordLogin(userId)
|
|
46
|
+
|
|
47
|
+
// Deactivate an account (sets is_active: false)
|
|
48
|
+
await svc.deactivateUser(userId)
|
|
49
|
+
|
|
50
|
+
// Total registered user count
|
|
51
|
+
const count = await svc.countUsers()
|
|
52
|
+
|
|
53
|
+
// Session management (for JWT revocation)
|
|
54
|
+
await svc.createSession(jti, userId, expiresAt)
|
|
55
|
+
await svc.retrieveValidSession(jti)
|
|
56
|
+
await svc.revokeSession(jti)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Data Models
|
|
60
|
+
|
|
61
|
+
### User
|
|
62
|
+
|
|
63
|
+
| Field | Type | Description |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `id` | `uuid` | Primary key |
|
|
66
|
+
| `email` | `text` | Unique email address |
|
|
67
|
+
| `password_hash` | `text` | bcrypt hash (nullable for OAuth users) |
|
|
68
|
+
| `first_name` | `text` | — |
|
|
69
|
+
| `last_name` | `text` | — |
|
|
70
|
+
| `google_id` | `text` | Google OAuth ID (nullable) |
|
|
71
|
+
| `picture` | `text` | Profile picture URL (nullable) |
|
|
72
|
+
| `is_active` | `boolean` | Account active flag |
|
|
73
|
+
| `last_login_at` | `datetime` | Last successful login |
|
|
74
|
+
| `app_role_id` | `text` | Optional custom RBAC role |
|
|
75
|
+
| `created_at` | `datetime` | — |
|
|
76
|
+
| `updated_at` | `datetime` | — |
|
|
77
|
+
|
|
78
|
+
### Team
|
|
79
|
+
|
|
80
|
+
| Field | Type | Description |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `id` | `uuid` | Primary key |
|
|
83
|
+
| `name` | `text` | Team name |
|
|
84
|
+
| `workspace_id` | `text` | Owning workspace |
|
|
85
|
+
| `created_at` | `datetime` | — |
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|