@cimulate/copilot-sdk 2.2.1 → 3.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.
Files changed (51) hide show
  1. package/dist/{bundle.cimulate.copilot-sdk.437a3f0b.esm.js → bundle.cimulate.copilot-sdk.1891f5f7.esm.js} +2 -2
  2. package/dist/{bundle.cimulate.copilot-sdk.437a3f0b.esm.js.map → bundle.cimulate.copilot-sdk.1891f5f7.esm.js.map} +1 -1
  3. package/dist/{bundle.cimulate.copilot-sdk.429ff346.umd.js → bundle.cimulate.copilot-sdk.a321ac32.umd.js} +2 -2
  4. package/dist/{bundle.cimulate.copilot-sdk.1f1847ab.cjs.js.map → bundle.cimulate.copilot-sdk.a321ac32.umd.js.map} +1 -1
  5. package/dist/{bundle.cimulate.copilot-sdk.1f1847ab.cjs.js → bundle.cimulate.copilot-sdk.c98a0a82.cjs.js} +2 -2
  6. package/dist/{bundle.cimulate.copilot-sdk.429ff346.umd.js.map → bundle.cimulate.copilot-sdk.c98a0a82.cjs.js.map} +1 -1
  7. package/dist/index.cjs.js +1 -1
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.esm.js +1 -1
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.umd.js +1 -1
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/copilot.d.ts +9 -9
  14. package/dist/types/model/CancelAck.d.ts +3 -3
  15. package/dist/types/model/CommonFields.d.ts +2 -2
  16. package/dist/types/model/CommonRequiredFields.d.ts +2 -2
  17. package/dist/types/model/ConnectAck.d.ts +3 -3
  18. package/dist/types/model/CopilotAPIEvent.d.ts +1 -1
  19. package/dist/types/model/CopilotSearchAck.d.ts +3 -3
  20. package/dist/types/model/DisplayProducts.d.ts +3 -3
  21. package/dist/types/model/Done.d.ts +3 -3
  22. package/dist/types/model/Error.d.ts +3 -3
  23. package/dist/types/model/FacetedNavigationAck.d.ts +3 -3
  24. package/dist/types/model/FollowUp.d.ts +3 -3
  25. package/dist/types/model/Inquiry.d.ts +4 -3
  26. package/dist/types/model/OperationAck.d.ts +3 -3
  27. package/dist/types/model/PartialInquiry.d.ts +4 -4
  28. package/dist/types/model/RefinedSearch.d.ts +3 -3
  29. package/dist/types/model/SessionData.d.ts +1 -4
  30. package/dist/types/model/SessionInformation.d.ts +7 -5
  31. package/examples/callbacks.ts +3 -2
  32. package/examples/generator.ts +1 -1
  33. package/package.json +1 -1
  34. package/src/copilot.ts +17 -17
  35. package/src/model/CancelAck.ts +3 -3
  36. package/src/model/CommonFields.ts +2 -2
  37. package/src/model/CommonRequiredFields.ts +2 -2
  38. package/src/model/ConnectAck.ts +3 -3
  39. package/src/model/CopilotAPIEvent.ts +1 -1
  40. package/src/model/CopilotSearchAck.ts +3 -3
  41. package/src/model/DisplayProducts.ts +3 -3
  42. package/src/model/Done.ts +3 -3
  43. package/src/model/Error.ts +3 -3
  44. package/src/model/FacetedNavigationAck.ts +3 -3
  45. package/src/model/FollowUp.ts +3 -3
  46. package/src/model/Inquiry.ts +4 -3
  47. package/src/model/OperationAck.ts +3 -3
  48. package/src/model/PartialInquiry.ts +4 -4
  49. package/src/model/RefinedSearch.ts +3 -3
  50. package/src/model/SessionData.ts +1 -4
  51. package/src/model/SessionInformation.ts +7 -6
@@ -1,11 +1,11 @@
1
1
  interface Error {
2
2
  sessionId: string;
3
- eventId: string;
4
- timestamp: string;
3
+ id: string;
4
+ createdAt: string;
5
5
  eventSourceId: string;
6
6
  message: string;
7
7
  status: number;
8
8
  error: string;
9
- eventName: 'error';
9
+ name: 'error';
10
10
  }
11
11
  export { Error };
@@ -1,10 +1,10 @@
1
1
  import { FacetedNavigation } from './FacetedNavigation';
2
2
  interface FacetedNavigationAck {
3
- eventName: 'faceted_navigation';
3
+ name: 'faceted_navigation';
4
4
  request: FacetedNavigation;
5
5
  sessionId: string;
6
- eventId: string;
7
- timestamp: string;
6
+ id: string;
7
+ createdAt: string;
8
8
  status: string;
9
9
  }
10
10
  export { FacetedNavigationAck };
@@ -2,11 +2,11 @@ import { CopilotSearchSuggestion } from './CopilotSearchSuggestion';
2
2
  import { FacetedNavigationSuggestion } from './FacetedNavigationSuggestion';
3
3
  interface FollowUp {
4
4
  sessionId: string;
5
- eventId: string;
6
- timestamp: string;
5
+ id: string;
6
+ createdAt: string;
7
7
  eventSourceId: string;
8
8
  message: string;
9
9
  suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
10
- eventName: 'follow_up';
10
+ name: 'follow_up';
11
11
  }
12
12
  export { FollowUp };
@@ -1,9 +1,10 @@
1
1
  interface Inquiry {
2
2
  sessionId: string;
3
- eventId: string;
4
- timestamp: string;
3
+ id: string;
4
+ createdAt: string;
5
5
  eventSourceId: string;
6
6
  message: string;
7
- eventName: 'inquiry';
7
+ name: 'inquiry';
8
+ inquiryLinkId: string;
8
9
  }
9
10
  export { Inquiry };
@@ -1,8 +1,8 @@
1
1
  interface OperationAck {
2
2
  sessionId: string;
3
- eventId: string;
4
- timestamp: string;
5
- eventName: string;
3
+ id: string;
4
+ createdAt: string;
5
+ name: string;
6
6
  status: string;
7
7
  request: any;
8
8
  }
@@ -1,11 +1,11 @@
1
1
  interface PartialInquiry {
2
2
  sessionId: string;
3
- eventId: string;
4
- timestamp: string;
3
+ id: string;
4
+ createdAt: string;
5
5
  eventSourceId: string;
6
6
  message: string;
7
- inquiryEventId: string;
7
+ inquiryLinkId: string;
8
8
  index: number;
9
- eventName: 'partial_inquiry';
9
+ name: 'partial_inquiry';
10
10
  }
11
11
  export { PartialInquiry };
@@ -3,11 +3,11 @@ import { ReturnedFields } from "./ReturnedFields";
3
3
  import { SearchParams } from './SearchParams';
4
4
  interface RefinedSearch<TReturnedFields extends ReturnedFields = ReturnedFields> {
5
5
  sessionId: string;
6
- eventId: string;
7
- timestamp: string;
6
+ id: string;
7
+ createdAt: string;
8
8
  eventSourceId: string;
9
9
  message: string;
10
- eventName: 'refined_search';
10
+ name: 'refined_search';
11
11
  searchParams: SearchParams;
12
12
  hits?: TReturnedFields;
13
13
  totalHits?: number;
@@ -1,7 +1,4 @@
1
- import { CopilotEvent } from './CopilotEvent';
2
- import { ReturnedFields } from "./ReturnedFields";
3
- interface SessionData<TReturnedFields extends ReturnedFields = ReturnedFields> {
4
- events?: Record<string, CopilotEvent<TReturnedFields>>;
1
+ interface SessionData {
5
2
  eventSourceMap?: Record<string, string[]>;
6
3
  }
7
4
  export { SessionData };
@@ -1,10 +1,12 @@
1
- import { ReturnedFields } from "./ReturnedFields";
1
+ import { CommonMetadata } from './CommonMetadata';
2
2
  import { SessionData } from './SessionData';
3
- interface SessionInformation<TReturnedFields extends ReturnedFields = ReturnedFields> {
4
- sessionId?: string;
3
+ interface SessionInformation {
4
+ id?: string;
5
5
  createdAt?: string;
6
- lastActiveAt?: string;
6
+ lastUpdatedAt?: string;
7
7
  status?: string;
8
- data?: SessionData<TReturnedFields>;
8
+ ttlInMinutes?: number;
9
+ data?: SessionData;
10
+ metadata?: CommonMetadata;
9
11
  }
10
12
  export { SessionInformation };
@@ -15,15 +15,16 @@ async function main() {
15
15
  });
16
16
 
17
17
  const followUp = copilot.on("follow_up", function followup(event) {
18
- if (event.eventSourceId == search.result.eventId) {
18
+ if (event.eventSourceId == search.result.id) {
19
19
  event.suggestions.forEach((s) => console.log(s.displayText));
20
20
  }
21
21
  });
22
22
 
23
23
  copilot.on("done", function done(event) {
24
- if (event.eventSourceId == search.result.eventId) {
24
+ if (event.eventSourceId == search.result.id) {
25
25
  copilot.off("follow_up", followUp);
26
26
  copilot.off("done", done);
27
+ console.log("De-registered event listeners!");
27
28
  }
28
29
  });
29
30
  }
@@ -13,7 +13,7 @@ async function main() {
13
13
  });
14
14
 
15
15
  for await (const event of search.events) {
16
- switch (event.eventName) {
16
+ switch (event.name) {
17
17
  case "follow_up":
18
18
  event.suggestions.forEach((event) => console.log(event.displayText));
19
19
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-sdk",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
4
  "description": "A lightweight API client SDK for Cimulate Copilot",
5
5
  "files": [
6
6
  "dist/**",
package/src/copilot.ts CHANGED
@@ -161,43 +161,43 @@ export default class CimulateCopilot<
161
161
  }
162
162
 
163
163
  async requestSessionInformation(): Promise<
164
- CopilotResult<T, SessionInformation<T>>
164
+ CopilotResult<T, SessionInformation>
165
165
  >;
166
166
  async requestSessionInformation(
167
- callback?: (sessionInformation: SessionInformation<T>) => void
167
+ callback?: (sessionInformation: SessionInformation) => void
168
168
  ): Promise<void>;
169
169
  async requestSessionInformation(
170
- callback?: (sessionInformation: SessionInformation<T>) => void
171
- ): Promise<CopilotResult<T, SessionInformation<T>> | void> {
170
+ callback?: (sessionInformation: SessionInformation) => void
171
+ ): Promise<CopilotResult<T, SessionInformation> | void> {
172
172
  return new Promise((resolve) => {
173
- this.socket.emit("session_info", (response: SessionInformation<T>) => {
173
+ this.socket.emit("session_info", (response: SessionInformation) => {
174
174
  if (callback) callback(response);
175
175
  // TODO - error handling
176
- resolve(response as CopilotResult<T, SessionInformation<T>>);
176
+ resolve(response as CopilotResult<T, SessionInformation>);
177
177
  });
178
178
  });
179
179
  }
180
180
 
181
181
  on<E extends CopilotEventName>(
182
- eventName: E,
183
- handler: (event: Extract<CopilotAPIEvent<T>, { eventName: E }>) => void
182
+ name: E,
183
+ handler: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
184
184
  ) {
185
- this.socket.on<CopilotEventName>(eventName, handler);
185
+ this.socket.on<CopilotEventName>(name, handler);
186
186
  return handler;
187
187
  }
188
188
 
189
189
  once<E extends CopilotEventName>(
190
- eventName: E,
191
- handler: (event: Extract<CopilotAPIEvent<T>, { eventName: E }>) => void
190
+ name: E,
191
+ handler: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
192
192
  ) {
193
- this.socket.once<CopilotEventName>(eventName, handler);
193
+ this.socket.once<CopilotEventName>(name, handler);
194
194
  }
195
195
 
196
196
  off<E extends CopilotEventName>(
197
- eventName?: E,
198
- handler?: (event: Extract<CopilotAPIEvent<T>, { eventName: E }>) => void
197
+ name?: E,
198
+ handler?: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
199
199
  ) {
200
- this.socket.off(eventName, handler as any);
200
+ this.socket.off(name, handler as any);
201
201
  }
202
202
 
203
203
  disconnect() {
@@ -225,7 +225,7 @@ export default class CimulateCopilot<
225
225
  event: string,
226
226
  payload: Exclude<CopilotAPIEvent<T>, ConnectAck>
227
227
  ) => {
228
- if (payload.eventName == "done") cancel();
228
+ if (payload.name == "done") cancel();
229
229
  if (payload.eventSourceId == eventSourceId) emit(payload);
230
230
  };
231
231
 
@@ -239,7 +239,7 @@ export default class CimulateCopilot<
239
239
  const result: A = await new Promise((resolve) =>
240
240
  // TODO - error handling
241
241
  this.socket.emit(operation, payload, (ack: A) => {
242
- eventSourceId = ack?.eventId;
242
+ eventSourceId = ack?.id;
243
243
  resolve(ack);
244
244
  })
245
245
  );
@@ -1,10 +1,10 @@
1
1
  import { Cancel } from './Cancel';
2
2
  interface CancelAck {
3
- eventName: 'cancel';
3
+ name: 'cancel';
4
4
  request: Cancel;
5
5
  sessionId: string;
6
- eventId: string;
7
- timestamp: string;
6
+ id: string;
7
+ createdAt: string;
8
8
  status: string;
9
9
  }
10
10
  export { CancelAck };
@@ -1,8 +1,8 @@
1
1
 
2
2
  interface CommonFields {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  eventSourceId: string;
7
7
  message: string;
8
8
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
  interface CommonRequiredFields {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  }
7
7
  export { CommonRequiredFields };
@@ -1,11 +1,11 @@
1
1
  import { ConnectAckMetadata } from './ConnectAckMetadata';
2
2
  interface ConnectAck {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  status: number;
7
7
  message: string;
8
8
  metadata: ConnectAckMetadata;
9
- eventName: 'connect_ack';
9
+ name: 'connect_ack';
10
10
  }
11
11
  export { ConnectAck };
@@ -20,4 +20,4 @@ export type CopilotAPIEvent<
20
20
  | PartialInquiry
21
21
  | RefinedSearch<TReturnedFields>;
22
22
 
23
- export type CopilotEventName = CopilotAPIEvent["eventName"];
23
+ export type CopilotEventName = CopilotAPIEvent["name"];
@@ -1,10 +1,10 @@
1
1
  import { CopilotSearch } from './CopilotSearch';
2
2
  interface CopilotSearchAck {
3
- eventName: 'copilot_search';
3
+ name: 'copilot_search';
4
4
  request: CopilotSearch;
5
5
  sessionId: string;
6
- eventId: string;
7
- timestamp: string;
6
+ id: string;
7
+ createdAt: string;
8
8
  status: string;
9
9
  }
10
10
  export { CopilotSearchAck };
@@ -2,11 +2,11 @@ import { ReturnedFields } from "./ReturnedFields";
2
2
 
3
3
  interface DisplayProducts<TReturnedFields extends ReturnedFields = ReturnedFields> {
4
4
  sessionId: string;
5
- eventId: string;
6
- timestamp: string;
5
+ id: string;
6
+ createdAt: string;
7
7
  eventSourceId: string;
8
8
  message: string;
9
- eventName: 'display_products';
9
+ name: 'display_products';
10
10
  products: TReturnedFields;
11
11
  }
12
12
  export { DisplayProducts };
package/src/model/Done.ts CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
2
  interface Done {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  eventSourceId: string;
7
7
  message: string;
8
- eventName: 'done';
8
+ name: 'done';
9
9
  }
10
10
  export { Done };
@@ -1,12 +1,12 @@
1
1
 
2
2
  interface Error {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  eventSourceId: string;
7
7
  message: string;
8
8
  status: number;
9
9
  error: string;
10
- eventName: 'error';
10
+ name: 'error';
11
11
  }
12
12
  export { Error };
@@ -1,10 +1,10 @@
1
1
  import { FacetedNavigation } from './FacetedNavigation';
2
2
  interface FacetedNavigationAck {
3
- eventName: 'faceted_navigation';
3
+ name: 'faceted_navigation';
4
4
  request: FacetedNavigation;
5
5
  sessionId: string;
6
- eventId: string;
7
- timestamp: string;
6
+ id: string;
7
+ createdAt: string;
8
8
  status: string;
9
9
  }
10
10
  export { FacetedNavigationAck };
@@ -2,11 +2,11 @@ import { CopilotSearchSuggestion } from './CopilotSearchSuggestion';
2
2
  import { FacetedNavigationSuggestion } from './FacetedNavigationSuggestion';
3
3
  interface FollowUp {
4
4
  sessionId: string;
5
- eventId: string;
6
- timestamp: string;
5
+ id: string;
6
+ createdAt: string;
7
7
  eventSourceId: string;
8
8
  message: string;
9
9
  suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
10
- eventName: 'follow_up';
10
+ name: 'follow_up';
11
11
  }
12
12
  export { FollowUp };
@@ -1,10 +1,11 @@
1
1
 
2
2
  interface Inquiry {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  eventSourceId: string;
7
7
  message: string;
8
- eventName: 'inquiry';
8
+ name: 'inquiry';
9
+ inquiryLinkId: string;
9
10
  }
10
11
  export { Inquiry };
@@ -1,9 +1,9 @@
1
1
 
2
2
  interface OperationAck {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
6
- eventName: string;
4
+ id: string;
5
+ createdAt: string;
6
+ name: string;
7
7
  status: string;
8
8
  request: any;
9
9
  }
@@ -1,12 +1,12 @@
1
1
 
2
2
  interface PartialInquiry {
3
3
  sessionId: string;
4
- eventId: string;
5
- timestamp: string;
4
+ id: string;
5
+ createdAt: string;
6
6
  eventSourceId: string;
7
7
  message: string;
8
- inquiryEventId: string;
8
+ inquiryLinkId: string;
9
9
  index: number;
10
- eventName: 'partial_inquiry';
10
+ name: 'partial_inquiry';
11
11
  }
12
12
  export { PartialInquiry };
@@ -4,11 +4,11 @@ import { SearchParams } from './SearchParams';
4
4
 
5
5
  interface RefinedSearch<TReturnedFields extends ReturnedFields = ReturnedFields> {
6
6
  sessionId: string;
7
- eventId: string;
8
- timestamp: string;
7
+ id: string;
8
+ createdAt: string;
9
9
  eventSourceId: string;
10
10
  message: string;
11
- eventName: 'refined_search';
11
+ name: 'refined_search';
12
12
  searchParams: SearchParams;
13
13
  hits?: TReturnedFields;
14
14
  totalHits?: number;
@@ -1,8 +1,5 @@
1
- import { CopilotEvent } from './CopilotEvent';
2
- import { ReturnedFields } from "./ReturnedFields";
3
1
 
4
- interface SessionData<TReturnedFields extends ReturnedFields = ReturnedFields> {
5
- events?: Record<string, CopilotEvent<TReturnedFields>>;
2
+ interface SessionData {
6
3
  eventSourceMap?: Record<string, string[]>;
7
4
  }
8
5
  export { SessionData };
@@ -1,11 +1,12 @@
1
- import { ReturnedFields } from "./ReturnedFields";
1
+ import { CommonMetadata } from './CommonMetadata';
2
2
  import { SessionData } from './SessionData';
3
-
4
- interface SessionInformation<TReturnedFields extends ReturnedFields = ReturnedFields> {
5
- sessionId?: string;
3
+ interface SessionInformation {
4
+ id?: string;
6
5
  createdAt?: string;
7
- lastActiveAt?: string;
6
+ lastUpdatedAt?: string;
8
7
  status?: string;
9
- data?: SessionData<TReturnedFields>;
8
+ ttlInMinutes?: number;
9
+ data?: SessionData;
10
+ metadata?: CommonMetadata;
10
11
  }
11
12
  export { SessionInformation };