@estopia/shared 1.0.0 → 1.0.2
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/broker/eventTypes.d.ts +27 -0
- package/dist/broker/eventTypes.d.ts.map +1 -0
- package/dist/broker/eventTypes.js +9 -0
- package/dist/broker/eventTypes.js.map +1 -0
- package/dist/broker/publisher.d.ts +16 -0
- package/dist/broker/publisher.d.ts.map +1 -0
- package/dist/broker/publisher.js +124 -0
- package/dist/broker/publisher.js.map +1 -0
- package/dist/broker/subscriber.d.ts +14 -0
- package/dist/broker/subscriber.d.ts.map +1 -0
- package/dist/broker/subscriber.js +60 -0
- package/dist/broker/subscriber.js.map +1 -0
- package/dist/database/cockroach.d.ts +11 -0
- package/dist/database/cockroach.d.ts.map +1 -0
- package/dist/database/cockroach.js +27 -0
- package/dist/database/cockroach.js.map +1 -0
- package/dist/database/dataTypes.d.ts +99 -0
- package/dist/database/dataTypes.d.ts.map +1 -0
- package/dist/database/dataTypes.js +7 -0
- package/dist/database/dataTypes.js.map +1 -0
- package/{src/database/types.ts → dist/database/types.d.ts} +8 -9
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +3 -0
- package/dist/database/types.js.map +1 -0
- package/dist/helpers/middlware/auth.d.ts +10 -0
- package/dist/helpers/middlware/auth.d.ts.map +1 -0
- package/dist/helpers/middlware/auth.js +55 -0
- package/dist/helpers/middlware/auth.js.map +1 -0
- package/dist/helpers/middlware/secure.d.ts +11 -0
- package/dist/helpers/middlware/secure.d.ts.map +1 -0
- package/dist/helpers/middlware/secure.js +42 -0
- package/dist/helpers/middlware/secure.js.map +1 -0
- package/dist/helpers/validateJWTToken.d.ts +16 -0
- package/dist/helpers/validateJWTToken.d.ts.map +1 -0
- package/dist/helpers/validateJWTToken.js +36 -0
- package/dist/helpers/validateJWTToken.js.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +16 -24
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +13 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +81 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/types/ENUMS.d.ts +32 -0
- package/dist/types/ENUMS.d.ts.map +1 -0
- package/dist/types/ENUMS.js +41 -0
- package/dist/types/ENUMS.js.map +1 -0
- package/dist/types/directs.d.ts +16 -0
- package/dist/types/directs.d.ts.map +1 -0
- package/dist/types/directs.js +3 -0
- package/dist/types/directs.js.map +1 -0
- package/dist/types/medical.d.ts +32 -0
- package/dist/types/medical.d.ts.map +1 -0
- package/dist/types/medical.js +3 -0
- package/dist/types/medical.js.map +1 -0
- package/dist/types/messages.d.ts +24 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +3 -0
- package/dist/types/messages.js.map +1 -0
- package/{src/types/request.ts → dist/types/request.d.ts} +22 -23
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +3 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/servers.d.ts +32 -0
- package/dist/types/servers.d.ts.map +1 -0
- package/dist/types/servers.js +3 -0
- package/dist/types/servers.js.map +1 -0
- package/dist/types/servicePayloads.d.ts +32 -0
- package/dist/types/servicePayloads.d.ts.map +1 -0
- package/dist/types/servicePayloads.js +10 -0
- package/dist/types/servicePayloads.js.map +1 -0
- package/dist/types/ticketsAndReporting.d.ts +29 -0
- package/dist/types/ticketsAndReporting.d.ts.map +1 -0
- package/dist/types/ticketsAndReporting.js +3 -0
- package/dist/types/ticketsAndReporting.js.map +1 -0
- package/dist/types/user.d.ts +29 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +3 -0
- package/dist/types/user.js.map +1 -0
- package/package.json +10 -4
- package/.github/workflows/tests.yml +0 -29
- package/scripts/migrations/1670000000000-initial.js +0 -107
- package/scripts/package.json +0 -20
- package/src/broker/eventTypes.ts +0 -23
- package/src/broker/publisher.ts +0 -82
- package/src/broker/subscriber.ts +0 -51
- package/src/database/cockroach.ts +0 -27
- package/src/helpers/middlware/auth.ts +0 -55
- package/src/helpers/middlware/secure.ts +0 -48
- package/src/helpers/validateJWTToken.ts +0 -38
- package/src/logging/logger.ts +0 -103
- package/src/types/ENUMS.ts +0 -45
- package/src/types/directs.ts +0 -18
- package/src/types/medical.ts +0 -36
- package/src/types/messages.ts +0 -27
- package/src/types/servers.ts +0 -36
- package/src/types/servicePayloads.ts +0 -40
- package/src/types/ticketsAndReporting.ts +0 -32
- package/src/types/user.ts +0 -34
- package/tests/verifyJWTToken.test.ts +0 -27
- package/tsconfig.json +0 -48
- package/vitest.config.ts +0 -9
package/src/types/ENUMS.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Enums
|
|
2
|
-
enum UserRole {
|
|
3
|
-
Member = 'MEMBER',
|
|
4
|
-
Admin = 'ADMIN',
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
enum ReportStatus {
|
|
8
|
-
Open = 'OPEN',
|
|
9
|
-
Reviewed = 'REVIEWED',
|
|
10
|
-
Closed = 'CLOSED',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
enum ReportEntityType {
|
|
14
|
-
User = 'USER',
|
|
15
|
-
Server = 'SERVER',
|
|
16
|
-
Channel = 'CHANNEL',
|
|
17
|
-
Message = 'MESSAGE',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
enum TicketStatus {
|
|
21
|
-
Open = 'OPEN',
|
|
22
|
-
Assigned = 'ASSIGNED',
|
|
23
|
-
Closed = 'CLOSED',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
enum DoseStatus {
|
|
27
|
-
Taken = 'TAKEN',
|
|
28
|
-
Skipped = 'SKIPPED',
|
|
29
|
-
Pending = 'PENDING',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
enum messageType {
|
|
33
|
-
Channel = 'CHANNEL',
|
|
34
|
-
Direct = 'DIRECT',
|
|
35
|
-
Ticket = 'TICKET',
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
UserRole,
|
|
40
|
-
ReportStatus,
|
|
41
|
-
ReportEntityType,
|
|
42
|
-
TicketStatus,
|
|
43
|
-
DoseStatus,
|
|
44
|
-
messageType
|
|
45
|
-
};
|
package/src/types/directs.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { UserRole } from "./ENUMS.js";
|
|
2
|
-
|
|
3
|
-
// /directs
|
|
4
|
-
export interface DirectMessageDto {
|
|
5
|
-
id: string;
|
|
6
|
-
isGroup: boolean;
|
|
7
|
-
name: string;
|
|
8
|
-
creatorId: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface DirectMessageMemberDto {
|
|
12
|
-
id: string;
|
|
13
|
-
userId: number;
|
|
14
|
-
role: UserRole;
|
|
15
|
-
isApproved: boolean;
|
|
16
|
-
joinedAt: Date;
|
|
17
|
-
directId: number;
|
|
18
|
-
}
|
package/src/types/medical.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { DoseStatus } from "./ENUMS.js";
|
|
2
|
-
|
|
3
|
-
// /medical
|
|
4
|
-
export interface MedicationDto {
|
|
5
|
-
id: string;
|
|
6
|
-
userId: number;
|
|
7
|
-
name: string;
|
|
8
|
-
dosage: string;
|
|
9
|
-
startDate: Date;
|
|
10
|
-
endDate?: Date;
|
|
11
|
-
notes?: string;
|
|
12
|
-
quantity?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface MedicationRefillDto {
|
|
16
|
-
id: string;
|
|
17
|
-
medicationId: number;
|
|
18
|
-
amount: number;
|
|
19
|
-
date: Date;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface MedicationTimeDto {
|
|
23
|
-
id: string;
|
|
24
|
-
medicationId: number;
|
|
25
|
-
time: string; // e.g., "08:00"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface TakenDoseDto {
|
|
29
|
-
id: string;
|
|
30
|
-
userId: number;
|
|
31
|
-
medId: number;
|
|
32
|
-
scheduledTime: Date;
|
|
33
|
-
takenTime?: Date;
|
|
34
|
-
dosage: string;
|
|
35
|
-
status: DoseStatus;
|
|
36
|
-
}
|
package/src/types/messages.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { messageType } from "./ENUMS.js";
|
|
2
|
-
|
|
3
|
-
// /messages
|
|
4
|
-
export interface MessageDto {
|
|
5
|
-
id: string;
|
|
6
|
-
type: messageType;
|
|
7
|
-
directId?: number;
|
|
8
|
-
channelId?: number;
|
|
9
|
-
ticketId?: number;
|
|
10
|
-
userId: number;
|
|
11
|
-
content: string;
|
|
12
|
-
mentionEveryone: boolean;
|
|
13
|
-
replyTo?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface MessageMediaDto {
|
|
17
|
-
id: string;
|
|
18
|
-
type: string; // e.g., "image/png"
|
|
19
|
-
size: number;
|
|
20
|
-
messageId: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface MessageMentionDto {
|
|
24
|
-
id: string;
|
|
25
|
-
userId: number;
|
|
26
|
-
messageId: number;
|
|
27
|
-
}
|
package/src/types/servers.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { UserRole } from "./ENUMS.js";
|
|
2
|
-
|
|
3
|
-
// /servers
|
|
4
|
-
export interface ServerDto {
|
|
5
|
-
id: string;
|
|
6
|
-
ownerId: number;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
isPrivate: boolean;
|
|
10
|
-
isVerified: boolean;
|
|
11
|
-
icon: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ServerMemberDto {
|
|
15
|
-
id: string;
|
|
16
|
-
userId: number;
|
|
17
|
-
serverId: number;
|
|
18
|
-
role: UserRole;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ChannelDto {
|
|
22
|
-
id: string;
|
|
23
|
-
serverId: number;
|
|
24
|
-
name: string;
|
|
25
|
-
channelType: string;
|
|
26
|
-
isStaffViewOnly: boolean;
|
|
27
|
-
isStaffTextOnly: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ServerBanDto {
|
|
31
|
-
id: string;
|
|
32
|
-
banningId: number;
|
|
33
|
-
bannedId: number;
|
|
34
|
-
note: string;
|
|
35
|
-
serverId: number;
|
|
36
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export interface SendPushNotificationRequest {
|
|
2
|
-
userId: string;
|
|
3
|
-
title: string;
|
|
4
|
-
body: string;
|
|
5
|
-
appType: 'medical' | 'chat';
|
|
6
|
-
// Optional data to send with the notification,
|
|
7
|
-
// e.g., { channelId: 123 }
|
|
8
|
-
data?: Record<string, any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum EmailTemplate {
|
|
12
|
-
AccountVerification = 'ACCOUNT_VERIFICATION',
|
|
13
|
-
PasswordReset = 'PASSWORD_RESET',
|
|
14
|
-
FactorVerifcation = 'FACTOR_VERIFICATION',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SendEmailRequest {
|
|
18
|
-
to: string; // The recipient's email address
|
|
19
|
-
template: EmailTemplate;
|
|
20
|
-
// Dynamic data for the template, e.g., { verificationLink: '...' }
|
|
21
|
-
context: Record<string, any>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface RequestUploadUrlRequest {
|
|
25
|
-
// e.g., 'image/png' or 'video/mp4'
|
|
26
|
-
mimeType: string;
|
|
27
|
-
// Where the file will be used
|
|
28
|
-
context: 'profile-icon' | 'chat-attachment' | 'server-icon';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface RequestUploadUrlResponse {
|
|
32
|
-
/**
|
|
33
|
-
* The secure, pre-signed URL where the client should upload the file.
|
|
34
|
-
*/
|
|
35
|
-
uploadUrl: string;
|
|
36
|
-
/**
|
|
37
|
-
* The final URL to access the file after the upload is complete.
|
|
38
|
-
*/
|
|
39
|
-
accessUrl: string;
|
|
40
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ReportEntityType, ReportStatus, TicketStatus } from "./ENUMS.js";
|
|
2
|
-
|
|
3
|
-
// /tickets & /reports
|
|
4
|
-
export interface TicketDto {
|
|
5
|
-
id: string;
|
|
6
|
-
discordId?: number;
|
|
7
|
-
status: TicketStatus;
|
|
8
|
-
title: string;
|
|
9
|
-
assignedTo?: number;
|
|
10
|
-
assignedBy?: number;
|
|
11
|
-
closedBy?: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface TicketMessageDto {
|
|
15
|
-
id: string;
|
|
16
|
-
userId: number;
|
|
17
|
-
ticketId: number;
|
|
18
|
-
message: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ReportDto {
|
|
22
|
-
id: string;
|
|
23
|
-
reporterId: number;
|
|
24
|
-
entityType: ReportEntityType;
|
|
25
|
-
entityId: number;
|
|
26
|
-
reason: string; // ENUM
|
|
27
|
-
description: string;
|
|
28
|
-
status: ReportStatus;
|
|
29
|
-
reviewedBy?: number;
|
|
30
|
-
reviewedAt?: Date;
|
|
31
|
-
reportedAt: Date;
|
|
32
|
-
}
|
package/src/types/user.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// /user
|
|
2
|
-
export interface UserDto {
|
|
3
|
-
id: string;
|
|
4
|
-
username: string;
|
|
5
|
-
password: string | null;
|
|
6
|
-
icon: string;
|
|
7
|
-
isAdmin: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface PasskeyDto {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
transports: number;
|
|
14
|
-
// Note: keyid, publicKey, and counter are omitted for security.
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AuthAppDto {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
// Note: secret is omitted for security.
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface NotificationSettingsDto {
|
|
24
|
-
id: string;
|
|
25
|
-
userId: number;
|
|
26
|
-
directMessage: boolean;
|
|
27
|
-
groupDMMessage: boolean;
|
|
28
|
-
groupDMMention: boolean;
|
|
29
|
-
addedToDM: boolean;
|
|
30
|
-
serverEveryoneMention: boolean;
|
|
31
|
-
serverMention: boolean;
|
|
32
|
-
serverReply: boolean;
|
|
33
|
-
directCall: boolean;
|
|
34
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import jwt from 'jsonwebtoken';
|
|
3
|
-
import { validateJWTToken, tryValidateJWTToken } from '../src/helpers/validateJWTToken';
|
|
4
|
-
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
vi.restoreAllMocks();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
describe('verifyJWTToken helper', () => {
|
|
10
|
-
it('verifies a valid token and returns payload', () => {
|
|
11
|
-
process.env.JWT_SECRET = 'test_jwt_secret';
|
|
12
|
-
const token = jwt.sign({ sub: 'user-1' }, process.env.JWT_SECRET!, { issuer: 'estopia-auth' });
|
|
13
|
-
const decoded = validateJWTToken(token);
|
|
14
|
-
expect(decoded).toHaveProperty('userId', 'user-1');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('tryValidateJWTToken returns null for invalid token', () => {
|
|
18
|
-
process.env.JWT_SECRET = 'test_jwt_secret';
|
|
19
|
-
const decoded = tryValidateJWTToken('not-a-token');
|
|
20
|
-
expect(decoded).toBeNull();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('validateJWTToken throws when secret not configured', () => {
|
|
24
|
-
delete process.env.JWT_SECRET;
|
|
25
|
-
expect(() => validateJWTToken('anything')).toThrow(/JWT secret not configured/);
|
|
26
|
-
});
|
|
27
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
// File Layout
|
|
5
|
-
// "rootDir": "./src",
|
|
6
|
-
// "outDir": "./dist",
|
|
7
|
-
|
|
8
|
-
// Environment Settings
|
|
9
|
-
// See also https://aka.ms/tsconfig/module
|
|
10
|
-
"module": "nodenext",
|
|
11
|
-
"target": "esnext",
|
|
12
|
-
"types": [
|
|
13
|
-
"node"
|
|
14
|
-
],
|
|
15
|
-
// For nodejs:
|
|
16
|
-
// "lib": ["esnext"],
|
|
17
|
-
// "types": ["node"],
|
|
18
|
-
// and npm install -D @types/node
|
|
19
|
-
|
|
20
|
-
// Other Outputs
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"declaration": true,
|
|
23
|
-
"declarationMap": true,
|
|
24
|
-
|
|
25
|
-
// Stricter Typechecking Options
|
|
26
|
-
"noUncheckedIndexedAccess": true,
|
|
27
|
-
"exactOptionalPropertyTypes": true,
|
|
28
|
-
|
|
29
|
-
// Style Options
|
|
30
|
-
// "noImplicitReturns": true,
|
|
31
|
-
// "noImplicitOverride": true,
|
|
32
|
-
// "noUnusedLocals": true,
|
|
33
|
-
// "noUnusedParameters": true,
|
|
34
|
-
// "noFallthroughCasesInSwitch": true,
|
|
35
|
-
// "noPropertyAccessFromIndexSignature": true,
|
|
36
|
-
|
|
37
|
-
// Recommended Options
|
|
38
|
-
"strict": true,
|
|
39
|
-
"jsx": "react-jsx",
|
|
40
|
-
"verbatimModuleSyntax": false,
|
|
41
|
-
"isolatedModules": true,
|
|
42
|
-
"noUncheckedSideEffectImports": true,
|
|
43
|
-
"moduleDetection": "force",
|
|
44
|
-
"skipLibCheck": true,
|
|
45
|
-
"allowImportingTsExtensions": true,
|
|
46
|
-
"noEmit": true
|
|
47
|
-
}
|
|
48
|
-
}
|