@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.
- package/dist/{bundle.cimulate.copilot-sdk.437a3f0b.esm.js → bundle.cimulate.copilot-sdk.1891f5f7.esm.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.437a3f0b.esm.js.map → bundle.cimulate.copilot-sdk.1891f5f7.esm.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.429ff346.umd.js → bundle.cimulate.copilot-sdk.a321ac32.umd.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.1f1847ab.cjs.js.map → bundle.cimulate.copilot-sdk.a321ac32.umd.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.1f1847ab.cjs.js → bundle.cimulate.copilot-sdk.c98a0a82.cjs.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.429ff346.umd.js.map → bundle.cimulate.copilot-sdk.c98a0a82.cjs.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/copilot.d.ts +9 -9
- package/dist/types/model/CancelAck.d.ts +3 -3
- package/dist/types/model/CommonFields.d.ts +2 -2
- package/dist/types/model/CommonRequiredFields.d.ts +2 -2
- package/dist/types/model/ConnectAck.d.ts +3 -3
- package/dist/types/model/CopilotAPIEvent.d.ts +1 -1
- package/dist/types/model/CopilotSearchAck.d.ts +3 -3
- package/dist/types/model/DisplayProducts.d.ts +3 -3
- package/dist/types/model/Done.d.ts +3 -3
- package/dist/types/model/Error.d.ts +3 -3
- package/dist/types/model/FacetedNavigationAck.d.ts +3 -3
- package/dist/types/model/FollowUp.d.ts +3 -3
- package/dist/types/model/Inquiry.d.ts +4 -3
- package/dist/types/model/OperationAck.d.ts +3 -3
- package/dist/types/model/PartialInquiry.d.ts +4 -4
- package/dist/types/model/RefinedSearch.d.ts +3 -3
- package/dist/types/model/SessionData.d.ts +1 -4
- package/dist/types/model/SessionInformation.d.ts +7 -5
- package/examples/callbacks.ts +3 -2
- package/examples/generator.ts +1 -1
- package/package.json +1 -1
- package/src/copilot.ts +17 -17
- package/src/model/CancelAck.ts +3 -3
- package/src/model/CommonFields.ts +2 -2
- package/src/model/CommonRequiredFields.ts +2 -2
- package/src/model/ConnectAck.ts +3 -3
- package/src/model/CopilotAPIEvent.ts +1 -1
- package/src/model/CopilotSearchAck.ts +3 -3
- package/src/model/DisplayProducts.ts +3 -3
- package/src/model/Done.ts +3 -3
- package/src/model/Error.ts +3 -3
- package/src/model/FacetedNavigationAck.ts +3 -3
- package/src/model/FollowUp.ts +3 -3
- package/src/model/Inquiry.ts +4 -3
- package/src/model/OperationAck.ts +3 -3
- package/src/model/PartialInquiry.ts +4 -4
- package/src/model/RefinedSearch.ts +3 -3
- package/src/model/SessionData.ts +1 -4
- package/src/model/SessionInformation.ts +7 -6
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
interface Error {
|
|
2
2
|
sessionId: string;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
id: string;
|
|
4
|
+
createdAt: string;
|
|
5
5
|
eventSourceId: string;
|
|
6
6
|
message: string;
|
|
7
7
|
status: number;
|
|
8
8
|
error: string;
|
|
9
|
-
|
|
9
|
+
name: 'error';
|
|
10
10
|
}
|
|
11
11
|
export { Error };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FacetedNavigation } from './FacetedNavigation';
|
|
2
2
|
interface FacetedNavigationAck {
|
|
3
|
-
|
|
3
|
+
name: 'faceted_navigation';
|
|
4
4
|
request: FacetedNavigation;
|
|
5
5
|
sessionId: string;
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
createdAt: string;
|
|
7
7
|
eventSourceId: string;
|
|
8
8
|
message: string;
|
|
9
9
|
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
|
|
10
|
-
|
|
10
|
+
name: 'follow_up';
|
|
11
11
|
}
|
|
12
12
|
export { FollowUp };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
interface PartialInquiry {
|
|
2
2
|
sessionId: string;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
id: string;
|
|
4
|
+
createdAt: string;
|
|
5
5
|
eventSourceId: string;
|
|
6
6
|
message: string;
|
|
7
|
-
|
|
7
|
+
inquiryLinkId: string;
|
|
8
8
|
index: number;
|
|
9
|
-
|
|
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
|
-
|
|
7
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: string;
|
|
8
8
|
eventSourceId: string;
|
|
9
9
|
message: string;
|
|
10
|
-
|
|
10
|
+
name: 'refined_search';
|
|
11
11
|
searchParams: SearchParams;
|
|
12
12
|
hits?: TReturnedFields;
|
|
13
13
|
totalHits?: number;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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 {
|
|
1
|
+
import { CommonMetadata } from './CommonMetadata';
|
|
2
2
|
import { SessionData } from './SessionData';
|
|
3
|
-
interface SessionInformation
|
|
4
|
-
|
|
3
|
+
interface SessionInformation {
|
|
4
|
+
id?: string;
|
|
5
5
|
createdAt?: string;
|
|
6
|
-
|
|
6
|
+
lastUpdatedAt?: string;
|
|
7
7
|
status?: string;
|
|
8
|
-
|
|
8
|
+
ttlInMinutes?: number;
|
|
9
|
+
data?: SessionData;
|
|
10
|
+
metadata?: CommonMetadata;
|
|
9
11
|
}
|
|
10
12
|
export { SessionInformation };
|
package/examples/callbacks.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
}
|
package/examples/generator.ts
CHANGED
package/package.json
CHANGED
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
|
|
164
|
+
CopilotResult<T, SessionInformation>
|
|
165
165
|
>;
|
|
166
166
|
async requestSessionInformation(
|
|
167
|
-
callback?: (sessionInformation: SessionInformation
|
|
167
|
+
callback?: (sessionInformation: SessionInformation) => void
|
|
168
168
|
): Promise<void>;
|
|
169
169
|
async requestSessionInformation(
|
|
170
|
-
callback?: (sessionInformation: SessionInformation
|
|
171
|
-
): Promise<CopilotResult<T, SessionInformation
|
|
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
|
|
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
|
|
176
|
+
resolve(response as CopilotResult<T, SessionInformation>);
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
on<E extends CopilotEventName>(
|
|
182
|
-
|
|
183
|
-
handler: (event: Extract<CopilotAPIEvent<T>, {
|
|
182
|
+
name: E,
|
|
183
|
+
handler: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
|
|
184
184
|
) {
|
|
185
|
-
this.socket.on<CopilotEventName>(
|
|
185
|
+
this.socket.on<CopilotEventName>(name, handler);
|
|
186
186
|
return handler;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
once<E extends CopilotEventName>(
|
|
190
|
-
|
|
191
|
-
handler: (event: Extract<CopilotAPIEvent<T>, {
|
|
190
|
+
name: E,
|
|
191
|
+
handler: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
|
|
192
192
|
) {
|
|
193
|
-
this.socket.once<CopilotEventName>(
|
|
193
|
+
this.socket.once<CopilotEventName>(name, handler);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
off<E extends CopilotEventName>(
|
|
197
|
-
|
|
198
|
-
handler?: (event: Extract<CopilotAPIEvent<T>, {
|
|
197
|
+
name?: E,
|
|
198
|
+
handler?: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
|
|
199
199
|
) {
|
|
200
|
-
this.socket.off(
|
|
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.
|
|
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?.
|
|
242
|
+
eventSourceId = ack?.id;
|
|
243
243
|
resolve(ack);
|
|
244
244
|
})
|
|
245
245
|
);
|
package/src/model/CancelAck.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Cancel } from './Cancel';
|
|
2
2
|
interface CancelAck {
|
|
3
|
-
|
|
3
|
+
name: 'cancel';
|
|
4
4
|
request: Cancel;
|
|
5
5
|
sessionId: string;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: string;
|
|
8
8
|
status: string;
|
|
9
9
|
}
|
|
10
10
|
export { CancelAck };
|
package/src/model/ConnectAck.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ConnectAckMetadata } from './ConnectAckMetadata';
|
|
2
2
|
interface ConnectAck {
|
|
3
3
|
sessionId: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
6
|
status: number;
|
|
7
7
|
message: string;
|
|
8
8
|
metadata: ConnectAckMetadata;
|
|
9
|
-
|
|
9
|
+
name: 'connect_ack';
|
|
10
10
|
}
|
|
11
11
|
export { ConnectAck };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CopilotSearch } from './CopilotSearch';
|
|
2
2
|
interface CopilotSearchAck {
|
|
3
|
-
|
|
3
|
+
name: 'copilot_search';
|
|
4
4
|
request: CopilotSearch;
|
|
5
5
|
sessionId: string;
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
createdAt: string;
|
|
7
7
|
eventSourceId: string;
|
|
8
8
|
message: string;
|
|
9
|
-
|
|
9
|
+
name: 'display_products';
|
|
10
10
|
products: TReturnedFields;
|
|
11
11
|
}
|
|
12
12
|
export { DisplayProducts };
|
package/src/model/Done.ts
CHANGED
package/src/model/Error.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
interface Error {
|
|
3
3
|
sessionId: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
6
|
eventSourceId: string;
|
|
7
7
|
message: string;
|
|
8
8
|
status: number;
|
|
9
9
|
error: string;
|
|
10
|
-
|
|
10
|
+
name: 'error';
|
|
11
11
|
}
|
|
12
12
|
export { Error };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FacetedNavigation } from './FacetedNavigation';
|
|
2
2
|
interface FacetedNavigationAck {
|
|
3
|
-
|
|
3
|
+
name: 'faceted_navigation';
|
|
4
4
|
request: FacetedNavigation;
|
|
5
5
|
sessionId: string;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: string;
|
|
8
8
|
status: string;
|
|
9
9
|
}
|
|
10
10
|
export { FacetedNavigationAck };
|
package/src/model/FollowUp.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { CopilotSearchSuggestion } from './CopilotSearchSuggestion';
|
|
|
2
2
|
import { FacetedNavigationSuggestion } from './FacetedNavigationSuggestion';
|
|
3
3
|
interface FollowUp {
|
|
4
4
|
sessionId: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
createdAt: string;
|
|
7
7
|
eventSourceId: string;
|
|
8
8
|
message: string;
|
|
9
9
|
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
|
|
10
|
-
|
|
10
|
+
name: 'follow_up';
|
|
11
11
|
}
|
|
12
12
|
export { FollowUp };
|
package/src/model/Inquiry.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
interface Inquiry {
|
|
3
3
|
sessionId: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
6
|
eventSourceId: string;
|
|
7
7
|
message: string;
|
|
8
|
-
|
|
8
|
+
name: 'inquiry';
|
|
9
|
+
inquiryLinkId: string;
|
|
9
10
|
}
|
|
10
11
|
export { Inquiry };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
interface PartialInquiry {
|
|
3
3
|
sessionId: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
6
|
eventSourceId: string;
|
|
7
7
|
message: string;
|
|
8
|
-
|
|
8
|
+
inquiryLinkId: string;
|
|
9
9
|
index: number;
|
|
10
|
-
|
|
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
|
-
|
|
8
|
-
|
|
7
|
+
id: string;
|
|
8
|
+
createdAt: string;
|
|
9
9
|
eventSourceId: string;
|
|
10
10
|
message: string;
|
|
11
|
-
|
|
11
|
+
name: 'refined_search';
|
|
12
12
|
searchParams: SearchParams;
|
|
13
13
|
hits?: TReturnedFields;
|
|
14
14
|
totalHits?: number;
|
package/src/model/SessionData.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { CopilotEvent } from './CopilotEvent';
|
|
2
|
-
import { ReturnedFields } from "./ReturnedFields";
|
|
3
1
|
|
|
4
|
-
interface SessionData
|
|
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 {
|
|
1
|
+
import { CommonMetadata } from './CommonMetadata';
|
|
2
2
|
import { SessionData } from './SessionData';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
sessionId?: string;
|
|
3
|
+
interface SessionInformation {
|
|
4
|
+
id?: string;
|
|
6
5
|
createdAt?: string;
|
|
7
|
-
|
|
6
|
+
lastUpdatedAt?: string;
|
|
8
7
|
status?: string;
|
|
9
|
-
|
|
8
|
+
ttlInMinutes?: number;
|
|
9
|
+
data?: SessionData;
|
|
10
|
+
metadata?: CommonMetadata;
|
|
10
11
|
}
|
|
11
12
|
export { SessionInformation };
|