@osise/api-client 0.0.9 → 0.0.11

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,134 @@
1
+ /**
2
+ * Real-time types for SignalR communication
3
+ * Defines event payloads for chat and notification hubs
4
+ */
5
+ /** SignalR connection state */
6
+ export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
7
+ /** Configuration for real-time connections */
8
+ export interface RealTimeConfig {
9
+ /** Base URL for the API (same as REST API base URL) */
10
+ baseUrl: string;
11
+ /** Function that returns the current JWT access token */
12
+ accessTokenFactory: () => string | null;
13
+ /** Enable automatic reconnection (default: true) */
14
+ autoReconnect?: boolean;
15
+ /** Reconnection delay intervals in milliseconds (default: [0, 2000, 5000, 10000, 30000]) */
16
+ reconnectDelays?: number[];
17
+ /** Enable debug logging (default: false) */
18
+ debug?: boolean;
19
+ }
20
+ /** New message received in a conversation */
21
+ export interface ReceiveMessageEvent {
22
+ id: string;
23
+ conversationId: string;
24
+ type: string;
25
+ content?: string;
26
+ senderId?: string;
27
+ senderName?: string;
28
+ senderPhotoUrl?: string;
29
+ isSystemMessage: boolean;
30
+ media?: {
31
+ url: string;
32
+ fileName?: string;
33
+ fileSize?: number;
34
+ contentType?: string;
35
+ duration?: number;
36
+ thumbnailUrl?: string;
37
+ };
38
+ location?: {
39
+ latitude: number;
40
+ longitude: number;
41
+ label?: string;
42
+ };
43
+ replyTo?: {
44
+ id: string;
45
+ type: string;
46
+ contentPreview?: string;
47
+ senderName: string;
48
+ };
49
+ createdAt: string;
50
+ }
51
+ /** Typing indicator from another user */
52
+ export interface TypingIndicatorEvent {
53
+ conversationId: string;
54
+ userId: string;
55
+ isTyping: boolean;
56
+ timestamp: string;
57
+ }
58
+ /** Message delivery confirmation */
59
+ export interface MessageDeliveredEvent {
60
+ conversationId: string;
61
+ messageId: string;
62
+ deliveredAt: string;
63
+ }
64
+ /** Messages marked as read by the other participant */
65
+ export interface MessagesReadEvent {
66
+ conversationId: string;
67
+ messageIds: string[];
68
+ readAt: string;
69
+ }
70
+ /** Message was edited by the sender */
71
+ export interface MessageEditedEvent {
72
+ conversationId: string;
73
+ messageId: string;
74
+ newContent: string;
75
+ editedAt: string;
76
+ }
77
+ /** Message was deleted by the sender */
78
+ export interface MessageDeletedEvent {
79
+ conversationId: string;
80
+ messageId: string;
81
+ timestamp: string;
82
+ }
83
+ /** User online/offline status change */
84
+ export interface UserPresenceEvent {
85
+ userId: string;
86
+ isOnline: boolean;
87
+ lastSeenAt: string;
88
+ }
89
+ /** New notification received */
90
+ export interface ReceiveNotificationEvent {
91
+ id: string;
92
+ type: string;
93
+ priority: string;
94
+ title: string;
95
+ body: string;
96
+ imageUrl?: string;
97
+ actionUrl?: string;
98
+ actionType?: string;
99
+ relatedEntityId?: string;
100
+ relatedEntityType?: string;
101
+ isRead: boolean;
102
+ readAt?: string;
103
+ data?: Record<string, unknown>;
104
+ createdAt: string;
105
+ expiresAt?: string;
106
+ }
107
+ /** Updated unread notification count */
108
+ export interface NotificationCountEvent {
109
+ unreadCount: number;
110
+ timestamp: string;
111
+ }
112
+ /** Chat hub event handlers */
113
+ export interface ChatEventHandlers {
114
+ onMessage?: (message: ReceiveMessageEvent) => void;
115
+ onTypingIndicator?: (event: TypingIndicatorEvent) => void;
116
+ onMessageDelivered?: (event: MessageDeliveredEvent) => void;
117
+ onMessagesRead?: (event: MessagesReadEvent) => void;
118
+ onMessageEdited?: (event: MessageEditedEvent) => void;
119
+ onMessageDeleted?: (event: MessageDeletedEvent) => void;
120
+ onUserPresenceChanged?: (event: UserPresenceEvent) => void;
121
+ }
122
+ /** Notification hub event handlers */
123
+ export interface NotificationEventHandlers {
124
+ onNotification?: (notification: ReceiveNotificationEvent) => void;
125
+ onNotificationCountUpdated?: (event: NotificationCountEvent) => void;
126
+ }
127
+ /** Combined connection event handlers */
128
+ export interface ConnectionEventHandlers {
129
+ onConnected?: () => void;
130
+ onDisconnected?: (error?: Error) => void;
131
+ onReconnecting?: (error?: Error) => void;
132
+ onReconnected?: (connectionId?: string) => void;
133
+ }
134
+ //# sourceMappingURL=realtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../../src/types/realtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,+BAA+B;AAC/B,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC;AAE3F,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,kBAAkB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACxC,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4FAA4F;IAC5F,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAMD,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB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,KAAK,IAAI,CAAC;IAClE,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACtE;AAED,yCAAyC;AACzC,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osise/api-client",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Official TypeScript SDK for the Osise API - connecting consumers with skilled artisans",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -53,6 +53,9 @@
53
53
  "url": "https://github.com/osise/osise-api-client/issues"
54
54
  },
55
55
  "homepage": "https://github.com/osise/osise-api-client#readme",
56
+ "dependencies": {
57
+ "@microsoft/signalr": "^8.0.17"
58
+ },
56
59
  "peerDependencies": {
57
60
  "react": ">=17.0.0"
58
61
  },
@@ -64,13 +67,13 @@
64
67
  "devDependencies": {
65
68
  "@types/node": "^20.0.0",
66
69
  "@types/react": "^18.2.0",
67
- "react": "^18.2.0",
68
- "typescript": "^5.4.0",
69
- "vitest": "^1.6.0",
70
- "eslint": "^8.57.0",
71
70
  "@typescript-eslint/eslint-plugin": "^7.0.0",
72
71
  "@typescript-eslint/parser": "^7.0.0",
73
- "eslint-plugin-react-hooks": "^4.6.0"
72
+ "eslint": "^8.57.0",
73
+ "eslint-plugin-react-hooks": "^4.6.0",
74
+ "react": "^18.2.0",
75
+ "typescript": "^5.4.0",
76
+ "vitest": "^1.6.0"
74
77
  },
75
78
  "engines": {
76
79
  "node": ">=18.0.0"