@olasphe/mysql 1.0.0 → 1.1.0
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/dist/index.d.ts +1 -1
- package/dist/index.js +4 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUserRepository, ISessionRepository, User, Session } from '@
|
|
1
|
+
import { IUserRepository, ISessionRepository, User, Session } from '@olasphe/core';
|
|
2
2
|
import mysql from 'mysql2/promise';
|
|
3
3
|
export declare class MySQLUserRepository implements IUserRepository {
|
|
4
4
|
private pool;
|
package/dist/index.js
CHANGED
|
@@ -11,11 +11,12 @@ class MySQLUserRepository {
|
|
|
11
11
|
const id = (0, crypto_1.randomUUID)();
|
|
12
12
|
const now = new Date();
|
|
13
13
|
// Check table exists? Assumed migrated.
|
|
14
|
-
await this.pool.execute(`INSERT INTO users (id, email, passwordHash, isVerified, verificationToken, verificationExpires, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [id, data.email, data.passwordHash, data.isVerified, data.verificationToken || null, data.verificationExpires || null, now, now]);
|
|
14
|
+
await this.pool.execute(`INSERT INTO users (id, email, passwordHash, isVerified, verificationToken, verificationExpires, role, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [id, data.email, data.passwordHash, data.isVerified, data.verificationToken || null, data.verificationExpires || null, data.role || 'user', now, now]);
|
|
15
15
|
return {
|
|
16
16
|
id,
|
|
17
17
|
...data,
|
|
18
18
|
isVerified: data.isVerified ?? false,
|
|
19
|
+
role: data.role || 'user',
|
|
19
20
|
createdAt: now,
|
|
20
21
|
updatedAt: now
|
|
21
22
|
};
|
|
@@ -61,6 +62,7 @@ class MySQLUserRepository {
|
|
|
61
62
|
isVerified: Boolean(row.isVerified), // MySQL often returns 1/0
|
|
62
63
|
verificationToken: row.verificationToken,
|
|
63
64
|
verificationExpires: row.verificationExpires,
|
|
65
|
+
role: row.role,
|
|
64
66
|
createdAt: row.createdAt,
|
|
65
67
|
updatedAt: row.updatedAt
|
|
66
68
|
};
|
|
@@ -113,6 +115,7 @@ async function createTables(pool) {
|
|
|
113
115
|
isVerified BOOLEAN DEFAULT FALSE,
|
|
114
116
|
verificationToken VARCHAR(255),
|
|
115
117
|
verificationExpires DATETIME,
|
|
118
|
+
role VARCHAR(20) DEFAULT 'user',
|
|
116
119
|
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
117
120
|
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
118
121
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olasphe/mysql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Auth SDK User <user@example.com>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build": "tsc"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@olasphe/core": "
|
|
22
|
+
"@olasphe/core": "^1.1.0",
|
|
23
23
|
"mysql2": "^3.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|