@meridianjs/user 0.1.7 → 0.1.9

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 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
package/dist/index.d.mts CHANGED
@@ -13,6 +13,11 @@ declare class UserModuleService extends UserModuleService_base {
13
13
  recordLogin(userId: string): Promise<void>;
14
14
  /** Deactivate a user account. */
15
15
  deactivateUser(userId: string): Promise<any>;
16
+ /**
17
+ * Restore a soft-deleted user account.
18
+ * Bypasses UPDATE_RESERVED to clear deleted_at directly via the repository.
19
+ */
20
+ restoreUser(userId: string, data?: Record<string, unknown>): Promise<any>;
16
21
  /** Return the total number of registered users. */
17
22
  countUsers(): Promise<number>;
18
23
  /** Store a new session record when a token is issued. */
package/dist/index.d.ts CHANGED
@@ -13,6 +13,11 @@ declare class UserModuleService extends UserModuleService_base {
13
13
  recordLogin(userId: string): Promise<void>;
14
14
  /** Deactivate a user account. */
15
15
  deactivateUser(userId: string): Promise<any>;
16
+ /**
17
+ * Restore a soft-deleted user account.
18
+ * Bypasses UPDATE_RESERVED to clear deleted_at directly via the repository.
19
+ */
20
+ restoreUser(userId: string, data?: Record<string, unknown>): Promise<any>;
16
21
  /** Return the total number of registered users. */
17
22
  countUsers(): Promise<number>;
18
23
  /** Store a new session record when a token is issued. */
package/dist/index.js CHANGED
@@ -112,6 +112,17 @@ var UserModuleService = class extends (0, import_framework_utils4.MeridianServic
112
112
  async deactivateUser(userId) {
113
113
  return this.updateUser(userId, { is_active: false });
114
114
  }
115
+ /**
116
+ * Restore a soft-deleted user account.
117
+ * Bypasses UPDATE_RESERVED to clear deleted_at directly via the repository.
118
+ */
119
+ async restoreUser(userId, data = {}) {
120
+ const repo = this.container.resolve("userRepository");
121
+ const user = await repo.findOneOrFail({ id: userId });
122
+ Object.assign(user, { ...data, deleted_at: null, is_active: true });
123
+ await repo.flush();
124
+ return user;
125
+ }
115
126
  /** Return the total number of registered users. */
116
127
  async countUsers() {
117
128
  const userRepository = this.container.resolve("userRepository");
package/dist/index.mjs CHANGED
@@ -86,6 +86,17 @@ var UserModuleService = class extends MeridianService({ User: user_default, Team
86
86
  async deactivateUser(userId) {
87
87
  return this.updateUser(userId, { is_active: false });
88
88
  }
89
+ /**
90
+ * Restore a soft-deleted user account.
91
+ * Bypasses UPDATE_RESERVED to clear deleted_at directly via the repository.
92
+ */
93
+ async restoreUser(userId, data = {}) {
94
+ const repo = this.container.resolve("userRepository");
95
+ const user = await repo.findOneOrFail({ id: userId });
96
+ Object.assign(user, { ...data, deleted_at: null, is_active: true });
97
+ await repo.flush();
98
+ return user;
99
+ }
89
100
  /** Return the total number of registered users. */
90
101
  async countUsers() {
91
102
  const userRepository = this.container.resolve("userRepository");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meridianjs/user",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Meridian user module — User and Team domain models",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",