@memberjunction/skip-types 0.9.2

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.
@@ -0,0 +1 @@
1
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,93 @@
1
+ import { UserViewEntityExtended } from '@memberjunction/core-entities';
2
+ export declare class SubProcessResponse {
3
+ status: "success" | "error";
4
+ resultType: "data" | "plot" | "html" | null;
5
+ tableData: any[] | null;
6
+ plotData: {
7
+ data: any[];
8
+ layout: any;
9
+ } | null;
10
+ htmlReport: string | null;
11
+ analysis: string | null;
12
+ errorMessage: string | null;
13
+ }
14
+ /**
15
+ * Defines the shape of the data that is expected by the Skip API Server when making a request
16
+ */
17
+ export declare class SkipAPIRequest {
18
+ /**
19
+ * The user's input
20
+ */
21
+ userInput: string;
22
+ /**
23
+ * The data context, use this to provide all of the data you have in a data context to Skip. You should provide this from cache or refreshed based on the parameters provided by the user.
24
+ */
25
+ dataContext: SkipDataContext;
26
+ /**
27
+ * The conversation ID
28
+ */
29
+ conversationID: string;
30
+ /**
31
+ * The organization ID - this is part of the Skip API Authentication Request, along with the bearer token in the header (the bearer token is not yet implemented, To-Do!)
32
+ */
33
+ organizationID: number;
34
+ /**
35
+ * The phase of the conversation, defined as follows:
36
+ * * initial_request: The initial request from the user - when a new conversation gets started or after a report is created, pass in this value
37
+ * * clarify_question_response: Sometimes the Skip API server responds back to your request with a responsePhase of 'clarifying_question' - in this situation, the MJAPI server needs to communicate with the UI to ask the follow up question to the user. When you have that feedback from the user gathered and are providing the response to the clarifying question back to Skip API, use this requestPhase
38
+ * * data_gathering_response: Sometimes the Skip API server responds back to your request with a responsePhase of 'data_request' - in this situation, the MJAPI server needs to process the data request, gather whatever additional data the Skip API has asked for, and then return it in the dataContext property of the SkipAPIRequest object. When you are finished gathering data and returning it to the Skip API server, use this requestPhase
39
+ */
40
+ requestPhase: 'initial_request' | 'clarify_question_response' | 'data_gathering_response';
41
+ }
42
+ /**
43
+ * Defines the shape of the data that is returned by the Skip API Server
44
+ */
45
+ export declare class SkipAPIResponse {
46
+ success: boolean;
47
+ executionResults: SubProcessResponse | null;
48
+ userExplanation: string;
49
+ techExplanation: string;
50
+ suggestedQuestions: string[] | null;
51
+ reportTitle: string | null;
52
+ analysis: string | null;
53
+ scriptText: string | null;
54
+ responsePhase: "clarifying_question" | "data_request" | "analysis_complete";
55
+ }
56
+ export declare class SkipDataContextFieldInfo {
57
+ Name: string;
58
+ Type: string;
59
+ Description?: string;
60
+ }
61
+ export declare class SkipDataContextItem {
62
+ Type: 'view' | 'query' | 'full_entity';
63
+ /**
64
+ * The ID of the view, query, or entity in the system
65
+ */
66
+ RecordID: number;
67
+ /**
68
+ * The name of the view, query, or entity in the system
69
+ */
70
+ RecordName: string;
71
+ /**
72
+ * The name of the entity in the system, only used if type = 'full_entity' or type = 'view' --- for type of 'query' this is not used as query can come from any number of entities in combination
73
+ */
74
+ EntityName?: string;
75
+ Fields: SkipDataContextFieldInfo[];
76
+ /**
77
+ * Generated description of the item which is dependent on the type of the item
78
+ */
79
+ get Description(): string;
80
+ /**
81
+ * Populate the SkipDataContextItem from a UserViewEntity class instance
82
+ * @param viewEntity
83
+ */
84
+ static FromViewEntity(viewEntity: UserViewEntityExtended): SkipDataContextItem;
85
+ Data?: any[];
86
+ ValidateDataExists(): boolean;
87
+ }
88
+ export declare class SkipDataContext {
89
+ Items: SkipDataContextItem[];
90
+ ValidateDataExists(): boolean;
91
+ ConvertToSimpleObject(): any;
92
+ CreateSimpleObjectTypeDefinition(): string;
93
+ }
package/dist/types.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SkipDataContext = exports.SkipDataContextItem = exports.SkipDataContextFieldInfo = exports.SkipAPIResponse = exports.SkipAPIRequest = exports.SubProcessResponse = void 0;
4
+ class SubProcessResponse {
5
+ }
6
+ exports.SubProcessResponse = SubProcessResponse;
7
+ /**
8
+ * Defines the shape of the data that is expected by the Skip API Server when making a request
9
+ */
10
+ class SkipAPIRequest {
11
+ }
12
+ exports.SkipAPIRequest = SkipAPIRequest;
13
+ /**
14
+ * Defines the shape of the data that is returned by the Skip API Server
15
+ */
16
+ class SkipAPIResponse {
17
+ }
18
+ exports.SkipAPIResponse = SkipAPIResponse;
19
+ class SkipDataContextFieldInfo {
20
+ }
21
+ exports.SkipDataContextFieldInfo = SkipDataContextFieldInfo;
22
+ class SkipDataContextItem {
23
+ constructor() {
24
+ /*
25
+ * The fields in the view, query, or entity
26
+ */
27
+ this.Fields = [];
28
+ }
29
+ /**
30
+ * Generated description of the item which is dependent on the type of the item
31
+ */
32
+ get Description() {
33
+ switch (this.Type) {
34
+ case 'view':
35
+ return `View: ${this.RecordName}, From Entity: ${this.EntityName}`;
36
+ case 'query':
37
+ return `Query: ${this.RecordName}`;
38
+ case 'full_entity':
39
+ return `Full Entity - All Records: ${this.EntityName}`;
40
+ default:
41
+ return `Unknown Type: ${this.Type}`;
42
+ }
43
+ }
44
+ /**
45
+ * Populate the SkipDataContextItem from a UserViewEntity class instance
46
+ * @param viewEntity
47
+ */
48
+ static FromViewEntity(viewEntity) {
49
+ const instance = new SkipDataContextItem();
50
+ // update our data from the viewEntity definition
51
+ instance.Type = 'view';
52
+ instance.EntityName = viewEntity.ViewEntityInfo.Name;
53
+ instance.RecordID = viewEntity.ID;
54
+ instance.RecordName = viewEntity.Name;
55
+ instance.Fields = viewEntity.ViewEntityInfo.Fields.map(f => {
56
+ return {
57
+ Name: f.Name,
58
+ Type: f.Type,
59
+ Description: f.Description
60
+ };
61
+ });
62
+ return instance;
63
+ }
64
+ ValidateDataExists() {
65
+ return this.Data ? this.Data.length > 0 : false;
66
+ }
67
+ }
68
+ exports.SkipDataContextItem = SkipDataContextItem;
69
+ class SkipDataContext {
70
+ constructor() {
71
+ this.Items = [];
72
+ }
73
+ ValidateDataExists() {
74
+ if (this.Items)
75
+ return !this.Items.some(i => !i.ValidateDataExists()); // if any data item is invalid, return false
76
+ else
77
+ return false;
78
+ }
79
+ ConvertToSimpleObject() {
80
+ // Return a simple object that will have a property for each item in our Items array. We will name each item sequentially as data_item_1, data_item_2, etc.
81
+ const ret = {};
82
+ for (let i = 0; i < this.Items.length; i++) {
83
+ ret[`data_item_${i}`] = this.Items[i].Data;
84
+ }
85
+ return ret;
86
+ }
87
+ CreateSimpleObjectTypeDefinition() {
88
+ let sOutput = "";
89
+ for (let i = 0; i < this.Items.length; i++) {
90
+ sOutput += `data_item_${i}: []; // array of data items\n`;
91
+ }
92
+ return `{${sOutput}}`;
93
+ }
94
+ }
95
+ exports.SkipDataContext = SkipDataContext;
96
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA,MAAa,kBAAkB;CAQ9B;AARD,gDAQC;AAED;;GAEG;AACH,MAAa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kB;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACpD,CAAC;CACJ;AA9DD,kDA8DC;AAED,MAAa,eAAe;IAA5B;QACI,UAAK,GAA0B,EAAE,CAAC;IAyBtC,CAAC;IAvBU,kBAAkB;QACrB,IAAI,IAAI,CAAC,KAAK;YACV,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,4CAA4C;;YAEnG,OAAO,KAAK,CAAC;IACrB,CAAC;IAEM,qBAAqB;QACxB,2JAA2J;QAC3J,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,gCAAgC;QACnC,IAAI,OAAO,GAAW,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,OAAO,IAAI,aAAa,CAAC,gCAAgC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,OAAO,GAAG,CAAC;IAC1B,CAAC;CACJ;AA1BD,0CA0BC"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@memberjunction/skip-types",
3
+ "version": "0.9.2",
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
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "start": "ts-node-dev src/index.ts",
12
+ "build": "tsc",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "author": "MemberJunction.com",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "ts-node-dev": "^2.0.0",
19
+ "typescript": "^5.3.3"
20
+ },
21
+ "dependencies": {
22
+ "@memberjunction/core-entities": "^0.9.119"
23
+ }
24
+ }
package/readme.md ADDED
@@ -0,0 +1,18 @@
1
+ ```markdown
2
+ # @memberjunction/skip-types
3
+
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
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @memberjunction/skip-types
10
+ ```
11
+
12
+ ## Contributing
13
+
14
+ Feel free to open issues or pull requests if you have suggestions or fixes.
15
+
16
+ ## License
17
+
18
+ MIT License