@memberjunction/skip-types 2.32.2 → 2.33.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 (2) hide show
  1. package/package.json +3 -3
  2. package/readme.md +212 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/skip-types",
3
- "version": "2.32.2",
3
+ "version": "2.33.0",
4
4
  "description": "MemberJunction: Skip AI Assistant - Types that are used between the MJAPI and the Skip API as well as the UI within MemberJunction Explorer",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "dependencies": {
22
- "@memberjunction/core-entities": "2.32.2",
23
- "@memberjunction/data-context": "2.32.2"
22
+ "@memberjunction/core-entities": "2.33.0",
23
+ "@memberjunction/data-context": "2.33.0"
24
24
  }
25
25
  }
package/readme.md CHANGED
@@ -1,7 +1,10 @@
1
- ```markdown
2
- # @memberjunction/skip-types
1
+ # MemberJunction Skip Types
3
2
 
4
- This library provides a set of types that are used to create consistency and coding simplicity for data interchange between the UI, Skip API and MJAPI
3
+ Type definitions and interfaces for the Skip AI Assistant integration with MemberJunction. This package provides the contract between the MemberJunction API, Skip API, and the MemberJunction Explorer UI.
4
+
5
+ ## Overview
6
+
7
+ The `@memberjunction/skip-types` package contains TypeScript type definitions, interfaces, and enums that facilitate communication between different components of the MemberJunction Skip AI assistant system. It ensures type safety and consistent data structures when interacting with the Skip API or rendering Skip-generated content in MemberJunction applications.
5
8
 
6
9
  ## Installation
7
10
 
@@ -9,10 +12,214 @@ This library provides a set of types that are used to create consistency and cod
9
12
  npm install @memberjunction/skip-types
10
13
  ```
11
14
 
15
+ ## Key Components
16
+
17
+ ### Request Types
18
+
19
+ Types used for making requests to the Skip API:
20
+
21
+ - `SkipAPIRequest` - Base interface for Skip API requests
22
+ - `SkipAPIRequestContext` - Context information for Skip API requests
23
+ - `SkipAPIRequestFilter` - Filter parameters for Skip requests
24
+ - `SkipAPIRequestSort` - Sort parameters for Skip requests
25
+ - `SkipAPIEntityQueryRequest` - Request for entity data queries
26
+ - `SkipAPIDataContextItemRequest` - Request for data context items
27
+ - `SkipAPIConversationRequest` - Request for conversation management
28
+ - `SkipAPIFetchImageRequest` - Request for image fetching
29
+
30
+ ### Response Types
31
+
32
+ Types used for handling responses from the Skip API:
33
+
34
+ - `SkipAPIResponse` - Base interface for Skip API responses
35
+ - `SkipAPIEntityQueryResponse` - Response with entity query results
36
+ - `SkipAPIConversationResponse` - Response for conversation operations
37
+ - `SkipAPIImageResponse` - Response for image operations
38
+ - `SkipAPIErrorResponse` - Error response structure
39
+ - `MJAPISkipResult` - Response format from MJAPI to the UI
40
+ - `SkipResponsePhase` - Defines the different phases of Skip responses
41
+
42
+ ### Message and Conversation Types
43
+
44
+ - `SkipMessage` - Individual message in a conversation with Skip
45
+ - `SkipConversation` - Collection of messages forming a conversation
46
+ - `SkipRequestPhase` - Defines the different phases of Skip requests
47
+ - `SkipConversationDetail` - Detailed conversation information
48
+ - `SkipConversationStatus` - Conversation status enum
49
+
50
+ ### Report Types
51
+
52
+ Types for Skip-generated reports and visualizations:
53
+
54
+ - `SkipHTMLReport` - HTML-based report generated by Skip
55
+ - `SkipHTMLReportCallbacks` - Interface for callbacks from HTML reports
56
+ - `SkipHTMLReportInitFunction` - Initialization function for HTML reports
57
+ - `SkipReportAction` - Actions that can be performed on reports
58
+ - `SkipReportEvent` - Events that can occur in reports
59
+ - `SkipReportCallbackResponse` - Response from report callbacks
60
+ - `SimpleDataContext` - Simplified data context for HTML reports
61
+
62
+ ### Learning Cycle Types
63
+
64
+ - `SkipAPILearningCycleRequest` - Request for Skip to learn from conversation history
65
+ - `SkipAPILearningCycleResponse` - Response from learning cycle processing
66
+ - `SkipAPIAgentNote` - Notes that Skip can generate during learning
67
+ - `SkipAPIAgentNoteType` - Types of notes Skip can generate
68
+ - `SkipAPIAgentRequest` - Format for Skip's human-in-the-loop requests
69
+
70
+ ### Data Types
71
+
72
+ - `SkipDataRequest` - Format for Skip to request additional data
73
+ - `SkipDataRequestType` - Types of data requests Skip can make
74
+ - `SkipSubProcessResponse` - Results from sandboxed script execution
75
+ - `SkipEntityInfo` - Entity metadata information for Skip
76
+ - `SkipEntityFieldInfo` - Field metadata for entities
77
+ - `SkipEntityRelationshipInfo` - Relationship metadata for entities
78
+ - `SkipDataContextItem` - Data context item structure
79
+ - `SkipDataContextItemType` - Types of data context items
80
+ - `SkipDataContextItemSource` - Source of data context items
81
+
82
+ ### Specialized Response Types
83
+
84
+ - `SkipAPIAnalysisCompleteResponse` - Response for completed analysis
85
+ - `SkipAPIClarifyingQuestionResponse` - Response when Skip needs clarification
86
+ - `SkipAPIDataRequestResponse` - Response when Skip needs more data
87
+ - `SkipAPIChatWithRecordResponse` - Response for chat-with-record feature
88
+
89
+ ## Usage Examples
90
+
91
+ ### Creating a Skip API Request
92
+
93
+ ```typescript
94
+ import {
95
+ SkipAPIRequest,
96
+ SkipMessage,
97
+ SkipRequestPhase
98
+ } from '@memberjunction/skip-types';
99
+
100
+ // Create a new Skip API request
101
+ const request: SkipAPIRequest = {
102
+ messages: [
103
+ {
104
+ role: "user",
105
+ content: "Show me sales by region from last quarter",
106
+ conversationDetailID: "12345"
107
+ }
108
+ ],
109
+ dataContext: myDataContext,
110
+ entities: myEntityMetadata,
111
+ queries: myStoredQueries,
112
+ conversationID: "conv-123",
113
+ organizationID: "org-456",
114
+ requestPhase: SkipRequestPhase.initial_request,
115
+ apiKeys: [
116
+ {
117
+ vendorDriverName: "AnthropicLLM",
118
+ apiKey: "YOUR_API_KEY"
119
+ }
120
+ ]
121
+ };
122
+ ```
123
+
124
+ ### Handling Skip API Responses
125
+
126
+ ```typescript
127
+ import {
128
+ MJAPISkipResult,
129
+ SkipAPIAnalysisCompleteResponse,
130
+ SkipResponsePhase
131
+ } from '@memberjunction/skip-types';
132
+
133
+ function handleSkipResponse(result: MJAPISkipResult) {
134
+ if (result.Success) {
135
+ if (result.ResponsePhase === SkipResponsePhase.analysis_complete) {
136
+ // Parse the result JSON into the appropriate type
137
+ const response = JSON.parse(result.Result) as SkipAPIAnalysisCompleteResponse;
138
+
139
+ // Now you can access the analysis results
140
+ console.log("Report title:", response.reportTitle);
141
+ console.log("Analysis:", response.analysis);
142
+
143
+ // Handle different result types
144
+ if (response.resultType === "data") {
145
+ // Handle table data from executionResults.tableData
146
+ displayTable(response.executionResults.tableData);
147
+ } else if (response.resultType === "plot") {
148
+ // Handle plot data from executionResults.plotData
149
+ renderPlot(response.executionResults.plotData);
150
+ } else if (response.resultType === "html") {
151
+ // Handle custom HTML report
152
+ renderHTML(response.executionResults.htmlReport);
153
+ }
154
+ } else if (result.ResponsePhase === SkipResponsePhase.clarifying_question) {
155
+ // Handle clarifying questions
156
+ const questionResponse = JSON.parse(result.Result) as SkipAPIClarifyingQuestionResponse;
157
+ promptUserForAnswer(questionResponse.question);
158
+ } else if (result.ResponsePhase === SkipResponsePhase.data_request) {
159
+ // Handle data requests
160
+ const dataRequest = JSON.parse(result.Result) as SkipAPIDataRequestResponse;
161
+ fetchAdditionalData(dataRequest.dataRequests);
162
+ }
163
+ } else {
164
+ console.error("Skip API request failed:", result.Status);
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### Working with Skip HTML Reports and Callbacks
170
+
171
+ ```typescript
172
+ import {
173
+ SkipHTMLReportInitFunction,
174
+ SimpleDataContext,
175
+ SkipHTMLReportCallbacks
176
+ } from '@memberjunction/skip-types';
177
+
178
+ // Init function that would be called by the container application
179
+ const initReport: SkipHTMLReportInitFunction = (
180
+ data: SimpleDataContext,
181
+ userState?: any,
182
+ callbacks?: SkipHTMLReportCallbacks
183
+ ) => {
184
+ // Initialize the report with the data
185
+ renderChart(data.data_item_1);
186
+
187
+ // Set up event handlers that use callbacks
188
+ document.getElementById('refresh').addEventListener('click', () => {
189
+ callbacks?.RefreshData();
190
+ });
191
+
192
+ document.getElementById('open-record').addEventListener('click', () => {
193
+ callbacks?.OpenEntityRecord('Customer', { ID: 123 });
194
+ });
195
+
196
+ document.getElementById('drill-down').addEventListener('click', () => {
197
+ callbacks?.DrillDown('SalesRegion', 'Northeast');
198
+ });
199
+
200
+ document.getElementById('export-data').addEventListener('click', () => {
201
+ callbacks?.ExportData('csv');
202
+ });
203
+
204
+ // Update user state when something changes
205
+ const newState = { selectedRegion: 'North' };
206
+ callbacks?.UpdateUserState(newState);
207
+ };
208
+
209
+ // Register the init function globally so it can be called from the container
210
+ window.initSkipReport = initReport;
211
+ ```
212
+
213
+ ## Dependencies
214
+
215
+ This package relies on the following MemberJunction packages:
216
+ - `@memberjunction/core-entities` - Core entity definitions
217
+ - `@memberjunction/data-context` - Data context types and utilities
218
+
12
219
  ## Contributing
13
220
 
14
- Feel free to open issues or pull requests if you have suggestions or fixes.
221
+ Contributions to extend or improve the type definitions are welcome. Please ensure that any additions maintain backward compatibility and follow the established naming conventions.
15
222
 
16
223
  ## License
17
224
 
18
- ISC License
225
+ ISC