@cimulate/copilot-sdk 1.1.1 → 1.2.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.
Files changed (114) hide show
  1. package/README.md +15 -0
  2. package/dist/bundle.cimulate.copilot-sdk.099d19fa.umd.js +2 -0
  3. package/dist/bundle.cimulate.copilot-sdk.099d19fa.umd.js.map +1 -0
  4. package/dist/bundle.cimulate.copilot-sdk.5716b677.cjs.js +2 -0
  5. package/dist/bundle.cimulate.copilot-sdk.5716b677.cjs.js.map +1 -0
  6. package/dist/bundle.cimulate.copilot-sdk.64883fd2.esm.js +2 -0
  7. package/dist/bundle.cimulate.copilot-sdk.64883fd2.esm.js.map +1 -0
  8. package/dist/index.cjs.js +1 -1
  9. package/dist/index.cjs.js.map +1 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/index.umd.js +1 -1
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/types/copilot.d.ts +17 -17
  15. package/dist/types/model/Cancel.d.ts +1 -1
  16. package/dist/types/model/CommonEventFields.d.ts +1 -1
  17. package/dist/types/model/CommonFields.d.ts +3 -4
  18. package/dist/types/model/CommonMetadata.d.ts +7 -0
  19. package/dist/types/model/CommonRequiredFields.d.ts +2 -3
  20. package/dist/types/model/ConnectAck.d.ts +4 -4
  21. package/dist/types/model/ConnectAckMessageFields.d.ts +8 -0
  22. package/dist/types/model/CopilotEvent.d.ts +20 -0
  23. package/dist/types/model/CopilotSearch.d.ts +3 -3
  24. package/dist/types/model/CopilotSearchSuggestion.d.ts +7 -0
  25. package/dist/types/model/DisplayProducts.d.ts +7 -6
  26. package/dist/types/model/DisplayProductsMessageFields.d.ts +4 -2
  27. package/dist/types/model/Done.d.ts +4 -4
  28. package/dist/types/model/DoneMessageFields.d.ts +4 -0
  29. package/dist/types/model/Error.d.ts +5 -5
  30. package/dist/types/model/ErrorMessageFields.d.ts +2 -1
  31. package/dist/types/model/EventAck.d.ts +14 -8
  32. package/dist/types/model/EventAckMessageFields.d.ts +10 -0
  33. package/dist/types/model/EventAckNames.d.ts +6 -0
  34. package/dist/types/model/FacetValue.d.ts +1 -1
  35. package/dist/types/model/FacetedNavigation.d.ts +2 -2
  36. package/dist/types/model/FacetedNavigationSuggestion.d.ts +7 -0
  37. package/dist/types/model/FollowUp.d.ts +7 -6
  38. package/dist/types/model/FollowUpMessageFields.d.ts +7 -0
  39. package/dist/types/model/Inquiry.d.ts +4 -4
  40. package/dist/types/model/InquiryMessageFields.d.ts +4 -0
  41. package/dist/types/model/PartialInquiry.d.ts +5 -5
  42. package/dist/types/model/PartialInquiryMessageFields.d.ts +2 -1
  43. package/dist/types/model/RefinedSearch.d.ts +10 -9
  44. package/dist/types/model/RefinedSearchMessageFields.d.ts +7 -5
  45. package/dist/types/model/ReturnedFields.d.ts +2 -0
  46. package/dist/types/model/Root.d.ts +34 -26
  47. package/dist/types/model/SearchParams.d.ts +5 -0
  48. package/dist/types/model/SessionData.d.ts +5 -4
  49. package/dist/types/model/SessionEventStatusReply.d.ts +1 -2
  50. package/dist/types/model/SessionInformation.d.ts +7 -7
  51. package/dist/types/model/WorkflowMetadata.d.ts +5 -0
  52. package/dist/types/model/index.d.ts +14 -8
  53. package/package.json +6 -4
  54. package/rollup.config.js +1 -1
  55. package/src/copilot.ts +49 -25
  56. package/src/model/Cancel.ts +1 -1
  57. package/src/model/CommonEventFields.ts +1 -1
  58. package/src/model/CommonFields.ts +3 -4
  59. package/src/model/CommonMetadata.ts +7 -0
  60. package/src/model/CommonRequiredFields.ts +2 -3
  61. package/src/model/ConnectAck.ts +4 -4
  62. package/src/model/ConnectAckMessageFields.ts +8 -0
  63. package/src/model/CopilotEvent.ts +20 -0
  64. package/src/model/CopilotSearch.ts +3 -3
  65. package/src/model/CopilotSearchSuggestion.ts +7 -0
  66. package/src/model/DisplayProducts.ts +7 -7
  67. package/src/model/DisplayProductsMessageFields.ts +4 -3
  68. package/src/model/Done.ts +4 -4
  69. package/src/model/DoneMessageFields.ts +5 -0
  70. package/src/model/Error.ts +5 -5
  71. package/src/model/ErrorMessageFields.ts +2 -1
  72. package/src/model/EventAck.ts +16 -8
  73. package/src/model/EventAckMessageFields.ts +10 -0
  74. package/src/model/EventAckNames.ts +7 -0
  75. package/src/model/FacetValue.ts +1 -1
  76. package/src/model/FacetedNavigation.ts +2 -2
  77. package/src/model/FacetedNavigationSuggestion.ts +7 -0
  78. package/src/model/FollowUp.ts +7 -6
  79. package/src/model/FollowUpMessageFields.ts +7 -0
  80. package/src/model/Inquiry.ts +4 -4
  81. package/src/model/InquiryMessageFields.ts +5 -0
  82. package/src/model/PartialInquiry.ts +5 -5
  83. package/src/model/PartialInquiryMessageFields.ts +2 -1
  84. package/src/model/RefinedSearch.ts +10 -9
  85. package/src/model/RefinedSearchMessageFields.ts +7 -5
  86. package/src/model/ReturnedFields.ts +4 -0
  87. package/src/model/Root.ts +34 -26
  88. package/src/model/SearchParams.ts +6 -0
  89. package/src/model/SessionData.ts +5 -4
  90. package/src/model/SessionEventStatusReply.ts +1 -2
  91. package/src/model/SessionInformation.ts +7 -7
  92. package/src/model/WorkflowMetadata.ts +6 -0
  93. package/src/model/index.ts +14 -8
  94. package/tsconfig.json +2 -1
  95. package/dist/bundle.cimulate.copilot-sdk.65f7195a.esm.js +0 -2
  96. package/dist/bundle.cimulate.copilot-sdk.65f7195a.esm.js.map +0 -1
  97. package/dist/bundle.cimulate.copilot-sdk.a2e829d8.cjs.js +0 -2
  98. package/dist/bundle.cimulate.copilot-sdk.a2e829d8.cjs.js.map +0 -1
  99. package/dist/bundle.cimulate.copilot-sdk.c68ae11d.umd.js +0 -2
  100. package/dist/bundle.cimulate.copilot-sdk.c68ae11d.umd.js.map +0 -1
  101. package/dist/types/model/ConnectionAcknowledgmentMessageFields.d.ts +0 -7
  102. package/dist/types/model/EventAcknowledgmentMessageFields.d.ts +0 -6
  103. package/dist/types/model/FollowMinusUpMessageFields.d.ts +0 -5
  104. package/dist/types/model/ReservedEvent.d.ts +0 -10
  105. package/dist/types/model/SearchParameters.d.ts +0 -5
  106. package/dist/types/model/SessionEventInformationReply.d.ts +0 -5
  107. package/dist/types/model/Suggestion.d.ts +0 -6
  108. package/src/model/ConnectionAcknowledgmentMessageFields.ts +0 -7
  109. package/src/model/EventAcknowledgmentMessageFields.ts +0 -6
  110. package/src/model/FollowMinusUpMessageFields.ts +0 -5
  111. package/src/model/ReservedEvent.ts +0 -11
  112. package/src/model/SearchParameters.ts +0 -6
  113. package/src/model/SessionEventInformationReply.ts +0 -6
  114. package/src/model/Suggestion.ts +0 -7
package/src/copilot.ts CHANGED
@@ -1,7 +1,20 @@
1
1
  import io, { ManagerOptions, Socket, SocketOptions } from "socket.io-client";
2
- import { merge } from "ts-deepmerge";
3
2
 
4
- import type * as Event from "./model/index"
3
+ import type {
4
+ ConnectAck,
5
+ DisplayProducts,
6
+ Done,
7
+ Error,
8
+ EventAck,
9
+ EventAckNames,
10
+ FollowUp,
11
+ Inquiry,
12
+ PartialInquiry,
13
+ RefinedSearch,
14
+ ReturnedFields,
15
+ SessionInformation,
16
+ } from "./model";
17
+ import deepmerge from "deepmerge";
5
18
 
6
19
  type SocketIOOptions = Partial<ManagerOptions & SocketOptions>;
7
20
 
@@ -27,7 +40,9 @@ const socketDefaults: SocketIOOptions = {
27
40
  timeout: 10000,
28
41
  };
29
42
 
30
- class CimulateCopilot {
43
+ export default class CimulateCopilot<
44
+ T extends ReturnedFields = ReturnedFields
45
+ > {
31
46
  private socket: Socket;
32
47
 
33
48
  constructor({
@@ -38,9 +53,10 @@ class CimulateCopilot {
38
53
  }: CimulateCopilotOptions) {
39
54
  const socketioEndpoint = `${baseUrl}${namespace}`;
40
55
 
41
- this.socket = io(
42
- socketioEndpoint,
43
- merge(socketDefaults, socketOptions, {
56
+ const options: SocketIOOptions[] = [
57
+ socketDefaults,
58
+ socketOptions,
59
+ {
44
60
  withCredentials: true, // enables cookies
45
61
  transportOptions: {
46
62
  polling: {
@@ -49,8 +65,10 @@ class CimulateCopilot {
49
65
  },
50
66
  },
51
67
  },
52
- })
53
- );
68
+ },
69
+ ];
70
+
71
+ this.socket = io(socketioEndpoint, deepmerge.all(options));
54
72
  }
55
73
 
56
74
  connect() {
@@ -58,8 +76,11 @@ class CimulateCopilot {
58
76
  }
59
77
 
60
78
  search(
61
- { userPrompt, searchParams }: { userPrompt?: string; searchParams: SearchParams },
62
- callback?: (searchAck: Event.EventAck) => void
79
+ {
80
+ userPrompt,
81
+ searchParams,
82
+ }: { userPrompt?: string; searchParams: SearchParams },
83
+ callback?: (searchAck: EventAck<EventAckNames.COPILOT_SEARCH_ACK>) => void
63
84
  ) {
64
85
  const payload = {
65
86
  user_prompt: userPrompt,
@@ -74,7 +95,9 @@ class CimulateCopilot {
74
95
 
75
96
  facetedNavigation(
76
97
  { searchParams }: { searchParams: SearchParams },
77
- callback?: (facetedNavigation: Event.FacetedNavigation) => void
98
+ callback?: (
99
+ facetedNavigationAck: EventAck<EventAckNames.FACETED_NAVIGATION_ACK>
100
+ ) => void
78
101
  ) {
79
102
  const payload = {
80
103
  search_params: searchParams,
@@ -88,7 +111,7 @@ class CimulateCopilot {
88
111
 
89
112
  cancelRequest(
90
113
  { eventId, reason }: { eventId: string; reason: string },
91
- callback?: (cancelAck: Event.EventAck) => void
114
+ callback?: (cancelAck: EventAck<EventAckNames.CANCEL_ACK>) => void
92
115
  ) {
93
116
  const payload = {
94
117
  event_id: eventId,
@@ -101,43 +124,47 @@ class CimulateCopilot {
101
124
  this.socket.emit("cancel", payload);
102
125
  }
103
126
 
104
- requestSessionData(callback: (sessionData: Event.SessionData) => void) {
127
+ requestSessionInformation(
128
+ callback: (sessionInformation: SessionInformation<T>) => void
129
+ ) {
105
130
  this.socket.emit("session_info", callback);
106
131
  }
107
132
 
108
- onConnectAck(callback: (connectAck: Event.ConnectAck) => void) {
133
+ onConnectAck(callback: (connectAck: ConnectAck) => void) {
109
134
  this.socket.on("connect_ack", callback);
110
135
  }
111
136
 
112
- onSearchAck(callback: (searchAck: Event.EventAck) => void) {
137
+ onSearchAck(
138
+ callback: (searchAck: EventAck<EventAckNames.COPILOT_SEARCH_ACK>) => void
139
+ ) {
113
140
  this.socket.on("search_ack", callback);
114
141
  }
115
142
 
116
- onRefinedSearch(callback: (refinedSearch: Event.RefinedSearch) => void) {
143
+ onRefinedSearch(callback: (refinedSearch: RefinedSearch<T>) => void) {
117
144
  this.socket.on("refined_search", callback);
118
145
  }
119
146
 
120
- onFollowUp(callback: (followUp: Event.FollowUp) => void) {
147
+ onFollowUp(callback: (followUp: FollowUp) => void) {
121
148
  this.socket.on("follow_up", callback);
122
149
  }
123
150
 
124
- onInquiry(callback: (inquiry: Event.Inquiry) => void) {
151
+ onInquiry(callback: (inquiry: Inquiry) => void) {
125
152
  this.socket.on("inquiry", callback);
126
153
  }
127
154
 
128
- onPartialInquiry(callback: (partialInquiry: Event.PartialInquiry) => void) {
155
+ onPartialInquiry(callback: (partialInquiry: PartialInquiry) => void) {
129
156
  this.socket.on("partial_inquiry", callback);
130
157
  }
131
158
 
132
- onDisplayProducts(callback: (displayProducts: Event.DisplayProducts) => void) {
159
+ onDisplayProducts(callback: (displayProducts: DisplayProducts<T>) => void) {
133
160
  this.socket.on("display_products", callback);
134
161
  }
135
162
 
136
- onDone(callback: (done: Event.Done) => void) {
163
+ onDone(callback: (done: Done) => void) {
137
164
  this.socket.on("done", callback);
138
165
  }
139
166
 
140
- onError(callback: (error: Event.Error) => void) {
167
+ onError(callback: (error: Error) => void) {
141
168
  this.socket.on("error", callback);
142
169
  }
143
170
 
@@ -148,7 +175,4 @@ class CimulateCopilot {
148
175
  onDisconnect(callback: (reason: string) => void) {
149
176
  this.socket.on("disconnect", callback);
150
177
  }
151
-
152
178
  }
153
-
154
- export default CimulateCopilot;
@@ -1,6 +1,6 @@
1
1
 
2
2
  interface Cancel {
3
- eventId: string;
3
+ event_id: string;
4
4
  reason?: string;
5
5
  }
6
6
  export { Cancel };
@@ -1,6 +1,6 @@
1
1
 
2
2
  interface CommonEventFields {
3
- eventSourceId: string;
3
+ event_source_id: string;
4
4
  message: string;
5
5
  }
6
6
  export { CommonEventFields };
@@ -1,10 +1,9 @@
1
1
 
2
2
  interface CommonFields {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
9
8
  }
10
9
  export { CommonFields };
@@ -0,0 +1,7 @@
1
+ import {WorkflowMetadata} from './WorkflowMetadata';
2
+ interface CommonMetadata {
3
+ sio_session_id?: string;
4
+ session_id?: string;
5
+ workflow?: WorkflowMetadata;
6
+ }
7
+ export { CommonMetadata };
@@ -1,8 +1,7 @@
1
1
 
2
2
  interface CommonRequiredFields {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
6
  }
8
7
  export { CommonRequiredFields };
@@ -1,11 +1,11 @@
1
1
  import {ConnectAckMetadata} from './ConnectAckMetadata';
2
2
  interface ConnectAck {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- reservedStatus: number;
6
+ status: number;
8
7
  message: string;
9
8
  metadata: ConnectAckMetadata;
9
+ event_name: 'connect_ack';
10
10
  }
11
11
  export { ConnectAck };
@@ -0,0 +1,8 @@
1
+ import {ConnectAckMetadata} from './ConnectAckMetadata';
2
+ interface ConnectAckMessageFields {
3
+ status: number;
4
+ message: string;
5
+ metadata: ConnectAckMetadata;
6
+ event_name: 'connect_ack';
7
+ }
8
+ export { ConnectAckMessageFields };
@@ -0,0 +1,20 @@
1
+ import {ConnectAck} from './ConnectAck';
2
+ import {EventAck} from './EventAck';
3
+ import {FollowUp} from './FollowUp';
4
+ import {Inquiry} from './Inquiry';
5
+ import {DisplayProducts} from './DisplayProducts';
6
+ import {RefinedSearch} from './RefinedSearch';
7
+ import {Done} from './Done';
8
+ import {Error} from './Error';
9
+ import {CommonMetadata} from './CommonMetadata';
10
+ import type { ReturnedFields } from './ReturnedFields';
11
+ interface CopilotEvent<T extends object = ReturnedFields> {
12
+ id: string;
13
+ session_id: string;
14
+ name: string;
15
+ event_source_id: string;
16
+ data: ConnectAck | EventAck | FollowUp | Inquiry | DisplayProducts<T> | RefinedSearch<T> | Done | Error;
17
+ created_at: string;
18
+ metadata: CommonMetadata;
19
+ }
20
+ export { CopilotEvent };
@@ -1,6 +1,6 @@
1
- import {SearchParameters} from './SearchParameters';
1
+ import {SearchParams} from './SearchParams';
2
2
  interface CopilotSearch {
3
- searchParams: SearchParameters;
4
- userPrompt?: string;
3
+ search_params: SearchParams;
4
+ user_prompt?: string;
5
5
  }
6
6
  export { CopilotSearch };
@@ -0,0 +1,7 @@
1
+ import {CopilotSearch} from './CopilotSearch';
2
+ interface CopilotSearchSuggestion {
3
+ display_text: string;
4
+ action: 'copilot_search';
5
+ params: CopilotSearch;
6
+ }
7
+ export { CopilotSearchSuggestion };
@@ -1,11 +1,11 @@
1
-
2
- interface DisplayProducts {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
1
+ import type {ReturnedFields} from './ReturnedFields';
2
+ interface DisplayProducts<T extends object = ReturnedFields> {
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
9
- products: Map<string, any>[];
8
+ event_name: 'display_products';
9
+ products: T[];
10
10
  }
11
11
  export { DisplayProducts };
@@ -1,5 +1,6 @@
1
-
2
- interface DisplayProductsMessageFields {
3
- products: Map<string, any>[];
1
+ import type {ReturnedFields} from './ReturnedFields';
2
+ interface DisplayProductsMessageFields<T extends object = ReturnedFields> {
3
+ event_name: 'display_products';
4
+ products: T[];
4
5
  }
5
6
  export { DisplayProductsMessageFields };
package/src/model/Done.ts CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
2
  interface Done {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
8
+ event_name: 'done';
9
9
  }
10
10
  export { Done };
@@ -0,0 +1,5 @@
1
+
2
+ interface DoneMessageFields {
3
+ event_name: 'done';
4
+ }
5
+ export { DoneMessageFields };
@@ -1,12 +1,12 @@
1
1
 
2
2
  interface Error {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
9
- reservedStatus: number;
8
+ status: number;
10
9
  error: string;
10
+ event_name: 'error';
11
11
  }
12
12
  export { Error };
@@ -1,6 +1,7 @@
1
1
 
2
2
  interface ErrorMessageFields {
3
- reservedStatus: number;
3
+ status: number;
4
4
  error: string;
5
+ event_name: 'error';
5
6
  }
6
7
  export { ErrorMessageFields };
@@ -1,12 +1,20 @@
1
1
  import {CopilotSearch} from './CopilotSearch';
2
- interface EventAck {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
2
+ import {FacetedNavigation} from './FacetedNavigation';
3
+ import {Cancel} from './Cancel';
4
+ import {EventAckNames} from './EventAckNames';
5
+
6
+ type EventRequestMap = {
7
+ copilot_search_ack: CopilotSearch;
8
+ faceted_navigation_ack: FacetedNavigation;
9
+ cancel_ack: Cancel;
10
+ }
11
+
12
+ interface EventAck<T extends EventAckNames = EventAckNames> {
13
+ session_id: string;
14
+ event_id: string;
6
15
  timestamp: string;
7
- eventSourceId: string;
8
- message: string;
9
- reservedStatus: string;
10
- request: CopilotSearch;
16
+ status: string;
17
+ request: EventRequestMap[T];
18
+ event_name: T;
11
19
  }
12
20
  export { EventAck };
@@ -0,0 +1,10 @@
1
+ import {CopilotSearch} from './CopilotSearch';
2
+ import {FacetedNavigation} from './FacetedNavigation';
3
+ import {Cancel} from './Cancel';
4
+ import {EventAckNames} from './EventAckNames';
5
+ interface EventAckMessageFields {
6
+ status: string;
7
+ request: CopilotSearch | FacetedNavigation | Cancel;
8
+ event_name: EventAckNames;
9
+ }
10
+ export { EventAckMessageFields };
@@ -0,0 +1,7 @@
1
+
2
+ enum EventAckNames {
3
+ COPILOT_SEARCH_ACK = "copilot_search_ack",
4
+ FACETED_NAVIGATION_ACK = "faceted_navigation_ack",
5
+ CANCEL_ACK = "cancel_ack",
6
+ }
7
+ export { EventAckNames };
@@ -1,6 +1,6 @@
1
1
 
2
2
  interface FacetValue {
3
- reservedName?: string;
3
+ name?: string;
4
4
  count?: number;
5
5
  }
6
6
  export { FacetValue };
@@ -1,5 +1,5 @@
1
- import {SearchParameters} from './SearchParameters';
1
+ import {SearchParams} from './SearchParams';
2
2
  interface FacetedNavigation {
3
- searchParams: SearchParameters;
3
+ search_params: SearchParams;
4
4
  }
5
5
  export { FacetedNavigation };
@@ -0,0 +1,7 @@
1
+ import {FacetedNavigation} from './FacetedNavigation';
2
+ interface FacetedNavigationSuggestion {
3
+ display_text: string;
4
+ action: 'faceted_navigation';
5
+ params: FacetedNavigation;
6
+ }
7
+ export { FacetedNavigationSuggestion };
@@ -1,11 +1,12 @@
1
- import {Suggestion} from './Suggestion';
1
+ import {CopilotSearchSuggestion} from './CopilotSearchSuggestion';
2
+ import {FacetedNavigationSuggestion} from './FacetedNavigationSuggestion';
2
3
  interface FollowUp {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
4
+ session_id: string;
5
+ event_id: string;
6
6
  timestamp: string;
7
- eventSourceId: string;
7
+ event_source_id: string;
8
8
  message: string;
9
- suggestions: Suggestion[];
9
+ suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
10
+ event_name: 'follow_up';
10
11
  }
11
12
  export { FollowUp };
@@ -0,0 +1,7 @@
1
+ import {CopilotSearchSuggestion} from './CopilotSearchSuggestion';
2
+ import {FacetedNavigationSuggestion} from './FacetedNavigationSuggestion';
3
+ interface FollowUpMessageFields {
4
+ suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
5
+ event_name: 'follow_up';
6
+ }
7
+ export { FollowUpMessageFields };
@@ -1,10 +1,10 @@
1
1
 
2
2
  interface Inquiry {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
8
+ event_name: 'inquiry';
9
9
  }
10
10
  export { Inquiry };
@@ -0,0 +1,5 @@
1
+
2
+ interface InquiryMessageFields {
3
+ event_name: 'inquiry';
4
+ }
5
+ export { InquiryMessageFields };
@@ -1,12 +1,12 @@
1
1
 
2
2
  interface PartialInquiry {
3
- sessionId: string;
4
- eventId: string;
5
- eventName: string;
3
+ session_id: string;
4
+ event_id: string;
6
5
  timestamp: string;
7
- eventSourceId: string;
6
+ event_source_id: string;
8
7
  message: string;
9
- inquiryEventId: string;
8
+ inquiry_event_id: string;
10
9
  index: number;
10
+ event_name: 'partial_inquiry';
11
11
  }
12
12
  export { PartialInquiry };
@@ -1,6 +1,7 @@
1
1
 
2
2
  interface PartialInquiryMessageFields {
3
- inquiryEventId: string;
3
+ inquiry_event_id: string;
4
4
  index: number;
5
+ event_name: 'partial_inquiry';
5
6
  }
6
7
  export { PartialInquiryMessageFields };
@@ -1,15 +1,16 @@
1
- import {SearchParameters} from './SearchParameters';
1
+ import {SearchParams} from './SearchParams';
2
2
  import {Facet} from './Facet';
3
- interface RefinedSearch {
4
- sessionId: string;
5
- eventId: string;
6
- eventName: string;
3
+ import type {ReturnedFields} from './ReturnedFields';
4
+ interface RefinedSearch<T extends object = ReturnedFields> {
5
+ session_id: string;
6
+ event_id: string;
7
7
  timestamp: string;
8
- eventSourceId: string;
8
+ event_source_id: string;
9
9
  message: string;
10
- searchParams: SearchParameters;
11
- hits?: Map<string, any>[];
12
- totalHits?: number;
10
+ event_name: 'refined_search';
11
+ search_params: SearchParams;
12
+ hits?: T[];
13
+ total_hits?: number;
13
14
  facets?: Facet[];
14
15
  }
15
16
  export { RefinedSearch };
@@ -1,9 +1,11 @@
1
- import {SearchParameters} from './SearchParameters';
1
+ import {SearchParams} from './SearchParams';
2
2
  import {Facet} from './Facet';
3
- interface RefinedSearchMessageFields {
4
- searchParams: SearchParameters;
5
- hits?: Map<string, any>[];
6
- totalHits?: number;
3
+ import type {ReturnedFields} from './ReturnedFields';
4
+ interface RefinedSearchMessageFields<T extends object = ReturnedFields> {
5
+ event_name: 'refined_search';
6
+ search_params: SearchParams;
7
+ hits?: T[];
8
+ total_hits?: number;
7
9
  facets?: Facet[];
8
10
  }
9
11
  export { RefinedSearchMessageFields };
@@ -0,0 +1,4 @@
1
+ // This is added manually
2
+ type ReturnedFields<T = unknown> = Record<string, T>;
3
+
4
+ export type { ReturnedFields };
package/src/model/Root.ts CHANGED
@@ -1,54 +1,62 @@
1
1
  import {CommonRequiredFields} from './CommonRequiredFields';
2
2
  import {CommonFields} from './CommonFields';
3
+ import {CommonMetadata} from './CommonMetadata';
3
4
  import {ConnectAckMetadata} from './ConnectAckMetadata';
4
5
  import {ConnectAck} from './ConnectAck';
5
- import {SearchParameters} from './SearchParameters';
6
+ import {SearchParams} from './SearchParams';
6
7
  import {FacetValue} from './FacetValue';
7
8
  import {Facet} from './Facet';
8
9
  import {CopilotSearch} from './CopilotSearch';
9
10
  import {FacetedNavigation} from './FacetedNavigation';
11
+ import {EventAckNames} from './EventAckNames';
10
12
  import {EventAck} from './EventAck';
11
13
  import {RefinedSearch} from './RefinedSearch';
12
14
  import {DisplayProducts} from './DisplayProducts';
13
- import {Suggestion} from './Suggestion';
15
+ import {CopilotSearchSuggestion} from './CopilotSearchSuggestion';
16
+ import {FacetedNavigationSuggestion} from './FacetedNavigationSuggestion';
14
17
  import {FollowUp} from './FollowUp';
15
18
  import {PartialInquiry} from './PartialInquiry';
16
19
  import {Inquiry} from './Inquiry';
17
20
  import {Done} from './Done';
18
21
  import {Error} from './Error';
19
- import {ReservedEvent} from './ReservedEvent';
22
+ import {CopilotEvent} from './CopilotEvent';
20
23
  import {SessionData} from './SessionData';
21
24
  import {SessionInformation} from './SessionInformation';
22
- import {SessionEventInformationReply} from './SessionEventInformationReply';
23
25
  import {SessionEventStatusReply} from './SessionEventStatusReply';
24
26
  import {Cancel} from './Cancel';
27
+ import type {ReturnedFields} from './ReturnedFields';
25
28
  interface Root {
26
- commonFields?: CommonRequiredFields;
27
- commonEventFields?: CommonFields;
28
- connectAckMetadata?: ConnectAckMetadata;
29
- connectAck?: ConnectAck;
30
- searchParams?: SearchParameters;
31
- facetValue?: FacetValue;
29
+ common_fields?: CommonRequiredFields;
30
+ common_event_fields?: CommonFields;
31
+ common_metadata?: CommonMetadata;
32
+ connect_ack_metadata?: ConnectAckMetadata;
33
+ connect_ack?: ConnectAck;
34
+ search_params?: SearchParams;
35
+ facet_value?: FacetValue;
32
36
  facets?: Facet[];
33
- copilotSearch?: CopilotSearch;
34
- facetedNavigation?: FacetedNavigation;
35
- eventAck?: EventAck;
36
- refinedSearch?: RefinedSearch;
37
- displayProducts?: DisplayProducts;
38
- suggestions?: Suggestion[];
39
- followUp?: FollowUp;
40
- partialInquiry?: PartialInquiry;
37
+ copilot_search?: CopilotSearch;
38
+ faceted_navigation?: FacetedNavigation;
39
+ event_ack_names?: EventAckNames;
40
+ event_ack?: EventAck;
41
+ refined_search?: RefinedSearch;
42
+ display_products?: DisplayProducts;
43
+ copilot_search_suggestion?: CopilotSearchSuggestion;
44
+ faceted_navigation_suggestion?: FacetedNavigationSuggestion;
45
+ suggestions?: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
46
+ follow_up?: FollowUp;
47
+ partial_inquiry?: PartialInquiry;
41
48
  inquiry?: Inquiry;
42
49
  done?: Done;
43
50
  error?: Error;
44
- reservedEvent?: ReservedEvent;
45
- sessionData?: SessionData;
46
- sessionInfoReply?: SessionInformation;
47
- sessionEventsReply?: Map<string, any>[];
48
- sessionEventInfo?: string;
49
- sessionEventInfoReply?: SessionEventInformationReply;
50
- sessionEventStatus?: string;
51
- sessionEventStatusReply?: SessionEventStatusReply;
51
+ event?: CopilotEvent;
52
+ session_data?: SessionData;
53
+ session_info_reply?: SessionInformation;
54
+ session_events_reply?: CopilotEvent[];
55
+ session_event_info?: string;
56
+ session_event_info_reply?: ConnectAck | EventAck | FollowUp | Inquiry | DisplayProducts | RefinedSearch | Done | Error;
57
+ session_event_status?: string;
58
+ session_event_status_reply?: SessionEventStatusReply;
52
59
  cancel?: Cancel;
60
+ return_fields?: ReturnedFields;
53
61
  }
54
62
  export { Root };