oblien 1.1.7 → 1.1.8
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/index.d.ts +24 -5
- package/package.json +1 -1
- package/src/chat/index.js +29 -7
package/index.d.ts
CHANGED
|
@@ -66,15 +66,28 @@ export interface GuestManagerOptions {
|
|
|
66
66
|
onGuestCreated?: (guest: Guest) => void;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export interface
|
|
69
|
+
export interface GuestSession {
|
|
70
70
|
id: string;
|
|
71
|
+
agentId: string;
|
|
72
|
+
title: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
lastMessageAt?: string;
|
|
76
|
+
userAgent?: string;
|
|
77
|
+
country?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Guest {
|
|
81
|
+
id?: string;
|
|
71
82
|
namespace: string;
|
|
72
83
|
ip: string;
|
|
84
|
+
fingerprint?: string;
|
|
73
85
|
isGuest: boolean;
|
|
74
86
|
createdAt: string;
|
|
75
|
-
lastSeen
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
lastSeen?: string;
|
|
88
|
+
sessionCount: number;
|
|
89
|
+
metadata?: Record<string, any>;
|
|
90
|
+
sessions: GuestSession[];
|
|
78
91
|
}
|
|
79
92
|
|
|
80
93
|
export class GuestManager {
|
|
@@ -275,13 +288,19 @@ export interface ListSessionsOptions {
|
|
|
275
288
|
includeStats?: boolean;
|
|
276
289
|
}
|
|
277
290
|
|
|
291
|
+
export interface GetGuestOptions {
|
|
292
|
+
ip?: string;
|
|
293
|
+
fingerprint?: string;
|
|
294
|
+
namespace?: string;
|
|
295
|
+
}
|
|
296
|
+
|
|
278
297
|
export class OblienChat {
|
|
279
298
|
constructor(client: OblienClient, options?: ChatOptions);
|
|
280
299
|
|
|
281
300
|
// Session Creation
|
|
282
301
|
createSession(options: CreateSessionOptions): Promise<SessionData>;
|
|
283
302
|
createGuestSession(options: CreateGuestSessionOptions): Promise<GuestSessionData>;
|
|
284
|
-
getGuest(
|
|
303
|
+
getGuest(options: GetGuestOptions | string): Promise<Guest | null>; // From Oblien API (string = namespace)
|
|
285
304
|
getGuestFromCache(ip: string, fingerprint?: string): Promise<Guest | null>; // From local cache
|
|
286
305
|
|
|
287
306
|
// Session Token Management (Server-side)
|
package/package.json
CHANGED
package/src/chat/index.js
CHANGED
|
@@ -148,17 +148,39 @@ export class OblienChat {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* Get guest by IP
|
|
152
|
-
* @param {string}
|
|
153
|
-
* @param {string} [
|
|
154
|
-
* @
|
|
151
|
+
* Get guest sessions by namespace, IP, or fingerprint from Oblien API (server-side)
|
|
152
|
+
* @param {string|Object} options - Namespace string or query options object
|
|
153
|
+
* @param {string} [options.ip] - IP address
|
|
154
|
+
* @param {string} [options.fingerprint] - Client fingerprint
|
|
155
|
+
* @param {string} [options.namespace] - Guest namespace
|
|
156
|
+
* @returns {Promise<Object|null>} Guest object with sessions array or null
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* // Get by namespace (string)
|
|
160
|
+
* const guest = await chat.getGuest('guest-1-2-3-4');
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* // Get by IP and fingerprint (object)
|
|
164
|
+
* const guest = await chat.getGuest({ ip: '1.2.3.4', fingerprint: 'abc123' });
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // Get by namespace (object)
|
|
168
|
+
* const guest = await chat.getGuest({ namespace: 'guest-1-2-3-4' });
|
|
155
169
|
*/
|
|
156
|
-
async getGuest(
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
async getGuest(options) {
|
|
171
|
+
// Handle string usage: getGuest('namespace')
|
|
172
|
+
if (typeof options === 'string') {
|
|
173
|
+
options = { namespace: options };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const { ip, fingerprint, namespace } = options;
|
|
177
|
+
|
|
178
|
+
if (!ip && !fingerprint && !namespace) {
|
|
179
|
+
throw new Error('Either IP, fingerprint, or namespace is required');
|
|
159
180
|
}
|
|
160
181
|
|
|
161
182
|
const params = new URLSearchParams();
|
|
183
|
+
if (namespace) params.append('namespace', namespace);
|
|
162
184
|
if (ip) params.append('ip', ip);
|
|
163
185
|
if (fingerprint) params.append('fingerprint', fingerprint);
|
|
164
186
|
|