@experts_hub/shared 1.0.24 → 1.0.26

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.
@@ -0,0 +1,2 @@
1
+ export * from './tcp/user.tcp.adapter';
2
+ export * from './rmq/user.rmq.adapter';
@@ -0,0 +1,2 @@
1
+ import { MicroserviceOptions } from "@nestjs/microservices";
2
+ export declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
@@ -0,0 +1,2 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+ export declare const UserTCPAdapter: () => MicroserviceOptions;
@@ -0,0 +1,2 @@
1
+ export * from './user.entity';
2
+ export * from './refresh-token.entity';
@@ -0,0 +1,12 @@
1
+ import { User } from './user.entity';
2
+ export declare class RefreshToken {
3
+ id: string;
4
+ userId: string;
5
+ tokenId: string;
6
+ deviceInfo: any;
7
+ isRevoked: boolean;
8
+ expiresAt: Date;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ user: User;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { RefreshToken } from './refresh-token.entity';
2
+ export declare class User {
3
+ id: string;
4
+ username: string;
5
+ email: string;
6
+ password: string;
7
+ firstName: string;
8
+ lastName: string;
9
+ role: string;
10
+ isActive: boolean;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ refreshTokens: RefreshToken[];
14
+ }
package/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+
1
3
  declare const AUTHENTICATION_PATTERN: {
2
4
  handleValidateToken: string;
3
5
  handleLogin: string;
@@ -8,4 +10,34 @@ declare const AUTHENTICATION_PATTERN: {
8
10
  revokeSession: string;
9
11
  };
10
12
 
11
- export { AUTHENTICATION_PATTERN };
13
+ declare const UserTCPAdapter: () => MicroserviceOptions;
14
+
15
+ declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
16
+
17
+ declare class RefreshToken {
18
+ id: string;
19
+ userId: string;
20
+ tokenId: string;
21
+ deviceInfo: any;
22
+ isRevoked: boolean;
23
+ expiresAt: Date;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ user: User;
27
+ }
28
+
29
+ declare class User {
30
+ id: string;
31
+ username: string;
32
+ email: string;
33
+ password: string;
34
+ firstName: string;
35
+ lastName: string;
36
+ role: string;
37
+ isActive: boolean;
38
+ createdAt: Date;
39
+ updatedAt: Date;
40
+ refreshTokens: RefreshToken[];
41
+ }
42
+
43
+ export { AUTHENTICATION_PATTERN, RefreshToken, User, UserRMQAdapter, UserTCPAdapter };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+
1
3
  declare const AUTHENTICATION_PATTERN: {
2
4
  handleValidateToken: string;
3
5
  handleLogin: string;
@@ -8,4 +10,34 @@ declare const AUTHENTICATION_PATTERN: {
8
10
  revokeSession: string;
9
11
  };
10
12
 
11
- export { AUTHENTICATION_PATTERN };
13
+ declare const UserTCPAdapter: () => MicroserviceOptions;
14
+
15
+ declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
16
+
17
+ declare class RefreshToken {
18
+ id: string;
19
+ userId: string;
20
+ tokenId: string;
21
+ deviceInfo: any;
22
+ isRevoked: boolean;
23
+ expiresAt: Date;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ user: User;
27
+ }
28
+
29
+ declare class User {
30
+ id: string;
31
+ username: string;
32
+ email: string;
33
+ password: string;
34
+ firstName: string;
35
+ lastName: string;
36
+ role: string;
37
+ isActive: boolean;
38
+ createdAt: Date;
39
+ updatedAt: Date;
40
+ refreshTokens: RefreshToken[];
41
+ }
42
+
43
+ export { AUTHENTICATION_PATTERN, RefreshToken, User, UserRMQAdapter, UserTCPAdapter };
package/dist/index.js CHANGED
@@ -15,11 +15,23 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __decorateClass = (decorators, target, key, kind) => {
19
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
+ if (decorator = decorators[i])
22
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
+ if (kind && result) __defProp(target, key, result);
24
+ return result;
25
+ };
18
26
 
19
27
  // src/index.ts
20
28
  var index_exports = {};
21
29
  __export(index_exports, {
22
- AUTHENTICATION_PATTERN: () => AUTHENTICATION_PATTERN
30
+ AUTHENTICATION_PATTERN: () => AUTHENTICATION_PATTERN,
31
+ RefreshToken: () => RefreshToken,
32
+ User: () => User,
33
+ UserRMQAdapter: () => UserRMQAdapter,
34
+ UserTCPAdapter: () => UserTCPAdapter
23
35
  });
24
36
  module.exports = __toCommonJS(index_exports);
25
37
 
@@ -33,7 +45,162 @@ var AUTHENTICATION_PATTERN = {
33
45
  fetchSessions: "fetch.sessions",
34
46
  revokeSession: "revoke.session"
35
47
  };
48
+
49
+ // src/adapters/tcp/user.tcp.adapter.ts
50
+ var import_dotenv = require("dotenv");
51
+ var import_microservices = require("@nestjs/microservices");
52
+ (0, import_dotenv.config)();
53
+ var UserTCPAdapter = () => {
54
+ return {
55
+ name: "USER_MICROSERVICE",
56
+ transport: import_microservices.Transport.TCP,
57
+ options: {
58
+ host: process.env.USER_MICROSERVICE_TCP_HOST || "localhost",
59
+ port: parseInt(process.env.USER_MICROSERVICE_TCP_PORT || "4001", 10)
60
+ }
61
+ };
62
+ };
63
+
64
+ // src/adapters/rmq/user.rmq.adapter.ts
65
+ var import_dotenv2 = require("dotenv");
66
+ var import_microservices2 = require("@nestjs/microservices");
67
+ (0, import_dotenv2.config)();
68
+ var UserRMQAdapter = (mode = "microservice") => {
69
+ const urls = process.env.USER_MICROSERVICE_RMQ_URL?.split(",") || [
70
+ "amqp://localhost:5672"
71
+ ];
72
+ const queue = process.env.USER_MICROSERVICE_RMQ_QUEUE || "user_queue";
73
+ const prefetchCount = parseInt(
74
+ process.env.USER_MICROSERVICE_RMQ_PREFETCH_COUNT || "10"
75
+ );
76
+ const heartbeat = parseInt(
77
+ process.env.USER_MICROSERVICE_RMQ_HEARTBEAT || "60"
78
+ );
79
+ const deadLetterExchange = process.env.USER_MICROSERVICE_RMQ_DLX || "user_dlx";
80
+ const deadLetterQueue = process.env.USER_MICROSERVICE_RMQ_DLQ || "user_dlq";
81
+ const messageTtl = parseInt(
82
+ process.env.USER_MICROSERVICE_RMQ_MESSAGE_TTL || "30000"
83
+ );
84
+ const config3 = {
85
+ name: "USER_MICROSERVICE",
86
+ transport: import_microservices2.Transport.RMQ,
87
+ options: {
88
+ urls,
89
+ queue,
90
+ prefetchCount,
91
+ heartbeat,
92
+ queueOptions: {
93
+ durable: true,
94
+ arguments: {
95
+ "x-dead-letter-exchange": deadLetterExchange,
96
+ "x-dead-letter-routing-key": deadLetterQueue,
97
+ "x-message-ttl": messageTtl
98
+ }
99
+ },
100
+ connectionOptions: {
101
+ heartbeat,
102
+ retry: true,
103
+ retryAttempts: 5,
104
+ retryDelay: 3e3,
105
+ timeout: 1e4,
106
+ poolSize: parseInt(process.env.MICROSERVICE_RMQ_POOL_SIZE || "5"),
107
+ ...process.env.USER_MICROSERVICE_RMQ_USE_SSL === "true" && {
108
+ ssl: {
109
+ rejectUnauthorized: false
110
+ }
111
+ }
112
+ }
113
+ }
114
+ };
115
+ if (mode === "microservice") {
116
+ config3["options"]["noAck"] = false;
117
+ }
118
+ return config3;
119
+ };
120
+
121
+ // src/entities/user.entity.ts
122
+ var import_typeorm2 = require("typeorm");
123
+
124
+ // src/entities/refresh-token.entity.ts
125
+ var import_typeorm = require("typeorm");
126
+ var RefreshToken = class {
127
+ };
128
+ __decorateClass([
129
+ (0, import_typeorm.PrimaryGeneratedColumn)("uuid")
130
+ ], RefreshToken.prototype, "id", 2);
131
+ __decorateClass([
132
+ (0, import_typeorm.Column)({ name: "user_id" })
133
+ ], RefreshToken.prototype, "userId", 2);
134
+ __decorateClass([
135
+ (0, import_typeorm.Column)({ name: "token_id" })
136
+ ], RefreshToken.prototype, "tokenId", 2);
137
+ __decorateClass([
138
+ (0, import_typeorm.Column)({ name: "device_info", type: "json", nullable: true })
139
+ ], RefreshToken.prototype, "deviceInfo", 2);
140
+ __decorateClass([
141
+ (0, import_typeorm.Column)({ name: "is_revoked", default: false })
142
+ ], RefreshToken.prototype, "isRevoked", 2);
143
+ __decorateClass([
144
+ (0, import_typeorm.Column)({ name: "expires_at" })
145
+ ], RefreshToken.prototype, "expiresAt", 2);
146
+ __decorateClass([
147
+ (0, import_typeorm.CreateDateColumn)({ name: "created_at" })
148
+ ], RefreshToken.prototype, "createdAt", 2);
149
+ __decorateClass([
150
+ (0, import_typeorm.UpdateDateColumn)({ name: "updated_at" })
151
+ ], RefreshToken.prototype, "updatedAt", 2);
152
+ __decorateClass([
153
+ (0, import_typeorm.ManyToOne)(() => User, (user) => user.refreshTokens),
154
+ (0, import_typeorm.JoinColumn)({ name: "user_id" })
155
+ ], RefreshToken.prototype, "user", 2);
156
+ RefreshToken = __decorateClass([
157
+ (0, import_typeorm.Entity)("refresh_tokens")
158
+ ], RefreshToken);
159
+
160
+ // src/entities/user.entity.ts
161
+ var User = class {
162
+ };
163
+ __decorateClass([
164
+ (0, import_typeorm2.PrimaryGeneratedColumn)("uuid")
165
+ ], User.prototype, "id", 2);
166
+ __decorateClass([
167
+ (0, import_typeorm2.Column)({ unique: true })
168
+ ], User.prototype, "username", 2);
169
+ __decorateClass([
170
+ (0, import_typeorm2.Column)({ unique: true })
171
+ ], User.prototype, "email", 2);
172
+ __decorateClass([
173
+ (0, import_typeorm2.Column)()
174
+ ], User.prototype, "password", 2);
175
+ __decorateClass([
176
+ (0, import_typeorm2.Column)({ name: "first_name", nullable: true })
177
+ ], User.prototype, "firstName", 2);
178
+ __decorateClass([
179
+ (0, import_typeorm2.Column)({ name: "last_name", nullable: true })
180
+ ], User.prototype, "lastName", 2);
181
+ __decorateClass([
182
+ (0, import_typeorm2.Column)({ default: "user" })
183
+ ], User.prototype, "role", 2);
184
+ __decorateClass([
185
+ (0, import_typeorm2.Column)({ name: "is_active", default: true })
186
+ ], User.prototype, "isActive", 2);
187
+ __decorateClass([
188
+ (0, import_typeorm2.CreateDateColumn)({ name: "created_at" })
189
+ ], User.prototype, "createdAt", 2);
190
+ __decorateClass([
191
+ (0, import_typeorm2.UpdateDateColumn)({ name: "updated_at" })
192
+ ], User.prototype, "updatedAt", 2);
193
+ __decorateClass([
194
+ (0, import_typeorm2.OneToMany)(() => RefreshToken, (token) => token.user)
195
+ ], User.prototype, "refreshTokens", 2);
196
+ User = __decorateClass([
197
+ (0, import_typeorm2.Entity)("users")
198
+ ], User);
36
199
  // Annotate the CommonJS export names for ESM import in node:
37
200
  0 && (module.exports = {
38
- AUTHENTICATION_PATTERN
201
+ AUTHENTICATION_PATTERN,
202
+ RefreshToken,
203
+ User,
204
+ UserRMQAdapter,
205
+ UserTCPAdapter
39
206
  });
package/dist/index.mjs CHANGED
@@ -1,3 +1,14 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
1
12
  // src/modules/authentication/pattern/pattern.ts
2
13
  var AUTHENTICATION_PATTERN = {
3
14
  handleValidateToken: "handle.validate.token",
@@ -8,6 +19,161 @@ var AUTHENTICATION_PATTERN = {
8
19
  fetchSessions: "fetch.sessions",
9
20
  revokeSession: "revoke.session"
10
21
  };
22
+
23
+ // src/adapters/tcp/user.tcp.adapter.ts
24
+ import { config } from "dotenv";
25
+ import { Transport } from "@nestjs/microservices";
26
+ config();
27
+ var UserTCPAdapter = () => {
28
+ return {
29
+ name: "USER_MICROSERVICE",
30
+ transport: Transport.TCP,
31
+ options: {
32
+ host: process.env.USER_MICROSERVICE_TCP_HOST || "localhost",
33
+ port: parseInt(process.env.USER_MICROSERVICE_TCP_PORT || "4001", 10)
34
+ }
35
+ };
36
+ };
37
+
38
+ // src/adapters/rmq/user.rmq.adapter.ts
39
+ import { config as config2 } from "dotenv";
40
+ import { Transport as Transport2 } from "@nestjs/microservices";
41
+ config2();
42
+ var UserRMQAdapter = (mode = "microservice") => {
43
+ const urls = process.env.USER_MICROSERVICE_RMQ_URL?.split(",") || [
44
+ "amqp://localhost:5672"
45
+ ];
46
+ const queue = process.env.USER_MICROSERVICE_RMQ_QUEUE || "user_queue";
47
+ const prefetchCount = parseInt(
48
+ process.env.USER_MICROSERVICE_RMQ_PREFETCH_COUNT || "10"
49
+ );
50
+ const heartbeat = parseInt(
51
+ process.env.USER_MICROSERVICE_RMQ_HEARTBEAT || "60"
52
+ );
53
+ const deadLetterExchange = process.env.USER_MICROSERVICE_RMQ_DLX || "user_dlx";
54
+ const deadLetterQueue = process.env.USER_MICROSERVICE_RMQ_DLQ || "user_dlq";
55
+ const messageTtl = parseInt(
56
+ process.env.USER_MICROSERVICE_RMQ_MESSAGE_TTL || "30000"
57
+ );
58
+ const config3 = {
59
+ name: "USER_MICROSERVICE",
60
+ transport: Transport2.RMQ,
61
+ options: {
62
+ urls,
63
+ queue,
64
+ prefetchCount,
65
+ heartbeat,
66
+ queueOptions: {
67
+ durable: true,
68
+ arguments: {
69
+ "x-dead-letter-exchange": deadLetterExchange,
70
+ "x-dead-letter-routing-key": deadLetterQueue,
71
+ "x-message-ttl": messageTtl
72
+ }
73
+ },
74
+ connectionOptions: {
75
+ heartbeat,
76
+ retry: true,
77
+ retryAttempts: 5,
78
+ retryDelay: 3e3,
79
+ timeout: 1e4,
80
+ poolSize: parseInt(process.env.MICROSERVICE_RMQ_POOL_SIZE || "5"),
81
+ ...process.env.USER_MICROSERVICE_RMQ_USE_SSL === "true" && {
82
+ ssl: {
83
+ rejectUnauthorized: false
84
+ }
85
+ }
86
+ }
87
+ }
88
+ };
89
+ if (mode === "microservice") {
90
+ config3["options"]["noAck"] = false;
91
+ }
92
+ return config3;
93
+ };
94
+
95
+ // src/entities/user.entity.ts
96
+ import { Entity as Entity2, PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column2, CreateDateColumn as CreateDateColumn2, UpdateDateColumn as UpdateDateColumn2, OneToMany } from "typeorm";
97
+
98
+ // src/entities/refresh-token.entity.ts
99
+ import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from "typeorm";
100
+ var RefreshToken = class {
101
+ };
102
+ __decorateClass([
103
+ PrimaryGeneratedColumn("uuid")
104
+ ], RefreshToken.prototype, "id", 2);
105
+ __decorateClass([
106
+ Column({ name: "user_id" })
107
+ ], RefreshToken.prototype, "userId", 2);
108
+ __decorateClass([
109
+ Column({ name: "token_id" })
110
+ ], RefreshToken.prototype, "tokenId", 2);
111
+ __decorateClass([
112
+ Column({ name: "device_info", type: "json", nullable: true })
113
+ ], RefreshToken.prototype, "deviceInfo", 2);
114
+ __decorateClass([
115
+ Column({ name: "is_revoked", default: false })
116
+ ], RefreshToken.prototype, "isRevoked", 2);
117
+ __decorateClass([
118
+ Column({ name: "expires_at" })
119
+ ], RefreshToken.prototype, "expiresAt", 2);
120
+ __decorateClass([
121
+ CreateDateColumn({ name: "created_at" })
122
+ ], RefreshToken.prototype, "createdAt", 2);
123
+ __decorateClass([
124
+ UpdateDateColumn({ name: "updated_at" })
125
+ ], RefreshToken.prototype, "updatedAt", 2);
126
+ __decorateClass([
127
+ ManyToOne(() => User, (user) => user.refreshTokens),
128
+ JoinColumn({ name: "user_id" })
129
+ ], RefreshToken.prototype, "user", 2);
130
+ RefreshToken = __decorateClass([
131
+ Entity("refresh_tokens")
132
+ ], RefreshToken);
133
+
134
+ // src/entities/user.entity.ts
135
+ var User = class {
136
+ };
137
+ __decorateClass([
138
+ PrimaryGeneratedColumn2("uuid")
139
+ ], User.prototype, "id", 2);
140
+ __decorateClass([
141
+ Column2({ unique: true })
142
+ ], User.prototype, "username", 2);
143
+ __decorateClass([
144
+ Column2({ unique: true })
145
+ ], User.prototype, "email", 2);
146
+ __decorateClass([
147
+ Column2()
148
+ ], User.prototype, "password", 2);
149
+ __decorateClass([
150
+ Column2({ name: "first_name", nullable: true })
151
+ ], User.prototype, "firstName", 2);
152
+ __decorateClass([
153
+ Column2({ name: "last_name", nullable: true })
154
+ ], User.prototype, "lastName", 2);
155
+ __decorateClass([
156
+ Column2({ default: "user" })
157
+ ], User.prototype, "role", 2);
158
+ __decorateClass([
159
+ Column2({ name: "is_active", default: true })
160
+ ], User.prototype, "isActive", 2);
161
+ __decorateClass([
162
+ CreateDateColumn2({ name: "created_at" })
163
+ ], User.prototype, "createdAt", 2);
164
+ __decorateClass([
165
+ UpdateDateColumn2({ name: "updated_at" })
166
+ ], User.prototype, "updatedAt", 2);
167
+ __decorateClass([
168
+ OneToMany(() => RefreshToken, (token) => token.user)
169
+ ], User.prototype, "refreshTokens", 2);
170
+ User = __decorateClass([
171
+ Entity2("users")
172
+ ], User);
11
173
  export {
12
- AUTHENTICATION_PATTERN
174
+ AUTHENTICATION_PATTERN,
175
+ RefreshToken,
176
+ User,
177
+ UserRMQAdapter,
178
+ UserTCPAdapter
13
179
  };
@@ -0,0 +1 @@
1
+ export * from './pattern/pattern';
@@ -0,0 +1,9 @@
1
+ export declare const AUTHENTICATION_PATTERN: {
2
+ handleValidateToken: string;
3
+ handleLogin: string;
4
+ handleRefreshToken: string;
5
+ handleLogout: string;
6
+ handleLogoutAll: string;
7
+ fetchSessions: string;
8
+ revokeSession: string;
9
+ };
@@ -0,0 +1 @@
1
+ export * from './authentication';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experts_hub/shared",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "Shared DTOs, interfaces, and utilities for experts hub applications",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -51,6 +51,8 @@
51
51
  "dependencies": {
52
52
  "@nestjs/microservices": "^11.0.19",
53
53
  "@nestjs/swagger": "^11.1.2",
54
- "dotenv": "^16.5.0"
54
+ "@nestjs/typeorm": "^11.0.0",
55
+ "dotenv": "^16.5.0",
56
+ "typeorm": "^0.3.22"
55
57
  }
56
58
  }