@cimulate/copilot-sdk 3.4.0 → 3.6.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 (29) hide show
  1. package/dist/{bundle.cimulate.copilot-sdk.3d873978.esm.js → bundle.cimulate.copilot-sdk.1fbe1d17.esm.js} +2 -2
  2. package/dist/{bundle.cimulate.copilot-sdk.3d873978.esm.js.map → bundle.cimulate.copilot-sdk.1fbe1d17.esm.js.map} +1 -1
  3. package/dist/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js → bundle.cimulate.copilot-sdk.528903a1.umd.js} +2 -2
  4. package/dist/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js.map → bundle.cimulate.copilot-sdk.528903a1.umd.js.map} +1 -1
  5. package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js → bundle.cimulate.copilot-sdk.a9e69ca5.cjs.js} +2 -2
  6. package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js.map → bundle.cimulate.copilot-sdk.a9e69ca5.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 +3 -1
  14. package/dist/types/model/ConversationReset.d.ts +5 -0
  15. package/dist/types/model/ConversationResetAck.d.ts +10 -0
  16. package/dist/types/model/CopilotApiAck.d.ts +2 -1
  17. package/dist/types/model/SearchParams.d.ts +2 -0
  18. package/dist/types/model/SessionData.d.ts +2 -0
  19. package/dist/types/model/index.d.ts +3 -1
  20. package/examples/callbacks.ts +1 -1
  21. package/examples/conversationReset.ts +52 -0
  22. package/package.json +1 -1
  23. package/src/copilot.ts +18 -0
  24. package/src/model/ConversationReset.ts +6 -0
  25. package/src/model/ConversationResetAck.ts +10 -0
  26. package/src/model/CopilotApiAck.ts +2 -0
  27. package/src/model/SearchParams.ts +2 -0
  28. package/src/model/SessionData.ts +2 -0
  29. package/src/model/index.ts +3 -1
@@ -0,0 +1,10 @@
1
+ import { ConversationReset } from './ConversationReset';
2
+ interface ConversationResetAck {
3
+ name: 'conversation_reset';
4
+ request: ConversationReset;
5
+ sessionId: string;
6
+ id: string;
7
+ createdAt: string;
8
+ status: number;
9
+ }
10
+ export { ConversationResetAck };
@@ -6,4 +6,5 @@ import { CancelAck } from "./CancelAck";
6
6
  import { CopilotError } from "./CopilotError";
7
7
  import { CopilotSearchAck } from "./CopilotSearchAck";
8
8
  import { FacetedNavigationAck } from "./FacetedNavigationAck";
9
- export type CopilotAPIAck = CancelAck | CopilotSearchAck | FacetedNavigationAck | CopilotError;
9
+ import { ConversationResetAck } from "./ConversationResetAck";
10
+ export type CopilotAPIAck = CancelAck | CopilotSearchAck | ConversationResetAck | FacetedNavigationAck | CopilotError;
@@ -4,5 +4,7 @@ interface SearchParams {
4
4
  pageSize?: number;
5
5
  page?: number;
6
6
  includeFacets?: boolean;
7
+ catalogSegment?: string;
8
+ pricebooks?: string[];
7
9
  }
8
10
  export { SearchParams };
@@ -1,4 +1,6 @@
1
1
  interface SessionData {
2
2
  eventSourceMap?: Record<string, string[]>;
3
+ conversationIds?: string[];
4
+ activeConversationId?: string;
3
5
  }
4
6
  export { SessionData };
@@ -6,8 +6,10 @@ export * from './CommonRequiredFields';
6
6
  export * from './ConnectAck';
7
7
  export * from './ConnectAckMetadata';
8
8
  export * from './ConnectError';
9
- export * from './CopilotAPIEvent';
9
+ export * from './ConversationReset';
10
+ export * from './ConversationResetAck';
10
11
  export * from './CopilotApiAck';
12
+ export * from './CopilotAPIEvent';
11
13
  export * from './CopilotError';
12
14
  export * from './CopilotEvent';
13
15
  export * from './CopilotSearch';
@@ -16,7 +16,7 @@ async function main() {
16
16
 
17
17
  try {
18
18
  const search = await copilot.search({
19
- searchParams: { query: "laptops" },
19
+ searchParams: { query: "starlink Mini", catalogSegment: "WestMarine", pricebooks: ["wm-regular", "wm-sale-retail"] },
20
20
  });
21
21
  console.log("Search request ack:", search.result);
22
22
 
@@ -0,0 +1,52 @@
1
+ import { CimulateCopilot } from "@cimulate/copilot-sdk";
2
+
3
+
4
+ async function main() {
5
+ const copilot = new CimulateCopilot({
6
+ apiKey: "API_KEY",
7
+ // Alternatively, a JWT token of the form `Bearer {token}` can be used for authentication.
8
+ // apiToken: "token123",
9
+ baseUrl: "https://qa.copilot.search.cimulate.ai",
10
+ });
11
+
12
+ // Register handlers.
13
+ const connectAckHandler = copilot.on("connect_ack", function connectAck(event) {
14
+ console.log("Connect Ack: ", event);
15
+ });
16
+
17
+ const errorHandler = copilot.on("error", function errorEvent(event) {
18
+ console.error("Error received: ", event);
19
+ });
20
+
21
+ const connectErrorHandler = copilot.on("connect_error", function errorEvent(error) {
22
+ console.error("Error message received: ", error.message);
23
+ });
24
+
25
+ console.log("Establish a new connection");
26
+ copilot.connect();
27
+
28
+ console.log("Reset conversaton with empty payload");
29
+ const response = await copilot.conversationResetRequest({});
30
+ console.log("Conversation reset response: ", response);
31
+
32
+ console.log("Reset conversaton with empty payload");
33
+ const responseWithUserReason = await copilot.conversationResetRequest({
34
+ reason: "Clear the copilot context."
35
+ });
36
+ console.log("Conversation reset response: ", responseWithUserReason);
37
+
38
+ const sessionData = await copilot.requestSessionInformation();
39
+ console.log("Conversations related to this session: ", sessionData.data.conversationIds);
40
+ console.log("Current active conversation in this session: ", sessionData.data.activeConversationId);
41
+
42
+ console.log("Disconnect");
43
+ copilot.disconnect();
44
+
45
+ console.log("De-register handler");
46
+ copilot.off("connect_ack", connectAckHandler);
47
+ copilot.off("error", errorHandler);
48
+ copilot.off("connect_error", connectErrorHandler);
49
+
50
+ }
51
+
52
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-sdk",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "A lightweight API client SDK for Cimulate Copilot",
5
5
  "files": [
6
6
  "dist/**",
package/src/copilot.ts CHANGED
@@ -15,6 +15,8 @@ import type {
15
15
  FacetedNavigationAck,
16
16
  ReturnedFields,
17
17
  SessionInformation,
18
+ ConversationReset,
19
+ ConversationResetAck,
18
20
  } from "./model";
19
21
  import CimulateCopilotException from "./exceptions";
20
22
  import { SnakeCaseParser } from "./parser";
@@ -251,6 +253,22 @@ export default class CimulateCopilot<
251
253
  );
252
254
  }
253
255
 
256
+ async conversationResetRequest(args: ConversationReset): Promise<CopilotResult<T, ConversationResetAck>>;
257
+ async conversationResetRequest(
258
+ args: ConversationReset,
259
+ callback?: (event: ConversationResetAck) => void
260
+ ): Promise<void>;
261
+ conversationResetRequest(
262
+ args: ConversationReset,
263
+ callback?: (event: ConversationResetAck) => void
264
+ ): Promise<CopilotResult<T, ConversationResetAck> | void> {
265
+ return this.asyncResponse<ConversationReset, ConversationResetAck>(
266
+ "conversation_reset",
267
+ args,
268
+ callback
269
+ );
270
+ }
271
+
254
272
  async requestSessionInformation(): Promise<
255
273
  CopilotResult<T, SessionInformation>
256
274
  >;
@@ -0,0 +1,6 @@
1
+
2
+ interface ConversationReset {
3
+ conversationId?: string;
4
+ reason?: string;
5
+ }
6
+ export { ConversationReset };
@@ -0,0 +1,10 @@
1
+ import { ConversationReset } from './ConversationReset';
2
+ interface ConversationResetAck {
3
+ name: 'conversation_reset';
4
+ request: ConversationReset;
5
+ sessionId: string;
6
+ id: string;
7
+ createdAt: string;
8
+ status: number;
9
+ }
10
+ export { ConversationResetAck };
@@ -6,9 +6,11 @@ import { CancelAck } from "./CancelAck";
6
6
  import { CopilotError } from "./CopilotError";
7
7
  import { CopilotSearchAck } from "./CopilotSearchAck";
8
8
  import { FacetedNavigationAck } from "./FacetedNavigationAck";
9
+ import { ConversationResetAck } from "./ConversationResetAck";
9
10
 
10
11
  export type CopilotAPIAck =
11
12
  | CancelAck
12
13
  | CopilotSearchAck
14
+ | ConversationResetAck
13
15
  | FacetedNavigationAck
14
16
  | CopilotError;
@@ -5,5 +5,7 @@ interface SearchParams {
5
5
  pageSize?: number;
6
6
  page?: number;
7
7
  includeFacets?: boolean;
8
+ catalogSegment?: string;
9
+ pricebooks?: string[];
8
10
  }
9
11
  export { SearchParams };
@@ -1,5 +1,7 @@
1
1
 
2
2
  interface SessionData {
3
3
  eventSourceMap?: Record<string, string[]>;
4
+ conversationIds?: string[];
5
+ activeConversationId?: string;
4
6
  }
5
7
  export { SessionData };
@@ -6,8 +6,10 @@ export * from './CommonRequiredFields';
6
6
  export * from './ConnectAck';
7
7
  export * from './ConnectAckMetadata';
8
8
  export * from './ConnectError';
9
- export * from './CopilotAPIEvent';
9
+ export * from './ConversationReset';
10
+ export * from './ConversationResetAck';
10
11
  export * from './CopilotApiAck';
12
+ export * from './CopilotAPIEvent';
11
13
  export * from './CopilotError';
12
14
  export * from './CopilotEvent';
13
15
  export * from './CopilotSearch';