@spektra-cloudevents/application-copilot-widget 1.2.0 → 2.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/README.md +126 -75
- package/dist/index.cjs +400 -63
- package/dist/index.d.cts +64 -8
- package/dist/index.d.ts +64 -8
- package/dist/index.js +400 -63
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
type Environment = 'qa' | 'stage';
|
|
2
1
|
interface ApplicationContext {
|
|
3
2
|
projectKey: string;
|
|
4
|
-
environment: Environment;
|
|
5
3
|
page?: {
|
|
6
4
|
pageKey?: string;
|
|
7
5
|
route?: string;
|
|
@@ -29,7 +27,6 @@ interface ApplicationContext {
|
|
|
29
27
|
}
|
|
30
28
|
interface WidgetConfig {
|
|
31
29
|
projectKey: string;
|
|
32
|
-
environment: Environment;
|
|
33
30
|
/** Base URL of Spektra.ApplicationCopilot.Api, e.g. https://localhost:5001 */
|
|
34
31
|
apiBaseUrl: string;
|
|
35
32
|
/** Optional SignalR hub URL for live progress, e.g. `${apiBaseUrl}/hubs/application-copilot` */
|
|
@@ -38,10 +35,12 @@ interface WidgetConfig {
|
|
|
38
35
|
tenantUniqueName: string;
|
|
39
36
|
/** Executed on every question to capture the current page context. */
|
|
40
37
|
getContext: () => ApplicationContext;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Required. Returns the signed-in user's bearer token (the same token the host sends to the CloudEvents API).
|
|
40
|
+
* Sent as `Authorization: Bearer` on every request and as the SignalR access token. The Copilot API validates it;
|
|
41
|
+
* there is no other way to identify the user (no email header).
|
|
42
|
+
*/
|
|
43
|
+
getAuthToken: () => string | undefined;
|
|
45
44
|
/** Launcher button label. Defaults to "Ask Application Copilot". */
|
|
46
45
|
buttonText?: string;
|
|
47
46
|
/** Host navigation hook (e.g. Angular router). If omitted, the widget falls back to window.location. */
|
|
@@ -52,6 +51,55 @@ interface WidgetConfig {
|
|
|
52
51
|
number?: string;
|
|
53
52
|
webUrl?: string;
|
|
54
53
|
}) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Optional host hook to open the host's own support experience (e.g. the Zoho Desk ASAP widget via the host's
|
|
56
|
+
* support service, for the current tenant). When set, the widget shows an "Open support" action; on click it
|
|
57
|
+
* closes its own panel first (synchronously) and then calls this callback.
|
|
58
|
+
*/
|
|
59
|
+
onOpenSupport?: () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Show the "Add to knowledge base" upload button in the panel header. Default false (hidden). Set it only for users
|
|
62
|
+
* who may manage the Copilot knowledge base (CloudEvents Admin: System Admin and Partner Admin). This is UI only:
|
|
63
|
+
* the Copilot API still authorizes every upload.
|
|
64
|
+
*/
|
|
65
|
+
showKnowledgeUpload?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** A knowledge-base link returned with an answer (published articles only). Rendered only when `url` is https. */
|
|
68
|
+
interface CopilotReference {
|
|
69
|
+
title?: string;
|
|
70
|
+
url: string;
|
|
71
|
+
}
|
|
72
|
+
/** Server-built support-ticket draft (`GET /api/sessions/{id}/support-ticket/draft`). */
|
|
73
|
+
interface SupportTicketDraft {
|
|
74
|
+
subject: string;
|
|
75
|
+
description: string;
|
|
76
|
+
fields?: {
|
|
77
|
+
userName?: string;
|
|
78
|
+
userEmail?: string;
|
|
79
|
+
role?: string;
|
|
80
|
+
roleDisplayName?: string;
|
|
81
|
+
tenant?: string;
|
|
82
|
+
requestId?: string;
|
|
83
|
+
eventName?: string;
|
|
84
|
+
eventStatus?: string;
|
|
85
|
+
eventScheduledDate?: string;
|
|
86
|
+
eventDeliveryMode?: string;
|
|
87
|
+
eventOwner?: string;
|
|
88
|
+
eventPM?: string;
|
|
89
|
+
question?: string;
|
|
90
|
+
conversationSummary?: string;
|
|
91
|
+
timestampUtc?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Response of `POST /api/sessions/{id}/support-ticket`. */
|
|
95
|
+
interface SupportTicketResult {
|
|
96
|
+
status: string;
|
|
97
|
+
ticketNumber?: string;
|
|
98
|
+
webUrl?: string;
|
|
99
|
+
id?: string;
|
|
100
|
+
/** Confirmation text, e.g. "Your support ticket 123 has been created." */
|
|
101
|
+
message?: string;
|
|
102
|
+
reason?: string;
|
|
55
103
|
}
|
|
56
104
|
interface CopilotAnswer {
|
|
57
105
|
status: string;
|
|
@@ -66,6 +114,12 @@ interface CopilotAnswer {
|
|
|
66
114
|
verifiedRoleLabel?: string | null;
|
|
67
115
|
evidenceRefs?: string[];
|
|
68
116
|
source?: string;
|
|
117
|
+
/** Knowledge-base links (published articles only); empty when none. */
|
|
118
|
+
references?: CopilotReference[];
|
|
119
|
+
/** Server decision: offer a support ticket for this answer. */
|
|
120
|
+
supportTicketEligible?: boolean;
|
|
121
|
+
/** Offer text to show when `supportTicketEligible` is true. */
|
|
122
|
+
supportTicketPrompt?: string;
|
|
69
123
|
}
|
|
70
124
|
|
|
71
125
|
/**
|
|
@@ -83,6 +137,8 @@ declare const ApplicationCopilotWidget: {
|
|
|
83
137
|
ask: (question: string) => void;
|
|
84
138
|
setContext: (context: ApplicationContext) => void;
|
|
85
139
|
captureError: (errorContext: ApplicationContext["recentError"]) => void;
|
|
140
|
+
/** Drop the current Copilot session and conversation (e.g. after a tenant switch or sign-out). */
|
|
141
|
+
resetSession: () => void;
|
|
86
142
|
};
|
|
87
143
|
declare global {
|
|
88
144
|
interface Window {
|
|
@@ -90,4 +146,4 @@ declare global {
|
|
|
90
146
|
}
|
|
91
147
|
}
|
|
92
148
|
|
|
93
|
-
export { type ApplicationContext, ApplicationCopilotWidget, type CopilotAnswer, type
|
|
149
|
+
export { type ApplicationContext, ApplicationCopilotWidget, type CopilotAnswer, type CopilotReference, type SupportTicketDraft, type SupportTicketResult, type WidgetConfig, ApplicationCopilotWidget as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
type Environment = 'qa' | 'stage';
|
|
2
1
|
interface ApplicationContext {
|
|
3
2
|
projectKey: string;
|
|
4
|
-
environment: Environment;
|
|
5
3
|
page?: {
|
|
6
4
|
pageKey?: string;
|
|
7
5
|
route?: string;
|
|
@@ -29,7 +27,6 @@ interface ApplicationContext {
|
|
|
29
27
|
}
|
|
30
28
|
interface WidgetConfig {
|
|
31
29
|
projectKey: string;
|
|
32
|
-
environment: Environment;
|
|
33
30
|
/** Base URL of Spektra.ApplicationCopilot.Api, e.g. https://localhost:5001 */
|
|
34
31
|
apiBaseUrl: string;
|
|
35
32
|
/** Optional SignalR hub URL for live progress, e.g. `${apiBaseUrl}/hubs/application-copilot` */
|
|
@@ -38,10 +35,12 @@ interface WidgetConfig {
|
|
|
38
35
|
tenantUniqueName: string;
|
|
39
36
|
/** Executed on every question to capture the current page context. */
|
|
40
37
|
getContext: () => ApplicationContext;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Required. Returns the signed-in user's bearer token (the same token the host sends to the CloudEvents API).
|
|
40
|
+
* Sent as `Authorization: Bearer` on every request and as the SignalR access token. The Copilot API validates it;
|
|
41
|
+
* there is no other way to identify the user (no email header).
|
|
42
|
+
*/
|
|
43
|
+
getAuthToken: () => string | undefined;
|
|
45
44
|
/** Launcher button label. Defaults to "Ask Application Copilot". */
|
|
46
45
|
buttonText?: string;
|
|
47
46
|
/** Host navigation hook (e.g. Angular router). If omitted, the widget falls back to window.location. */
|
|
@@ -52,6 +51,55 @@ interface WidgetConfig {
|
|
|
52
51
|
number?: string;
|
|
53
52
|
webUrl?: string;
|
|
54
53
|
}) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Optional host hook to open the host's own support experience (e.g. the Zoho Desk ASAP widget via the host's
|
|
56
|
+
* support service, for the current tenant). When set, the widget shows an "Open support" action; on click it
|
|
57
|
+
* closes its own panel first (synchronously) and then calls this callback.
|
|
58
|
+
*/
|
|
59
|
+
onOpenSupport?: () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Show the "Add to knowledge base" upload button in the panel header. Default false (hidden). Set it only for users
|
|
62
|
+
* who may manage the Copilot knowledge base (CloudEvents Admin: System Admin and Partner Admin). This is UI only:
|
|
63
|
+
* the Copilot API still authorizes every upload.
|
|
64
|
+
*/
|
|
65
|
+
showKnowledgeUpload?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** A knowledge-base link returned with an answer (published articles only). Rendered only when `url` is https. */
|
|
68
|
+
interface CopilotReference {
|
|
69
|
+
title?: string;
|
|
70
|
+
url: string;
|
|
71
|
+
}
|
|
72
|
+
/** Server-built support-ticket draft (`GET /api/sessions/{id}/support-ticket/draft`). */
|
|
73
|
+
interface SupportTicketDraft {
|
|
74
|
+
subject: string;
|
|
75
|
+
description: string;
|
|
76
|
+
fields?: {
|
|
77
|
+
userName?: string;
|
|
78
|
+
userEmail?: string;
|
|
79
|
+
role?: string;
|
|
80
|
+
roleDisplayName?: string;
|
|
81
|
+
tenant?: string;
|
|
82
|
+
requestId?: string;
|
|
83
|
+
eventName?: string;
|
|
84
|
+
eventStatus?: string;
|
|
85
|
+
eventScheduledDate?: string;
|
|
86
|
+
eventDeliveryMode?: string;
|
|
87
|
+
eventOwner?: string;
|
|
88
|
+
eventPM?: string;
|
|
89
|
+
question?: string;
|
|
90
|
+
conversationSummary?: string;
|
|
91
|
+
timestampUtc?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Response of `POST /api/sessions/{id}/support-ticket`. */
|
|
95
|
+
interface SupportTicketResult {
|
|
96
|
+
status: string;
|
|
97
|
+
ticketNumber?: string;
|
|
98
|
+
webUrl?: string;
|
|
99
|
+
id?: string;
|
|
100
|
+
/** Confirmation text, e.g. "Your support ticket 123 has been created." */
|
|
101
|
+
message?: string;
|
|
102
|
+
reason?: string;
|
|
55
103
|
}
|
|
56
104
|
interface CopilotAnswer {
|
|
57
105
|
status: string;
|
|
@@ -66,6 +114,12 @@ interface CopilotAnswer {
|
|
|
66
114
|
verifiedRoleLabel?: string | null;
|
|
67
115
|
evidenceRefs?: string[];
|
|
68
116
|
source?: string;
|
|
117
|
+
/** Knowledge-base links (published articles only); empty when none. */
|
|
118
|
+
references?: CopilotReference[];
|
|
119
|
+
/** Server decision: offer a support ticket for this answer. */
|
|
120
|
+
supportTicketEligible?: boolean;
|
|
121
|
+
/** Offer text to show when `supportTicketEligible` is true. */
|
|
122
|
+
supportTicketPrompt?: string;
|
|
69
123
|
}
|
|
70
124
|
|
|
71
125
|
/**
|
|
@@ -83,6 +137,8 @@ declare const ApplicationCopilotWidget: {
|
|
|
83
137
|
ask: (question: string) => void;
|
|
84
138
|
setContext: (context: ApplicationContext) => void;
|
|
85
139
|
captureError: (errorContext: ApplicationContext["recentError"]) => void;
|
|
140
|
+
/** Drop the current Copilot session and conversation (e.g. after a tenant switch or sign-out). */
|
|
141
|
+
resetSession: () => void;
|
|
86
142
|
};
|
|
87
143
|
declare global {
|
|
88
144
|
interface Window {
|
|
@@ -90,4 +146,4 @@ declare global {
|
|
|
90
146
|
}
|
|
91
147
|
}
|
|
92
148
|
|
|
93
|
-
export { type ApplicationContext, ApplicationCopilotWidget, type CopilotAnswer, type
|
|
149
|
+
export { type ApplicationContext, ApplicationCopilotWidget, type CopilotAnswer, type CopilotReference, type SupportTicketDraft, type SupportTicketResult, type WidgetConfig, ApplicationCopilotWidget as default };
|