@15gifts/sdk 0.1.0 → 0.3.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/dist/index.d.mts +477 -35
- package/dist/index.d.ts +477 -35
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,23 @@ import { Client as Client$1 } from 'openapi-fetch';
|
|
|
5
5
|
* Do not make direct changes to the file.
|
|
6
6
|
*/
|
|
7
7
|
interface paths$1 {
|
|
8
|
+
'/api/conversation/v2': {
|
|
9
|
+
parameters: {
|
|
10
|
+
query?: never;
|
|
11
|
+
header?: never;
|
|
12
|
+
path?: never;
|
|
13
|
+
cookie?: never;
|
|
14
|
+
};
|
|
15
|
+
get?: never;
|
|
16
|
+
put?: never;
|
|
17
|
+
/** Generate Conversation Json Response */
|
|
18
|
+
post: operations['generate_conversation_json_response_api_conversation_v2_post'];
|
|
19
|
+
delete?: never;
|
|
20
|
+
options?: never;
|
|
21
|
+
head?: never;
|
|
22
|
+
patch?: never;
|
|
23
|
+
trace?: never;
|
|
24
|
+
};
|
|
8
25
|
'/api/v1/conversation/': {
|
|
9
26
|
parameters: {
|
|
10
27
|
query?: never;
|
|
@@ -15,15 +32,10 @@ interface paths$1 {
|
|
|
15
32
|
get?: never;
|
|
16
33
|
put?: never;
|
|
17
34
|
/**
|
|
18
|
-
* Generate Conversation Response
|
|
19
|
-
* @
|
|
20
|
-
* The opening message should be the message that is displayed to the user when the engine is first opened, this is currently generated by the frontend,
|
|
21
|
-
* this message forms part of the conversation history, not that if the conversation id is not null then the opening message is ignored.
|
|
22
|
-
*
|
|
23
|
-
* This endpoint meets the contract that is outlined in
|
|
24
|
-
* [here](https://15gifts.atlassian.net/wiki/spaces/AI/pages/4319346722/Contracts+between+Conversation+Speech+Bowser+and+User+Experience+Admin+Rayman+teams).
|
|
35
|
+
* Generate Conversation Streaming Response
|
|
36
|
+
* @deprecated
|
|
25
37
|
*/
|
|
26
|
-
post: operations['
|
|
38
|
+
post: operations['generate_conversation_streaming_response_api_v1_conversation__post'];
|
|
27
39
|
delete?: never;
|
|
28
40
|
options?: never;
|
|
29
41
|
head?: never;
|
|
@@ -33,6 +45,73 @@ interface paths$1 {
|
|
|
33
45
|
}
|
|
34
46
|
interface components {
|
|
35
47
|
schemas: {
|
|
48
|
+
/** ActionsMatchedByTriggeredBranchesRecord */
|
|
49
|
+
ActionsMatchedByTriggeredBranchesRecord: {
|
|
50
|
+
/**
|
|
51
|
+
* Id
|
|
52
|
+
* @default actions_matched_by_triggered_branches
|
|
53
|
+
* @constant
|
|
54
|
+
* @enum {string}
|
|
55
|
+
*/
|
|
56
|
+
id: 'actions_matched_by_triggered_branches';
|
|
57
|
+
/**
|
|
58
|
+
* Timestamp
|
|
59
|
+
* Format: date-time
|
|
60
|
+
*/
|
|
61
|
+
timestamp?: string;
|
|
62
|
+
/** Data */
|
|
63
|
+
data: [string, string[]][];
|
|
64
|
+
};
|
|
65
|
+
/** ApplicationVersionRecord */
|
|
66
|
+
ApplicationVersionRecord: {
|
|
67
|
+
/**
|
|
68
|
+
* Id
|
|
69
|
+
* @default application_version
|
|
70
|
+
* @constant
|
|
71
|
+
* @enum {string}
|
|
72
|
+
*/
|
|
73
|
+
id: 'application_version';
|
|
74
|
+
/**
|
|
75
|
+
* Timestamp
|
|
76
|
+
* Format: date-time
|
|
77
|
+
*/
|
|
78
|
+
timestamp?: string;
|
|
79
|
+
/** Data */
|
|
80
|
+
data: string;
|
|
81
|
+
};
|
|
82
|
+
/** ContextChunksRecord */
|
|
83
|
+
ContextChunksRecord: {
|
|
84
|
+
/**
|
|
85
|
+
* Id
|
|
86
|
+
* @default context_chunks
|
|
87
|
+
* @constant
|
|
88
|
+
* @enum {string}
|
|
89
|
+
*/
|
|
90
|
+
id: 'context_chunks';
|
|
91
|
+
/**
|
|
92
|
+
* Timestamp
|
|
93
|
+
* Format: date-time
|
|
94
|
+
*/
|
|
95
|
+
timestamp?: string;
|
|
96
|
+
/** Data */
|
|
97
|
+
data: components['schemas']['ProductInformationChunkQueryResult'][];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* ConversationHistoryRequest
|
|
101
|
+
* @description A request to retrieve the conversation history
|
|
102
|
+
*/
|
|
103
|
+
ConversationHistoryRequest: {
|
|
104
|
+
/**
|
|
105
|
+
* Start Date
|
|
106
|
+
* @description The start date of the conversation history in YYYY-MM-DD HH:MM:SS format
|
|
107
|
+
*/
|
|
108
|
+
start_date: string;
|
|
109
|
+
/**
|
|
110
|
+
* End Date
|
|
111
|
+
* @description The end date of the conversation history in YYYY-MM-DD HH:MM:SS format
|
|
112
|
+
*/
|
|
113
|
+
end_date: string | null;
|
|
114
|
+
};
|
|
36
115
|
/** ConversationRequest */
|
|
37
116
|
ConversationRequest: {
|
|
38
117
|
/**
|
|
@@ -67,11 +146,252 @@ interface components {
|
|
|
67
146
|
*/
|
|
68
147
|
sessionId: string;
|
|
69
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* ConversationResponseDebugChunk
|
|
151
|
+
* @description Model for the debug chunk returned in the streaming response by the conversation endpoint.
|
|
152
|
+
*/
|
|
153
|
+
ConversationResponseDebugChunk: {
|
|
154
|
+
/**
|
|
155
|
+
* Type
|
|
156
|
+
* @default DEBUG
|
|
157
|
+
* @constant
|
|
158
|
+
* @enum {string}
|
|
159
|
+
*/
|
|
160
|
+
type: 'DEBUG';
|
|
161
|
+
/**
|
|
162
|
+
* Conversationid
|
|
163
|
+
* Format: uuid
|
|
164
|
+
* @description Unique identifier for the conversation. If an id is given in the request, the same id is returned in the response.
|
|
165
|
+
*/
|
|
166
|
+
conversationId: string;
|
|
167
|
+
/**
|
|
168
|
+
* Records
|
|
169
|
+
* @description List of debug records.
|
|
170
|
+
*/
|
|
171
|
+
records: (components['schemas']['EmbeddingTokenCountRecord'] | components['schemas']['SystemPromptRecord'] | components['schemas']['TriggeredBranchesRecord'] | components['schemas']['ActionsMatchedByTriggeredBranchesRecord'] | components['schemas']['RunActionDetailsRecord'] | components['schemas']['MaxCosineSimilarityScoresRecord'] | components['schemas']['LLMTokenCountRecord'] | components['schemas']['ContextChunksRecord'] | components['schemas']['ApplicationVersionRecord'] | components['schemas']['DBVersionRecord'] | components['schemas']['PhraseTokenProbabilitiesRecord'] | components['schemas']['ConversationTurnIDRecord'])[];
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* ConversationResponseMessageChunk
|
|
175
|
+
* @description Model for the message chunk returned in the streaming response by the conversation endpoint.
|
|
176
|
+
*/
|
|
177
|
+
ConversationResponseMessageChunk: {
|
|
178
|
+
/**
|
|
179
|
+
* Type
|
|
180
|
+
* @default MESSAGE
|
|
181
|
+
* @constant
|
|
182
|
+
* @enum {string}
|
|
183
|
+
*/
|
|
184
|
+
type: 'MESSAGE';
|
|
185
|
+
/**
|
|
186
|
+
* Conversationid
|
|
187
|
+
* Format: uuid
|
|
188
|
+
* @description Unique identifier for the conversation. If an id is given in the request, the same id is returned in the response.
|
|
189
|
+
*/
|
|
190
|
+
conversationId: string;
|
|
191
|
+
/**
|
|
192
|
+
* Message
|
|
193
|
+
* @description Message for the conversation.
|
|
194
|
+
*/
|
|
195
|
+
message: string;
|
|
196
|
+
};
|
|
197
|
+
/** ConversationTurnIDRecord */
|
|
198
|
+
ConversationTurnIDRecord: {
|
|
199
|
+
/**
|
|
200
|
+
* Id
|
|
201
|
+
* @default conversation_turn_id
|
|
202
|
+
* @constant
|
|
203
|
+
* @enum {string}
|
|
204
|
+
*/
|
|
205
|
+
id: 'conversation_turn_id';
|
|
206
|
+
/**
|
|
207
|
+
* Timestamp
|
|
208
|
+
* Format: date-time
|
|
209
|
+
*/
|
|
210
|
+
timestamp?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Conversation Turn Id
|
|
213
|
+
* Format: uuid
|
|
214
|
+
*/
|
|
215
|
+
conversation_turn_id: string;
|
|
216
|
+
};
|
|
217
|
+
/** DBVersionRecord */
|
|
218
|
+
DBVersionRecord: {
|
|
219
|
+
/**
|
|
220
|
+
* Id
|
|
221
|
+
* @default db_version
|
|
222
|
+
* @constant
|
|
223
|
+
* @enum {string}
|
|
224
|
+
*/
|
|
225
|
+
id: 'db_version';
|
|
226
|
+
/**
|
|
227
|
+
* Timestamp
|
|
228
|
+
* Format: date-time
|
|
229
|
+
*/
|
|
230
|
+
timestamp?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Db Version
|
|
233
|
+
* Format: uuid
|
|
234
|
+
*/
|
|
235
|
+
db_version: string;
|
|
236
|
+
};
|
|
237
|
+
/** EmbeddingTokenCountRecord */
|
|
238
|
+
EmbeddingTokenCountRecord: {
|
|
239
|
+
/**
|
|
240
|
+
* Id
|
|
241
|
+
* @default embedding_token_count
|
|
242
|
+
* @constant
|
|
243
|
+
* @enum {string}
|
|
244
|
+
*/
|
|
245
|
+
id: 'embedding_token_count';
|
|
246
|
+
/**
|
|
247
|
+
* Timestamp
|
|
248
|
+
* Format: date-time
|
|
249
|
+
*/
|
|
250
|
+
timestamp?: string;
|
|
251
|
+
data: components['schemas']['app__debug_stash__types__EmbeddingTokenCountRecord__Data'];
|
|
252
|
+
};
|
|
70
253
|
/** HTTPValidationError */
|
|
71
254
|
HTTPValidationError: {
|
|
72
255
|
/** Detail */
|
|
73
256
|
detail?: components['schemas']['ValidationError'][];
|
|
74
257
|
};
|
|
258
|
+
/**
|
|
259
|
+
* IndustryEnum
|
|
260
|
+
* @constant
|
|
261
|
+
* @enum {string}
|
|
262
|
+
*/
|
|
263
|
+
IndustryEnum: 'telco';
|
|
264
|
+
/** LLMTokenCountRecord */
|
|
265
|
+
LLMTokenCountRecord: {
|
|
266
|
+
/**
|
|
267
|
+
* Id
|
|
268
|
+
* @default llm_token_count
|
|
269
|
+
* @constant
|
|
270
|
+
* @enum {string}
|
|
271
|
+
*/
|
|
272
|
+
id: 'llm_token_count';
|
|
273
|
+
/**
|
|
274
|
+
* Timestamp
|
|
275
|
+
* Format: date-time
|
|
276
|
+
*/
|
|
277
|
+
timestamp?: string;
|
|
278
|
+
data: components['schemas']['app__debug_stash__types__LLMTokenCountRecord__Data'];
|
|
279
|
+
};
|
|
280
|
+
/** MaxCosineSimilarityScoresRecord */
|
|
281
|
+
MaxCosineSimilarityScoresRecord: {
|
|
282
|
+
/**
|
|
283
|
+
* Id
|
|
284
|
+
* @default max_cosine_similarity_scores
|
|
285
|
+
* @constant
|
|
286
|
+
* @enum {string}
|
|
287
|
+
*/
|
|
288
|
+
id: 'max_cosine_similarity_scores';
|
|
289
|
+
/**
|
|
290
|
+
* Timestamp
|
|
291
|
+
* Format: date-time
|
|
292
|
+
*/
|
|
293
|
+
timestamp?: string;
|
|
294
|
+
/** Data */
|
|
295
|
+
data: {
|
|
296
|
+
[key: string]: number;
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
/** PhraseTokenProbabilitiesRecord */
|
|
300
|
+
PhraseTokenProbabilitiesRecord: {
|
|
301
|
+
/**
|
|
302
|
+
* Id
|
|
303
|
+
* @default phrase_token_probabilities
|
|
304
|
+
* @constant
|
|
305
|
+
* @enum {string}
|
|
306
|
+
*/
|
|
307
|
+
id: 'phrase_token_probabilities';
|
|
308
|
+
/**
|
|
309
|
+
* Timestamp
|
|
310
|
+
* Format: date-time
|
|
311
|
+
*/
|
|
312
|
+
timestamp?: string;
|
|
313
|
+
/** Phrase Token Probabilities */
|
|
314
|
+
phrase_token_probabilities: components['schemas']['RootModel_list_TokenProbabilityRecord__'][];
|
|
315
|
+
};
|
|
316
|
+
/** ProductInformationChunkMetadata */
|
|
317
|
+
ProductInformationChunkMetadata: {
|
|
318
|
+
/** Model */
|
|
319
|
+
model: string;
|
|
320
|
+
/** Brand */
|
|
321
|
+
brand: string;
|
|
322
|
+
};
|
|
323
|
+
/** ProductInformationChunkQueryResult */
|
|
324
|
+
ProductInformationChunkQueryResult: {
|
|
325
|
+
/** Text */
|
|
326
|
+
text: string;
|
|
327
|
+
/** Customer Id */
|
|
328
|
+
customer_id: string;
|
|
329
|
+
metadata: components['schemas']['ProductInformationChunkMetadata'];
|
|
330
|
+
industry: components['schemas']['IndustryEnum'];
|
|
331
|
+
/** Similarity Score */
|
|
332
|
+
similarity_score: number;
|
|
333
|
+
};
|
|
334
|
+
/** RootModel[list[TokenProbabilityRecord]] */
|
|
335
|
+
RootModel_list_TokenProbabilityRecord__: components['schemas']['TokenProbabilityRecord'][];
|
|
336
|
+
/** RunActionDetailsRecord */
|
|
337
|
+
RunActionDetailsRecord: {
|
|
338
|
+
/**
|
|
339
|
+
* Id
|
|
340
|
+
* @default run_action_details
|
|
341
|
+
* @constant
|
|
342
|
+
* @enum {string}
|
|
343
|
+
*/
|
|
344
|
+
id: 'run_action_details';
|
|
345
|
+
/**
|
|
346
|
+
* Timestamp
|
|
347
|
+
* Format: date-time
|
|
348
|
+
*/
|
|
349
|
+
timestamp?: string;
|
|
350
|
+
data: components['schemas']['app__debug_stash__types__RunActionDetailsRecord__Data'];
|
|
351
|
+
};
|
|
352
|
+
/** SystemPromptRecord */
|
|
353
|
+
SystemPromptRecord: {
|
|
354
|
+
/**
|
|
355
|
+
* Id
|
|
356
|
+
* @default system_prompt
|
|
357
|
+
* @constant
|
|
358
|
+
* @enum {string}
|
|
359
|
+
*/
|
|
360
|
+
id: 'system_prompt';
|
|
361
|
+
/**
|
|
362
|
+
* Timestamp
|
|
363
|
+
* Format: date-time
|
|
364
|
+
*/
|
|
365
|
+
timestamp?: string;
|
|
366
|
+
/** Data */
|
|
367
|
+
data: string;
|
|
368
|
+
};
|
|
369
|
+
/** TokenProbabilityRecord */
|
|
370
|
+
TokenProbabilityRecord: {
|
|
371
|
+
/** Token */
|
|
372
|
+
token: string;
|
|
373
|
+
/** Probability */
|
|
374
|
+
probability: number;
|
|
375
|
+
/** Log Probability */
|
|
376
|
+
log_probability: number;
|
|
377
|
+
};
|
|
378
|
+
/** TriggeredBranchesRecord */
|
|
379
|
+
TriggeredBranchesRecord: {
|
|
380
|
+
/**
|
|
381
|
+
* Id
|
|
382
|
+
* @default triggered_branches
|
|
383
|
+
* @constant
|
|
384
|
+
* @enum {string}
|
|
385
|
+
*/
|
|
386
|
+
id: 'triggered_branches';
|
|
387
|
+
/**
|
|
388
|
+
* Timestamp
|
|
389
|
+
* Format: date-time
|
|
390
|
+
*/
|
|
391
|
+
timestamp?: string;
|
|
392
|
+
/** Data */
|
|
393
|
+
data: string[];
|
|
394
|
+
};
|
|
75
395
|
/** ValidationError */
|
|
76
396
|
ValidationError: {
|
|
77
397
|
/** Location */
|
|
@@ -81,6 +401,35 @@ interface components {
|
|
|
81
401
|
/** Error Type */
|
|
82
402
|
type: string;
|
|
83
403
|
};
|
|
404
|
+
/** Data */
|
|
405
|
+
app__debug_stash__types__EmbeddingTokenCountRecord__Data: {
|
|
406
|
+
/** Token Count */
|
|
407
|
+
token_count: number;
|
|
408
|
+
/** Model */
|
|
409
|
+
model: string;
|
|
410
|
+
/** Embedded Text */
|
|
411
|
+
embedded_text: string;
|
|
412
|
+
};
|
|
413
|
+
/** Data */
|
|
414
|
+
app__debug_stash__types__LLMTokenCountRecord__Data: {
|
|
415
|
+
/** Input Token Count */
|
|
416
|
+
input_token_count: number;
|
|
417
|
+
/** Output Token Count */
|
|
418
|
+
output_token_count: number;
|
|
419
|
+
/** Response Text */
|
|
420
|
+
response_text: string;
|
|
421
|
+
/** Input Messages */
|
|
422
|
+
input_messages: string;
|
|
423
|
+
/** Model */
|
|
424
|
+
model: string;
|
|
425
|
+
};
|
|
426
|
+
/** Data */
|
|
427
|
+
app__debug_stash__types__RunActionDetailsRecord__Data: {
|
|
428
|
+
/** Action Type */
|
|
429
|
+
action_type: string;
|
|
430
|
+
/** Branch Type */
|
|
431
|
+
branch_type: string;
|
|
432
|
+
};
|
|
84
433
|
};
|
|
85
434
|
responses: never;
|
|
86
435
|
parameters: never;
|
|
@@ -89,7 +438,52 @@ interface components {
|
|
|
89
438
|
pathItems: never;
|
|
90
439
|
}
|
|
91
440
|
interface operations {
|
|
92
|
-
|
|
441
|
+
generate_conversation_json_response_api_conversation_v2_post: {
|
|
442
|
+
parameters: {
|
|
443
|
+
query?: never;
|
|
444
|
+
header?: {
|
|
445
|
+
'user-agent'?: string;
|
|
446
|
+
/**
|
|
447
|
+
* @description Comma-separated list of feature flags (flags might require elevated permissions)
|
|
448
|
+
* @example debug,no-decision-forest
|
|
449
|
+
*/
|
|
450
|
+
'x-feature-flags'?: string | null;
|
|
451
|
+
/**
|
|
452
|
+
* @description the version of the sdk version that is being used
|
|
453
|
+
* @example 1.0.0
|
|
454
|
+
*/
|
|
455
|
+
'x-sdk-version'?: string | null;
|
|
456
|
+
};
|
|
457
|
+
path?: never;
|
|
458
|
+
cookie?: never;
|
|
459
|
+
};
|
|
460
|
+
requestBody: {
|
|
461
|
+
content: {
|
|
462
|
+
'application/json': components['schemas']['ConversationRequest'];
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
responses: {
|
|
466
|
+
/** @description A successful response from the conversation service */
|
|
467
|
+
200: {
|
|
468
|
+
headers: {
|
|
469
|
+
[name: string]: unknown;
|
|
470
|
+
};
|
|
471
|
+
content: {
|
|
472
|
+
'application/json': components['schemas']['ConversationResponseMessageChunk'] | components['schemas']['ConversationResponseDebugChunk'];
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
/** @description Validation Error */
|
|
476
|
+
422: {
|
|
477
|
+
headers: {
|
|
478
|
+
[name: string]: unknown;
|
|
479
|
+
};
|
|
480
|
+
content: {
|
|
481
|
+
'application/json': components['schemas']['HTTPValidationError'];
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
generate_conversation_streaming_response_api_v1_conversation__post: {
|
|
93
487
|
parameters: {
|
|
94
488
|
query?: never;
|
|
95
489
|
header?: {
|
|
@@ -99,6 +493,11 @@ interface operations {
|
|
|
99
493
|
* @example debug,no-decision-forest
|
|
100
494
|
*/
|
|
101
495
|
'x-feature-flags'?: string | null;
|
|
496
|
+
/**
|
|
497
|
+
* @description The version of the SDK version that is being used
|
|
498
|
+
* @example 1.0.0
|
|
499
|
+
*/
|
|
500
|
+
'x-sdk-version'?: string | null;
|
|
102
501
|
};
|
|
103
502
|
path?: never;
|
|
104
503
|
cookie?: never;
|
|
@@ -531,8 +930,11 @@ interface paths {
|
|
|
531
930
|
* "url": "https://www.example.com/telco/"
|
|
532
931
|
* } */
|
|
533
932
|
'application/json': {
|
|
534
|
-
/**
|
|
535
|
-
|
|
933
|
+
/**
|
|
934
|
+
* @description Event Name
|
|
935
|
+
* @enum {string}
|
|
936
|
+
*/
|
|
937
|
+
eventName: 'welcome_screen-shown' | 'tab-shown' | 'feedback_submit-clicked' | 'page-shown' | 'tool-closed' | 'user_message-submitted' | 'assistant_message-submitted' | 'feedback-shown' | 'feedback_skip-clicked' | 'sale-completed' | 'tab-clicked' | 'tool_close-clicked' | 'woo_assistant_message-submitted' | 'woo_user_message-submitted' | 'woo_reaction-submitted';
|
|
536
938
|
/** @description Customer ID */
|
|
537
939
|
customerId: string;
|
|
538
940
|
/** @description User ID */
|
|
@@ -579,7 +981,19 @@ interface paths {
|
|
|
579
981
|
};
|
|
580
982
|
}
|
|
581
983
|
|
|
582
|
-
|
|
984
|
+
/**
|
|
985
|
+
* These are the types as defined in the OpenAPI schema.
|
|
986
|
+
* We don't use them directly, or export them here because of how they appear in the documentation site.
|
|
987
|
+
*/
|
|
988
|
+
type ApiConversationRequest = components['schemas']['ConversationRequest'];
|
|
989
|
+
type ApiMessage = components['schemas']['ConversationResponseMessageChunk'];
|
|
990
|
+
type ApiDebug = components['schemas']['ConversationResponseDebugChunk'];
|
|
991
|
+
type ApiTrackingEvent = paths['/api/tracking/user/v1']['post']['requestBody']['content']['application/json'];
|
|
992
|
+
/**
|
|
993
|
+
* The request to the conversation API.
|
|
994
|
+
*/
|
|
995
|
+
interface ConversationApiRequest extends ApiConversationRequest {
|
|
996
|
+
}
|
|
583
997
|
/**
|
|
584
998
|
* Configuration options for initializing the client.
|
|
585
999
|
*/
|
|
@@ -587,7 +1001,7 @@ interface Config {
|
|
|
587
1001
|
/**
|
|
588
1002
|
* The customer ID associated with the conversation.
|
|
589
1003
|
*/
|
|
590
|
-
customerId:
|
|
1004
|
+
customerId: ConversationApiRequest['customerId'];
|
|
591
1005
|
/**
|
|
592
1006
|
* Optional fetch function to use for making HTTP requests.
|
|
593
1007
|
* If not provided, the default `fetch` implementation will be used.
|
|
@@ -622,19 +1036,19 @@ interface Identity {
|
|
|
622
1036
|
/**
|
|
623
1037
|
* The customer ID.
|
|
624
1038
|
*/
|
|
625
|
-
customerId:
|
|
1039
|
+
customerId: ConversationApiRequest['customerId'];
|
|
626
1040
|
/**
|
|
627
1041
|
* The conversation ID.
|
|
628
1042
|
*/
|
|
629
|
-
conversationId:
|
|
1043
|
+
conversationId: ConversationApiRequest['conversationId'];
|
|
630
1044
|
/**
|
|
631
1045
|
* The session ID associated with the user.
|
|
632
1046
|
*/
|
|
633
|
-
sessionId:
|
|
1047
|
+
sessionId: ConversationApiRequest['sessionId'];
|
|
634
1048
|
/**
|
|
635
1049
|
* The user ID.
|
|
636
1050
|
*/
|
|
637
|
-
userId:
|
|
1051
|
+
userId: ConversationApiRequest['userId'];
|
|
638
1052
|
}
|
|
639
1053
|
/**
|
|
640
1054
|
* Message within a conversation.
|
|
@@ -643,19 +1057,31 @@ interface Message {
|
|
|
643
1057
|
/**
|
|
644
1058
|
* The conversation ID to which the message belongs.
|
|
645
1059
|
*/
|
|
646
|
-
conversationId:
|
|
1060
|
+
conversationId: ApiMessage['conversationId'];
|
|
647
1061
|
/**
|
|
648
|
-
*
|
|
1062
|
+
* The message content.
|
|
649
1063
|
*/
|
|
650
|
-
|
|
1064
|
+
message: ApiMessage['message'];
|
|
651
1065
|
/**
|
|
652
|
-
* The message
|
|
1066
|
+
* The message type.
|
|
653
1067
|
*/
|
|
654
|
-
|
|
1068
|
+
type: ApiMessage['type'];
|
|
1069
|
+
}
|
|
1070
|
+
interface DebugResponse {
|
|
1071
|
+
/**
|
|
1072
|
+
* The conversation ID to which the message belongs.
|
|
1073
|
+
*/
|
|
1074
|
+
conversationId: ApiDebug['conversationId'];
|
|
1075
|
+
/**
|
|
1076
|
+
* The debug records.
|
|
1077
|
+
*/
|
|
1078
|
+
records: ApiDebug['records'];
|
|
655
1079
|
/**
|
|
656
1080
|
* The message type.
|
|
657
1081
|
*/
|
|
658
|
-
type:
|
|
1082
|
+
type: ApiDebug['type'];
|
|
1083
|
+
}
|
|
1084
|
+
interface TrackingEvent extends ApiTrackingEvent {
|
|
659
1085
|
}
|
|
660
1086
|
|
|
661
1087
|
/**
|
|
@@ -668,7 +1094,7 @@ declare class Client {
|
|
|
668
1094
|
* @example
|
|
669
1095
|
* ```ts
|
|
670
1096
|
* const client = new Client({ customerId: 'YOUR_CUSTOMER_ID' })
|
|
671
|
-
* const { data } = await client.endpoint.conversation.
|
|
1097
|
+
* const { data } = await client.endpoint.conversation.POST('/api/conversation/v2')
|
|
672
1098
|
* ```
|
|
673
1099
|
*/
|
|
674
1100
|
endpoint: Endpoint;
|
|
@@ -713,28 +1139,44 @@ declare class Client {
|
|
|
713
1139
|
* Sends a message in the conversation, optionally with an opening message.
|
|
714
1140
|
*
|
|
715
1141
|
* @param options - An object containing the opening message and the user message.
|
|
716
|
-
* @returns A promise that resolves to
|
|
1142
|
+
* @returns A promise that resolves to a message or a debug record.
|
|
1143
|
+
* If the message is a debug record, it will throw an error.
|
|
717
1144
|
*
|
|
718
1145
|
* @example
|
|
719
1146
|
* ```ts
|
|
720
|
-
* const
|
|
721
|
-
* openingMessage: 'Hello!',
|
|
1147
|
+
* const newMessage = await client.sendMessage({
|
|
1148
|
+
* openingMessage: 'Hello! How can I help you?',
|
|
722
1149
|
* userMessage: 'How can I get support?',
|
|
723
1150
|
* })
|
|
724
1151
|
*
|
|
725
|
-
* if (
|
|
726
|
-
*
|
|
727
|
-
* console.log('Received message:', message)
|
|
728
|
-
* }
|
|
1152
|
+
* if (newMessages) {
|
|
1153
|
+
* console.log('Received messages:', newMessages)
|
|
729
1154
|
* } else {
|
|
730
1155
|
* console.log('No message received')
|
|
731
1156
|
* }
|
|
732
1157
|
* ```
|
|
733
1158
|
*/
|
|
734
1159
|
sendMessage({ openingMessage, userMessage, }: {
|
|
735
|
-
openingMessage?:
|
|
736
|
-
userMessage:
|
|
737
|
-
}): Promise<
|
|
1160
|
+
openingMessage?: ConversationApiRequest['openingMessage'];
|
|
1161
|
+
userMessage: ConversationApiRequest['userMessage'];
|
|
1162
|
+
}): Promise<Message | undefined>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Sends an event to the tracking API, with the required properties already set.
|
|
1165
|
+
*
|
|
1166
|
+
* @param eventName - The name of the event to track.
|
|
1167
|
+
* @param properties - Additional properties to include in the event.
|
|
1168
|
+
* @returns A promise that resolves once the event is tracked.
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* await client.trackEvent('tab-shown')
|
|
1173
|
+
* ```
|
|
1174
|
+
*/
|
|
1175
|
+
trackEvent(eventName: TrackingEvent['eventName'], properties?: TrackingEvent['additionalProperties']): Promise<{
|
|
1176
|
+
data?: undefined;
|
|
1177
|
+
error?: undefined;
|
|
1178
|
+
response: Response;
|
|
1179
|
+
}>;
|
|
738
1180
|
}
|
|
739
1181
|
|
|
740
1182
|
/**
|
|
@@ -856,4 +1298,4 @@ declare const getUserId: () => string | null;
|
|
|
856
1298
|
*/
|
|
857
1299
|
declare const setUserId: (userId: string) => void;
|
|
858
1300
|
|
|
859
|
-
export { CONVERSATION_ID, Client, type Config, type Endpoint, type Identity, type Message, SESSION_ID, TTL, USER_ID, deleteConversationId, getConversationId, getSessionId, getUserId, setConversationId, setSessionId, setUserId };
|
|
1301
|
+
export { CONVERSATION_ID, Client, type Config, type ConversationApiRequest, type DebugResponse, type Endpoint, type Identity, type Message, SESSION_ID, TTL, type TrackingEvent, USER_ID, deleteConversationId, getConversationId, getSessionId, getUserId, setConversationId, setSessionId, setUserId };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)){let s=e.substring(6).trim(),n=JSON.parse(s);return t?.(n),n}},M=async function*(e,t){let n=e.pipeThrough(new TextDecoderStream).getReader();try{for(;;){let{done:i,value:r}=await n.read();if(i)break;yield A(r,t)}}finally{n.releaseLock()}},v=M;var h="__15gifts_user_id",T=1e3*60*60*24*30,y=()=>u(h),l=e=>g(h,e,T);var _="0.1.0";var S=class{endpoint;identity;constructor({customerId:t,fetch:s,conversationUrl:n,frontendUrl:i}){let r={"X-SDK-VERSION":_};this.endpoint={conversation:(0,x.default)({baseUrl:n,fetch:s,headers:r}),frontend:(0,x.default)({baseUrl:i,fetch:s,headers:r})},this.identity={customerId:t,conversationId:c(),sessionId:I()??"",userId:y()}}async createIdentity(){let{conversationId:t,sessionId:s,userId:n}=this.identity;if(t&&this.endConversation(),!s||!n){let{data:i}=await this.endpoint.frontend.POST("/api/tracking/identity/v1",{body:{createSessionId:!s,createUserId:!n,customerId:this.identity.customerId}});i&&(!s&&i.sessionId&&(this.identity.sessionId=i.sessionId,f(i.sessionId)),!n&&i.userId&&(this.identity.userId=i.userId,l(i.userId)))}}endConversation(){d()}async sendMessage({openingMessage:t,userMessage:s}){t&&this.identity.conversationId&&this.endConversation();let{data:n}=await this.endpoint.conversation.POST("/api/v1/conversation/",{body:{conversationId:this.identity.conversationId,customerId:this.identity.customerId,openingMessage:t,sessionId:this.identity.sessionId,userId:this.identity.userId,userMessage:s},parseAs:"stream"});return n?v(n,r=>{p(r.conversationId)}):void 0}};0&&(module.exports={CONVERSATION_ID,Client,SESSION_ID,TTL,USER_ID,deleteConversationId,getConversationId,getSessionId,getUserId,setConversationId,setSessionId,setUserId});
|
|
1
|
+
"use strict";var _=Object.create;var o=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var s in t)o(e,s,{get:t[s],enumerable:!0})},S=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of w(t))!b.call(e,i)&&i!==s&&o(e,i,{get:()=>t[i],enumerable:!(n=P(t,i))||n.enumerable});return e};var O=(e,t,s)=>(s=e!=null?_(T(e)):{},S(t||!e||!e.__esModule?o(s,"default",{value:e,enumerable:!0}):s,e)),R=e=>S(o({},"__esModule",{value:!0}),e);var A={};D(A,{CONVERSATION_ID:()=>r,Client:()=>x,SESSION_ID:()=>c,TTL:()=>E,USER_ID:()=>f,deleteConversationId:()=>d,getConversationId:()=>a,getSessionId:()=>I,getUserId:()=>v,setConversationId:()=>p,setSessionId:()=>u,setUserId:()=>y});module.exports=R(A);var h=O(require("openapi-fetch"));var r="__15gifts_conversation_id",d=()=>sessionStorage.removeItem(r),a=()=>sessionStorage.getItem(r),p=e=>sessionStorage.setItem(r,e);var c="__15gifts_session_id",I=()=>sessionStorage.getItem(c),u=e=>sessionStorage.setItem(c,e);var U=e=>{let t=localStorage.getItem(e);if(!t)return null;let s=JSON.parse(t);return Date.now()>s.expires?(localStorage.removeItem(e),null):s.value},m=U;var k=(e,t,s)=>{let n={expires:Date.now()+s,value:t};localStorage.setItem(e,JSON.stringify(n))},g=k;var f="__15gifts_user_id",E=1e3*60*60*24*30,v=()=>m(f),y=e=>g(f,e,E);var C="0.3.0";var x=class{endpoint;identity;constructor({customerId:t,fetch:s,conversationUrl:n,frontendUrl:i}){let l={"X-SDK-VERSION":C};this.endpoint={conversation:(0,h.default)({baseUrl:n,fetch:s,headers:l}),frontend:(0,h.default)({baseUrl:i,fetch:s,headers:l})},this.identity={customerId:t,conversationId:a(),sessionId:I()??"",userId:v()}}async createIdentity(){let{conversationId:t,sessionId:s,userId:n}=this.identity;if(t&&this.endConversation(),!s||!n){let{data:i}=await this.endpoint.frontend.POST("/api/tracking/identity/v1",{body:{createSessionId:!s,createUserId:!n,customerId:this.identity.customerId}});i&&(!s&&i.sessionId&&(this.identity.sessionId=i.sessionId,u(i.sessionId)),!n&&i.userId&&(this.identity.userId=i.userId,y(i.userId)))}}endConversation(){d()}async sendMessage({openingMessage:t,userMessage:s}){t&&this.identity.conversationId&&this.endConversation();let{data:n}=await this.endpoint.conversation.POST("/api/conversation/v2",{body:{conversationId:this.identity.conversationId,customerId:this.identity.customerId,openingMessage:t,sessionId:this.identity.sessionId,userId:this.identity.userId,userMessage:s}});if(n){if(p(n.conversationId),n.type==="DEBUG")throw n;return n}}async trackEvent(t,s){let n={additionalProperties:s,conversationId:this.identity.conversationId||void 0,customerId:this.identity.customerId,deviceType:void 0,eventName:t,sessionId:this.identity.sessionId,url:window.location.href,userAgent:window.navigator.userAgent,userId:this.identity.userId||void 0};return this.endpoint.frontend.POST("/api/tracking/user/v1",{body:n})}};0&&(module.exports={CONVERSATION_ID,Client,SESSION_ID,TTL,USER_ID,deleteConversationId,getConversationId,getSessionId,getUserId,setConversationId,setSessionId,setUserId});
|
|
3
2
|
//# sourceMappingURL=index.js.map
|