sockr-shared 1.0.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/README.md +144 -0
- package/dist/index.d.mts +115 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# sockr-shared
|
|
2
|
+
|
|
3
|
+
Shared TypeScript type definitions for the [SOCKR](https://github.com/Dev-180Memes/sockr) WebSocket messaging framework. This package provides type-safe contracts used by both the server and client packages.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install sockr-shared
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package exports TypeScript interfaces, enums, and types that ensure consistent communication between SOCKR server and client implementations. It has **zero runtime dependencies** and ships with full TypeScript support (CommonJS, ES Modules, and `.d.ts` declarations).
|
|
14
|
+
|
|
15
|
+
## Exports
|
|
16
|
+
|
|
17
|
+
### Socket Events
|
|
18
|
+
|
|
19
|
+
The `SocketEvent` enum defines all events used in the messaging protocol:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { SocketEvent } from 'sockr-shared';
|
|
23
|
+
|
|
24
|
+
// Connection lifecycle
|
|
25
|
+
SocketEvent.CONNECT
|
|
26
|
+
SocketEvent.DISCONNECT
|
|
27
|
+
SocketEvent.ERROR
|
|
28
|
+
|
|
29
|
+
// Authentication
|
|
30
|
+
SocketEvent.AUTHENTICATE
|
|
31
|
+
SocketEvent.AUTHENTICATED
|
|
32
|
+
SocketEvent.AUTH_ERROR
|
|
33
|
+
|
|
34
|
+
// User presence
|
|
35
|
+
SocketEvent.USER_ONLINE
|
|
36
|
+
SocketEvent.USER_OFFLINE
|
|
37
|
+
SocketEvent.GET_ONLINE_STATUS
|
|
38
|
+
SocketEvent.ONLINE_STATUS
|
|
39
|
+
|
|
40
|
+
// Messaging
|
|
41
|
+
SocketEvent.SEND_MESSAGE
|
|
42
|
+
SocketEvent.RECEIVE_MESSAGE
|
|
43
|
+
SocketEvent.MESSAGE_DELIVERED
|
|
44
|
+
SocketEvent.MESSAGE_ERROR
|
|
45
|
+
|
|
46
|
+
// Typing indicators
|
|
47
|
+
SocketEvent.TYPING_START
|
|
48
|
+
SocketEvent.TYPING_STOP
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Event Payloads
|
|
52
|
+
|
|
53
|
+
The `EventPayloads` interface maps each event to its strictly-typed payload:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { EventPayloads, SocketEvent } from 'sockr-shared';
|
|
57
|
+
|
|
58
|
+
// Type-safe event handling
|
|
59
|
+
type AuthPayload = EventPayloads[SocketEvent.AUTHENTICATE];
|
|
60
|
+
// { token: string }
|
|
61
|
+
|
|
62
|
+
type MessagePayload = EventPayloads[SocketEvent.SEND_MESSAGE];
|
|
63
|
+
// { to: string; content: string; metadata?: Record<string, any> }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Message Types
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { Message, MessageOptions } from 'sockr-shared';
|
|
70
|
+
|
|
71
|
+
const message: Message = {
|
|
72
|
+
id: 'msg-1',
|
|
73
|
+
from: 'user-a',
|
|
74
|
+
to: 'user-b',
|
|
75
|
+
content: 'Hello!',
|
|
76
|
+
timestamp: Date.now(),
|
|
77
|
+
delivered: false,
|
|
78
|
+
metadata: { priority: 'high' },
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const options: MessageOptions = {
|
|
82
|
+
requireAcknowledgment: true,
|
|
83
|
+
timeout: 5000,
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### User Types
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { User, UserConnection } from 'sockr-shared';
|
|
91
|
+
|
|
92
|
+
const user: User = {
|
|
93
|
+
id: 'user-a',
|
|
94
|
+
socketId: 'socket-123',
|
|
95
|
+
connectedAt: Date.now(),
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const connection: UserConnection = {
|
|
99
|
+
userId: 'user-a',
|
|
100
|
+
socketId: 'socket-123',
|
|
101
|
+
isOnline: true,
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Configuration Types
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { ServerConfig, ClientConfig } from 'sockr-shared';
|
|
109
|
+
|
|
110
|
+
const serverConfig: ServerConfig = {
|
|
111
|
+
port: 3000,
|
|
112
|
+
cors: { origin: 'http://localhost:5173', credentials: true },
|
|
113
|
+
pingTimeout: 10000,
|
|
114
|
+
pingInterval: 25000,
|
|
115
|
+
transports: ['websocket', 'polling'],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const clientConfig: ClientConfig = {
|
|
119
|
+
url: 'http://localhost:3000',
|
|
120
|
+
autoConnect: true,
|
|
121
|
+
reconnection: true,
|
|
122
|
+
reconnectionAttempts: 5,
|
|
123
|
+
reconnectionDelay: 1000,
|
|
124
|
+
timeout: 10000,
|
|
125
|
+
transports: ['websocket'],
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Build the package
|
|
133
|
+
npm run build
|
|
134
|
+
|
|
135
|
+
# Watch mode
|
|
136
|
+
npm run dev
|
|
137
|
+
|
|
138
|
+
# Clean build artifacts
|
|
139
|
+
npm run clean
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
declare enum SocketEvent {
|
|
2
|
+
CONNECT = "connect",
|
|
3
|
+
DISCONNECT = "disconnect",
|
|
4
|
+
ERROR = "error",
|
|
5
|
+
AUTHENTICATE = "authenticate",
|
|
6
|
+
AUTHENTICATED = "authenticated",
|
|
7
|
+
AUTH_ERROR = "auth_error",
|
|
8
|
+
USER_ONLINE = "user_online",
|
|
9
|
+
USER_OFFLINE = "user_offline",
|
|
10
|
+
GET_ONLINE_STATUS = "get_online_status",
|
|
11
|
+
ONLINE_STATUS = "online_status",
|
|
12
|
+
SEND_MESSAGE = "send_message",
|
|
13
|
+
RECEIVE_MESSAGE = "receive_message",
|
|
14
|
+
MESSAGE_DELIVERED = "message_delivered",
|
|
15
|
+
MESSAGE_ERROR = "message_error",
|
|
16
|
+
TYPING_START = "typing_start",
|
|
17
|
+
TYPING_STOP = "typing_stop"
|
|
18
|
+
}
|
|
19
|
+
interface EventPayloads {
|
|
20
|
+
[SocketEvent.AUTHENTICATE]: {
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
[SocketEvent.AUTHENTICATED]: {
|
|
24
|
+
userId: string;
|
|
25
|
+
socketId: string;
|
|
26
|
+
};
|
|
27
|
+
[SocketEvent.AUTH_ERROR]: {
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
[SocketEvent.USER_ONLINE]: {
|
|
31
|
+
userId: string;
|
|
32
|
+
};
|
|
33
|
+
[SocketEvent.USER_OFFLINE]: {
|
|
34
|
+
userId: string;
|
|
35
|
+
};
|
|
36
|
+
[SocketEvent.GET_ONLINE_STATUS]: {
|
|
37
|
+
userIds: string[];
|
|
38
|
+
};
|
|
39
|
+
[SocketEvent.ONLINE_STATUS]: {
|
|
40
|
+
statuses: Record<string, boolean>;
|
|
41
|
+
};
|
|
42
|
+
[SocketEvent.SEND_MESSAGE]: {
|
|
43
|
+
to: string;
|
|
44
|
+
content: string;
|
|
45
|
+
metadata?: Record<string, any>;
|
|
46
|
+
};
|
|
47
|
+
[SocketEvent.RECEIVE_MESSAGE]: {
|
|
48
|
+
from: string;
|
|
49
|
+
content: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
messageId: string;
|
|
52
|
+
metadata?: Record<string, any>;
|
|
53
|
+
};
|
|
54
|
+
[SocketEvent.MESSAGE_DELIVERED]: {
|
|
55
|
+
messageId: string;
|
|
56
|
+
};
|
|
57
|
+
[SocketEvent.MESSAGE_ERROR]: {
|
|
58
|
+
messageId: string;
|
|
59
|
+
error: string;
|
|
60
|
+
};
|
|
61
|
+
[SocketEvent.TYPING_START]: {
|
|
62
|
+
from: string;
|
|
63
|
+
};
|
|
64
|
+
[SocketEvent.TYPING_STOP]: {
|
|
65
|
+
from: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ServerConfig {
|
|
70
|
+
port?: number;
|
|
71
|
+
cors?: {
|
|
72
|
+
origin: string | string[];
|
|
73
|
+
credentials?: boolean;
|
|
74
|
+
};
|
|
75
|
+
pingTimeout?: number;
|
|
76
|
+
pingInterval?: number;
|
|
77
|
+
transports?: ('websocket' | 'polling')[];
|
|
78
|
+
}
|
|
79
|
+
interface ClientConfig {
|
|
80
|
+
url: string;
|
|
81
|
+
autoConnect?: boolean;
|
|
82
|
+
reconnection?: boolean;
|
|
83
|
+
reconnectionAttempts?: number;
|
|
84
|
+
reconnectionDelay?: number;
|
|
85
|
+
timeout?: number;
|
|
86
|
+
transports?: ('websocket' | 'polling')[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Message {
|
|
90
|
+
id: string;
|
|
91
|
+
from: string;
|
|
92
|
+
to: string;
|
|
93
|
+
content: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
delivered: boolean;
|
|
96
|
+
metadata?: Record<string, any>;
|
|
97
|
+
}
|
|
98
|
+
interface MessageOptions {
|
|
99
|
+
requireAcknowledgment?: boolean;
|
|
100
|
+
timeout?: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface User {
|
|
104
|
+
id: string;
|
|
105
|
+
socketId: string;
|
|
106
|
+
connectedAt: number;
|
|
107
|
+
metadata?: Record<string, any>;
|
|
108
|
+
}
|
|
109
|
+
interface UserConnection {
|
|
110
|
+
userId: string;
|
|
111
|
+
socketId: string;
|
|
112
|
+
isOnline: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { type ClientConfig, type EventPayloads, type Message, type MessageOptions, type ServerConfig, SocketEvent, type User, type UserConnection };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
declare enum SocketEvent {
|
|
2
|
+
CONNECT = "connect",
|
|
3
|
+
DISCONNECT = "disconnect",
|
|
4
|
+
ERROR = "error",
|
|
5
|
+
AUTHENTICATE = "authenticate",
|
|
6
|
+
AUTHENTICATED = "authenticated",
|
|
7
|
+
AUTH_ERROR = "auth_error",
|
|
8
|
+
USER_ONLINE = "user_online",
|
|
9
|
+
USER_OFFLINE = "user_offline",
|
|
10
|
+
GET_ONLINE_STATUS = "get_online_status",
|
|
11
|
+
ONLINE_STATUS = "online_status",
|
|
12
|
+
SEND_MESSAGE = "send_message",
|
|
13
|
+
RECEIVE_MESSAGE = "receive_message",
|
|
14
|
+
MESSAGE_DELIVERED = "message_delivered",
|
|
15
|
+
MESSAGE_ERROR = "message_error",
|
|
16
|
+
TYPING_START = "typing_start",
|
|
17
|
+
TYPING_STOP = "typing_stop"
|
|
18
|
+
}
|
|
19
|
+
interface EventPayloads {
|
|
20
|
+
[SocketEvent.AUTHENTICATE]: {
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
[SocketEvent.AUTHENTICATED]: {
|
|
24
|
+
userId: string;
|
|
25
|
+
socketId: string;
|
|
26
|
+
};
|
|
27
|
+
[SocketEvent.AUTH_ERROR]: {
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
[SocketEvent.USER_ONLINE]: {
|
|
31
|
+
userId: string;
|
|
32
|
+
};
|
|
33
|
+
[SocketEvent.USER_OFFLINE]: {
|
|
34
|
+
userId: string;
|
|
35
|
+
};
|
|
36
|
+
[SocketEvent.GET_ONLINE_STATUS]: {
|
|
37
|
+
userIds: string[];
|
|
38
|
+
};
|
|
39
|
+
[SocketEvent.ONLINE_STATUS]: {
|
|
40
|
+
statuses: Record<string, boolean>;
|
|
41
|
+
};
|
|
42
|
+
[SocketEvent.SEND_MESSAGE]: {
|
|
43
|
+
to: string;
|
|
44
|
+
content: string;
|
|
45
|
+
metadata?: Record<string, any>;
|
|
46
|
+
};
|
|
47
|
+
[SocketEvent.RECEIVE_MESSAGE]: {
|
|
48
|
+
from: string;
|
|
49
|
+
content: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
messageId: string;
|
|
52
|
+
metadata?: Record<string, any>;
|
|
53
|
+
};
|
|
54
|
+
[SocketEvent.MESSAGE_DELIVERED]: {
|
|
55
|
+
messageId: string;
|
|
56
|
+
};
|
|
57
|
+
[SocketEvent.MESSAGE_ERROR]: {
|
|
58
|
+
messageId: string;
|
|
59
|
+
error: string;
|
|
60
|
+
};
|
|
61
|
+
[SocketEvent.TYPING_START]: {
|
|
62
|
+
from: string;
|
|
63
|
+
};
|
|
64
|
+
[SocketEvent.TYPING_STOP]: {
|
|
65
|
+
from: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ServerConfig {
|
|
70
|
+
port?: number;
|
|
71
|
+
cors?: {
|
|
72
|
+
origin: string | string[];
|
|
73
|
+
credentials?: boolean;
|
|
74
|
+
};
|
|
75
|
+
pingTimeout?: number;
|
|
76
|
+
pingInterval?: number;
|
|
77
|
+
transports?: ('websocket' | 'polling')[];
|
|
78
|
+
}
|
|
79
|
+
interface ClientConfig {
|
|
80
|
+
url: string;
|
|
81
|
+
autoConnect?: boolean;
|
|
82
|
+
reconnection?: boolean;
|
|
83
|
+
reconnectionAttempts?: number;
|
|
84
|
+
reconnectionDelay?: number;
|
|
85
|
+
timeout?: number;
|
|
86
|
+
transports?: ('websocket' | 'polling')[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Message {
|
|
90
|
+
id: string;
|
|
91
|
+
from: string;
|
|
92
|
+
to: string;
|
|
93
|
+
content: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
delivered: boolean;
|
|
96
|
+
metadata?: Record<string, any>;
|
|
97
|
+
}
|
|
98
|
+
interface MessageOptions {
|
|
99
|
+
requireAcknowledgment?: boolean;
|
|
100
|
+
timeout?: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface User {
|
|
104
|
+
id: string;
|
|
105
|
+
socketId: string;
|
|
106
|
+
connectedAt: number;
|
|
107
|
+
metadata?: Record<string, any>;
|
|
108
|
+
}
|
|
109
|
+
interface UserConnection {
|
|
110
|
+
userId: string;
|
|
111
|
+
socketId: string;
|
|
112
|
+
isOnline: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { type ClientConfig, type EventPayloads, type Message, type MessageOptions, type ServerConfig, SocketEvent, type User, type UserConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
SocketEvent: () => SocketEvent
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/types/events.ts
|
|
28
|
+
var SocketEvent = /* @__PURE__ */ ((SocketEvent2) => {
|
|
29
|
+
SocketEvent2["CONNECT"] = "connect";
|
|
30
|
+
SocketEvent2["DISCONNECT"] = "disconnect";
|
|
31
|
+
SocketEvent2["ERROR"] = "error";
|
|
32
|
+
SocketEvent2["AUTHENTICATE"] = "authenticate";
|
|
33
|
+
SocketEvent2["AUTHENTICATED"] = "authenticated";
|
|
34
|
+
SocketEvent2["AUTH_ERROR"] = "auth_error";
|
|
35
|
+
SocketEvent2["USER_ONLINE"] = "user_online";
|
|
36
|
+
SocketEvent2["USER_OFFLINE"] = "user_offline";
|
|
37
|
+
SocketEvent2["GET_ONLINE_STATUS"] = "get_online_status";
|
|
38
|
+
SocketEvent2["ONLINE_STATUS"] = "online_status";
|
|
39
|
+
SocketEvent2["SEND_MESSAGE"] = "send_message";
|
|
40
|
+
SocketEvent2["RECEIVE_MESSAGE"] = "receive_message";
|
|
41
|
+
SocketEvent2["MESSAGE_DELIVERED"] = "message_delivered";
|
|
42
|
+
SocketEvent2["MESSAGE_ERROR"] = "message_error";
|
|
43
|
+
SocketEvent2["TYPING_START"] = "typing_start";
|
|
44
|
+
SocketEvent2["TYPING_STOP"] = "typing_stop";
|
|
45
|
+
return SocketEvent2;
|
|
46
|
+
})(SocketEvent || {});
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
SocketEvent
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/events.ts"],"sourcesContent":["export * from './types/events';\nexport * from './types/config';\nexport * from './types/message';\nexport * from './types/user';","export enum SocketEvent {\n // Connection events\n CONNECT = 'connect',\n DISCONNECT = 'disconnect',\n ERROR = 'error',\n\n // Authentication\n AUTHENTICATE = 'authenticate',\n AUTHENTICATED = 'authenticated',\n AUTH_ERROR = 'auth_error',\n\n // Presence\n USER_ONLINE = 'user_online',\n USER_OFFLINE = 'user_offline',\n GET_ONLINE_STATUS = 'get_online_status',\n ONLINE_STATUS = 'online_status',\n\n // Messaging\n SEND_MESSAGE = 'send_message',\n RECEIVE_MESSAGE = 'receive_message',\n MESSAGE_DELIVERED = 'message_delivered',\n MESSAGE_ERROR = 'message_error',\n TYPING_START = 'typing_start',\n TYPING_STOP = 'typing_stop',\n}\n\nexport interface EventPayloads {\n [SocketEvent.AUTHENTICATE]: {\n token: string;\n };\n\n [SocketEvent.AUTHENTICATED]: {\n userId: string;\n socketId: string;\n };\n\n [SocketEvent.AUTH_ERROR]: {\n message: string;\n };\n\n [SocketEvent.USER_ONLINE]: {\n userId: string;\n };\n\n [SocketEvent.USER_OFFLINE]: {\n userId: string;\n };\n\n [SocketEvent.GET_ONLINE_STATUS]: {\n userIds: string[];\n };\n\n [SocketEvent.ONLINE_STATUS]: {\n statuses: Record<string, boolean>;\n };\n\n [SocketEvent.SEND_MESSAGE]: {\n to: string;\n content: string;\n metadata?: Record<string, any>;\n };\n\n [SocketEvent.RECEIVE_MESSAGE]: {\n from: string;\n content: string;\n timestamp: number;\n messageId: string;\n metadata?: Record<string, any>;\n };\n\n [SocketEvent.MESSAGE_DELIVERED]: {\n messageId: string;\n };\n\n [SocketEvent.MESSAGE_ERROR]: {\n messageId: string;\n error: string;\n };\n\n [SocketEvent.TYPING_START]: {\n from: string;\n };\n\n [SocketEvent.TYPING_STOP]: {\n from: string;\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAK,cAAL,kBAAKA,iBAAL;AAEL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,WAAQ;AAGR,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,mBAAgB;AAChB,EAAAA,aAAA,gBAAa;AAGb,EAAAA,aAAA,iBAAc;AACd,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,uBAAoB;AACpB,EAAAA,aAAA,mBAAgB;AAGhB,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,qBAAkB;AAClB,EAAAA,aAAA,uBAAoB;AACpB,EAAAA,aAAA,mBAAgB;AAChB,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,iBAAc;AAvBJ,SAAAA;AAAA,GAAA;","names":["SocketEvent"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/types/events.ts
|
|
2
|
+
var SocketEvent = /* @__PURE__ */ ((SocketEvent2) => {
|
|
3
|
+
SocketEvent2["CONNECT"] = "connect";
|
|
4
|
+
SocketEvent2["DISCONNECT"] = "disconnect";
|
|
5
|
+
SocketEvent2["ERROR"] = "error";
|
|
6
|
+
SocketEvent2["AUTHENTICATE"] = "authenticate";
|
|
7
|
+
SocketEvent2["AUTHENTICATED"] = "authenticated";
|
|
8
|
+
SocketEvent2["AUTH_ERROR"] = "auth_error";
|
|
9
|
+
SocketEvent2["USER_ONLINE"] = "user_online";
|
|
10
|
+
SocketEvent2["USER_OFFLINE"] = "user_offline";
|
|
11
|
+
SocketEvent2["GET_ONLINE_STATUS"] = "get_online_status";
|
|
12
|
+
SocketEvent2["ONLINE_STATUS"] = "online_status";
|
|
13
|
+
SocketEvent2["SEND_MESSAGE"] = "send_message";
|
|
14
|
+
SocketEvent2["RECEIVE_MESSAGE"] = "receive_message";
|
|
15
|
+
SocketEvent2["MESSAGE_DELIVERED"] = "message_delivered";
|
|
16
|
+
SocketEvent2["MESSAGE_ERROR"] = "message_error";
|
|
17
|
+
SocketEvent2["TYPING_START"] = "typing_start";
|
|
18
|
+
SocketEvent2["TYPING_STOP"] = "typing_stop";
|
|
19
|
+
return SocketEvent2;
|
|
20
|
+
})(SocketEvent || {});
|
|
21
|
+
export {
|
|
22
|
+
SocketEvent
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/events.ts"],"sourcesContent":["export enum SocketEvent {\n // Connection events\n CONNECT = 'connect',\n DISCONNECT = 'disconnect',\n ERROR = 'error',\n\n // Authentication\n AUTHENTICATE = 'authenticate',\n AUTHENTICATED = 'authenticated',\n AUTH_ERROR = 'auth_error',\n\n // Presence\n USER_ONLINE = 'user_online',\n USER_OFFLINE = 'user_offline',\n GET_ONLINE_STATUS = 'get_online_status',\n ONLINE_STATUS = 'online_status',\n\n // Messaging\n SEND_MESSAGE = 'send_message',\n RECEIVE_MESSAGE = 'receive_message',\n MESSAGE_DELIVERED = 'message_delivered',\n MESSAGE_ERROR = 'message_error',\n TYPING_START = 'typing_start',\n TYPING_STOP = 'typing_stop',\n}\n\nexport interface EventPayloads {\n [SocketEvent.AUTHENTICATE]: {\n token: string;\n };\n\n [SocketEvent.AUTHENTICATED]: {\n userId: string;\n socketId: string;\n };\n\n [SocketEvent.AUTH_ERROR]: {\n message: string;\n };\n\n [SocketEvent.USER_ONLINE]: {\n userId: string;\n };\n\n [SocketEvent.USER_OFFLINE]: {\n userId: string;\n };\n\n [SocketEvent.GET_ONLINE_STATUS]: {\n userIds: string[];\n };\n\n [SocketEvent.ONLINE_STATUS]: {\n statuses: Record<string, boolean>;\n };\n\n [SocketEvent.SEND_MESSAGE]: {\n to: string;\n content: string;\n metadata?: Record<string, any>;\n };\n\n [SocketEvent.RECEIVE_MESSAGE]: {\n from: string;\n content: string;\n timestamp: number;\n messageId: string;\n metadata?: Record<string, any>;\n };\n\n [SocketEvent.MESSAGE_DELIVERED]: {\n messageId: string;\n };\n\n [SocketEvent.MESSAGE_ERROR]: {\n messageId: string;\n error: string;\n };\n\n [SocketEvent.TYPING_START]: {\n from: string;\n };\n\n [SocketEvent.TYPING_STOP]: {\n from: string;\n };\n}"],"mappings":";AAAO,IAAK,cAAL,kBAAKA,iBAAL;AAEL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,WAAQ;AAGR,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,mBAAgB;AAChB,EAAAA,aAAA,gBAAa;AAGb,EAAAA,aAAA,iBAAc;AACd,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,uBAAoB;AACpB,EAAAA,aAAA,mBAAgB;AAGhB,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,qBAAkB;AAClB,EAAAA,aAAA,uBAAoB;AACpB,EAAAA,aAAA,mBAAgB;AAChB,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,iBAAc;AAvBJ,SAAAA;AAAA,GAAA;","names":["SocketEvent"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sockr-shared",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared types for Sockr messaging system",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/Dev-180Memes/sockr.git",
|
|
26
|
+
"directory": "packages/shared"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"websocket",
|
|
30
|
+
"socket.io",
|
|
31
|
+
"messaging",
|
|
32
|
+
"typescript",
|
|
33
|
+
"types"
|
|
34
|
+
],
|
|
35
|
+
"author": "Adeoluwa Agbakosi <adeoluwaagbakosi@gmail.com>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "tsup --watch",
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"prepublishOnly": "pnpm build"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.3.5",
|
|
45
|
+
"typescript": "^5.6.3"
|
|
46
|
+
}
|
|
47
|
+
}
|