@memberjunction/server 2.6.1 → 2.7.1
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/entitySubclasses/userViewEntity.server.d.ts.map +1 -1
- package/dist/entitySubclasses/userViewEntity.server.js +44 -1
- package/dist/entitySubclasses/userViewEntity.server.js.map +1 -1
- package/dist/resolvers/ReportResolver.js +1 -1
- package/dist/resolvers/ReportResolver.js.map +1 -1
- package/package.json +22 -22
- package/src/entitySubclasses/userViewEntity.server.ts +44 -1
- package/src/resolvers/ReportResolver.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userViewEntity.server.d.ts","sourceRoot":"","sources":["../../src/entitySubclasses/userViewEntity.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,UAAU,EAAsB,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAiB,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAM5G,qBACa,qBAAsB,SAAQ,sBAAsB;IAI7D,cAAuB,sBAAsB,IAAI,OAAO,CAEvD;IAMD,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;cAMe,UAAU,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAc/C,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAC,CAAC;IAuErI,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"userViewEntity.server.d.ts","sourceRoot":"","sources":["../../src/entitySubclasses/userViewEntity.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,UAAU,EAAsB,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAiB,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAM5G,qBACa,qBAAsB,SAAQ,sBAAsB;IAI7D,cAAuB,sBAAsB,IAAI,OAAO,CAEvD;IAMD,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;cAMe,UAAU,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAc/C,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAC,CAAC;IAuErI,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAmH3D"}
|
|
@@ -92,6 +92,8 @@ let UserViewEntity_Server = class UserViewEntity_Server extends UserViewEntityEx
|
|
|
92
92
|
GenerateSysPrompt(entityInfo) {
|
|
93
93
|
const processedViews = [entityInfo.BaseView];
|
|
94
94
|
const md = new Metadata();
|
|
95
|
+
const listsEntity = md.EntityByName("Lists");
|
|
96
|
+
const listDetailsEntity = md.EntityByName("List Details");
|
|
95
97
|
const gptSysPrompt = `You are an expert in SQL and Microsoft SQL Server.
|
|
96
98
|
You will be provided a user prompt representing how they want to filter the data.
|
|
97
99
|
You may *NOT* use JOINS, only sub-queries for related tables.
|
|
@@ -103,6 +105,11 @@ const returnType = {
|
|
|
103
105
|
userExplanationMessage: string
|
|
104
106
|
};
|
|
105
107
|
|
|
108
|
+
In MemberJunction, we have a concept called "Entities" and these are metadata constructs that wrap SQL tables and views. The entity that we are currently
|
|
109
|
+
building a filter for is called "${entityInfo.Name}" and has an ID of "${entityInfo.ID}"
|
|
110
|
+
|
|
111
|
+
You won't be using this Entity name or ID in your SQL, unless you need to use it for List filtering (more on that below).
|
|
112
|
+
|
|
106
113
|
The view that the user is querying is called ${entityInfo.BaseView} and has these fields:
|
|
107
114
|
${entityInfo.Fields.map(f => {
|
|
108
115
|
let ret = `${f.Name} (${f.Type})`;
|
|
@@ -149,7 +156,43 @@ ${entityInfo.RelatedEntities.map(r => {
|
|
|
149
156
|
}
|
|
150
157
|
else
|
|
151
158
|
return '';
|
|
152
|
-
}).join('\n')}
|
|
159
|
+
}).join('\n')}
|
|
160
|
+
|
|
161
|
+
<IMPORTANT - LISTS FEATURE>
|
|
162
|
+
In addition to the above related views, a user may talk about "Lists" in their request. A List is a static set of records modeled in our database with the ${listsEntity.SchemaName}.vwLists view and
|
|
163
|
+
the ${listsEntity.SchemaName}.vwListDetails view. ${listsEntity.SchemaName}.vwLists contains the list "header" information with these columns:
|
|
164
|
+
${listsEntity.Fields.map(f => {
|
|
165
|
+
return f.Name + ' (' + f.SQLFullType + ')';
|
|
166
|
+
}).join(', ')}
|
|
167
|
+
The vwListDetails view contains the list "detail" information with these columns which is basically the records that are part of the list. ${listsEntity.SchemaName}.vwListDetails contains these columns:
|
|
168
|
+
${listDetailsEntity.Fields.map(f => {
|
|
169
|
+
return f.Name + ' (' + f.SQLFullType + ')';
|
|
170
|
+
}).join(', ')}.
|
|
171
|
+
|
|
172
|
+
If a user is asking to use a list in creating a view, you need to use a sub-query along these lines:
|
|
173
|
+
|
|
174
|
+
ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails WHERE ListID='My List ID')
|
|
175
|
+
|
|
176
|
+
In this example we're assuming the user has asked us to filter to include only records that are part of the list with the ID of 'My List ID'. In reality the prompt you will have will have a UUID/GUID type ID not a text string like this.
|
|
177
|
+
You can use any fields at the detail level filter the records and of course combine this type of list-oriented sub-query with other filters as appropriate to satisfy the user's request.
|
|
178
|
+
|
|
179
|
+
It is also possible that a user will provide the name of the list they want to filter on. This isn't ideal as names can collide but if they do this use this style of query with a join to the vwLists view (the list "header") to filter on the name
|
|
180
|
+
of the view or other header information if they want to filter on other list header attributes you can do this. Here is an example:
|
|
181
|
+
|
|
182
|
+
ID IN (SELECT ld.ID FROM ${listsEntity.SchemaName}.vwListDetails ld INNER JOIN ${listsEntity.SchemaName}.vwLists l ON ld.ListID=l.ID WHERE l.Name='My List Name')
|
|
183
|
+
|
|
184
|
+
Remember to use the Entity ID in filtering the ${listsEntity}.vwListDetails view as it is a unique identifier that will properly filter the records in the list to only the entity that the user is querying.
|
|
185
|
+
</IMPORTANT - LISTS FEATURE>
|
|
186
|
+
<IMPORTANT - OTHER VIEWS>
|
|
187
|
+
The user might reference other "views" in their request. In the user's terminology a view is what we call a "User View" in MemberJunction system-speak. The idea is a user might ask for a filter that includes or excludes
|
|
188
|
+
records from another view. Unlike Lists, which are STATIC sets of records, User Views are dynamic and can change based on the underlying data. So, what we need to do is use a sub-query that pulls in the SQL for the other view
|
|
189
|
+
The user will be referring to the other view by name, so what you need to do when generating SQL for this scenario is to simply embed a sub-query along the lines of this example, updated of course in the context of the user's request and the rest of any filters you are building:
|
|
190
|
+
ID IN ({%UserView "ViewID"%}) -- this is for filtering the primary key using other User Views for this entity: "${entityInfo.Name}"
|
|
191
|
+
AccountID IN ({%UserView "ViewID"%}) -- this is an example where the foreign key relationship for the AccountID field in this entity (${entityInfo.Name}) links to another entity hypothetically called "Accounts" and we want to use an Accounts view for filtering in some way
|
|
192
|
+
By including this sub-query in your generated WHERE clause, it will give me what I need to dynamically replace the {%UserView "View Name"%} with the actual SQL for the view that the user is referring to. Since that actual SQL
|
|
193
|
+
can change over time, I don't want to embed it directly here but rather have it templatized and each time it is run, I will pre-process the SQL to replace the template with the actual SQL for the view.
|
|
194
|
+
</IMPORTANT - OTHER VIEWS>
|
|
195
|
+
`;
|
|
153
196
|
return gptSysPrompt + (processedViews.length > 1 ? relationships : '') + `
|
|
154
197
|
**** REMEMBER **** I am a BOT, do not return anything other than JSON to me or I will choke on your response!`;
|
|
155
198
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userViewEntity.server.js","sourceRoot":"","sources":["../../src/entitySubclasses/userViewEntity.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAc,QAAQ,EAAE,QAAQ,EAAE,MAAM,sB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U;EACxE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACzB,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC;QAC/C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;6IACgI,WAAW,CAAC,UAAU;EACjK,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC/B,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC;QAC/C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;wBAIW,WAAW,CAAC,UAAU;;;;;;;;2BAQnB,WAAW,CAAC,UAAU,gCAAgC,WAAW,CAAC,UAAU;;iDAEtD,WAAW;;;;;;sHAM0D,UAAU,CAAC,IAAI;4IACO,UAAU,CAAC,IAAI;;;;CAI1J,CAAA;QAEO,OAAO,YAAY,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAgD,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG;sHACV,CAAC;IACnH,CAAC;CACJ,CAAA;AA5NY,qBAAqB;IADjC,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC;GAC3B,qBAAqB,CA4NjC"}
|
|
@@ -111,7 +111,7 @@ let ReportResolverExtended = class ReportResolverExtended {
|
|
|
111
111
|
ON
|
|
112
112
|
cd.ConversationID = c.ID
|
|
113
113
|
WHERE
|
|
114
|
-
cd.ID
|
|
114
|
+
cd.ID='${ConversationDetailID}'`;
|
|
115
115
|
const result = await dataSource.query(sql);
|
|
116
116
|
if (!result || result.length === 0)
|
|
117
117
|
throw new Error('Unable to retrieve converation details');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportResolver.js","sourceRoot":"","sources":["../../src/resolvers/ReportResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA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E,KAAK;gBACd,YAAY,EAAE,+BAA+B,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;aAC5F,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA/FO;IADL,KAAK,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC;IACZ,WAAA,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAA;IAAoB,WAAA,GAAG,EAAE,CAAA;;;;2DAW1E;AAMK;IADL,QAAQ,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;IAEpC,WAAA,GAAG,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAA;IACzC,WAAA,GAAG,EAAE,CAAA;;;;kFA2EP;AAhGU,sBAAsB;IADlC,QAAQ,CAAC,mBAAmB,CAAC;GACjB,sBAAsB,CAiGlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@apollo/server": "^4.9.1",
|
|
24
24
|
"@graphql-tools/utils": "^10.0.1",
|
|
25
|
-
"@memberjunction/actions": "2.
|
|
26
|
-
"@memberjunction/ai": "2.
|
|
27
|
-
"@memberjunction/ai-mistral": "2.
|
|
28
|
-
"@memberjunction/ai-openai": "2.
|
|
29
|
-
"@memberjunction/ai-vectors-pinecone": "2.
|
|
30
|
-
"@memberjunction/aiengine": "2.
|
|
31
|
-
"@memberjunction/core": "2.
|
|
32
|
-
"@memberjunction/core-actions": "2.
|
|
33
|
-
"@memberjunction/core-entities": "2.
|
|
34
|
-
"@memberjunction/data-context": "2.
|
|
35
|
-
"@memberjunction/data-context-server": "2.
|
|
36
|
-
"@memberjunction/doc-utils": "2.
|
|
37
|
-
"@memberjunction/entity-communications-server": "2.
|
|
38
|
-
"@memberjunction/external-change-detection": "2.
|
|
39
|
-
"@memberjunction/global": "2.
|
|
40
|
-
"@memberjunction/queue": "2.
|
|
41
|
-
"@memberjunction/skip-types": "2.
|
|
42
|
-
"@memberjunction/sqlserver-dataprovider": "2.
|
|
43
|
-
"@memberjunction/graphql-dataprovider": "2.
|
|
44
|
-
"@memberjunction/storage": "2.
|
|
45
|
-
"@memberjunction/templates": "2.
|
|
25
|
+
"@memberjunction/actions": "2.7.1",
|
|
26
|
+
"@memberjunction/ai": "2.7.1",
|
|
27
|
+
"@memberjunction/ai-mistral": "2.7.1",
|
|
28
|
+
"@memberjunction/ai-openai": "2.7.1",
|
|
29
|
+
"@memberjunction/ai-vectors-pinecone": "2.7.1",
|
|
30
|
+
"@memberjunction/aiengine": "2.7.1",
|
|
31
|
+
"@memberjunction/core": "2.7.1",
|
|
32
|
+
"@memberjunction/core-actions": "2.7.1",
|
|
33
|
+
"@memberjunction/core-entities": "2.7.1",
|
|
34
|
+
"@memberjunction/data-context": "2.7.1",
|
|
35
|
+
"@memberjunction/data-context-server": "2.7.1",
|
|
36
|
+
"@memberjunction/doc-utils": "2.7.1",
|
|
37
|
+
"@memberjunction/entity-communications-server": "2.7.1",
|
|
38
|
+
"@memberjunction/external-change-detection": "2.7.1",
|
|
39
|
+
"@memberjunction/global": "2.7.1",
|
|
40
|
+
"@memberjunction/queue": "2.7.1",
|
|
41
|
+
"@memberjunction/skip-types": "2.7.1",
|
|
42
|
+
"@memberjunction/sqlserver-dataprovider": "2.7.1",
|
|
43
|
+
"@memberjunction/graphql-dataprovider": "2.7.1",
|
|
44
|
+
"@memberjunction/storage": "2.7.1",
|
|
45
|
+
"@memberjunction/templates": "2.7.1",
|
|
46
46
|
"@types/cors": "^2.8.13",
|
|
47
47
|
"@types/jsonwebtoken": "9.0.6",
|
|
48
48
|
"@types/node": "20.14.2",
|
|
@@ -115,6 +115,8 @@ export class UserViewEntity_Server extends UserViewEntityExtended {
|
|
|
115
115
|
public GenerateSysPrompt(entityInfo: EntityInfo): string {
|
|
116
116
|
const processedViews: string[] = [entityInfo.BaseView];
|
|
117
117
|
const md = new Metadata();
|
|
118
|
+
const listsEntity = md.EntityByName("Lists");
|
|
119
|
+
const listDetailsEntity = md.EntityByName("List Details");
|
|
118
120
|
const gptSysPrompt: string = `You are an expert in SQL and Microsoft SQL Server.
|
|
119
121
|
You will be provided a user prompt representing how they want to filter the data.
|
|
120
122
|
You may *NOT* use JOINS, only sub-queries for related tables.
|
|
@@ -126,6 +128,11 @@ const returnType = {
|
|
|
126
128
|
userExplanationMessage: string
|
|
127
129
|
};
|
|
128
130
|
|
|
131
|
+
In MemberJunction, we have a concept called "Entities" and these are metadata constructs that wrap SQL tables and views. The entity that we are currently
|
|
132
|
+
building a filter for is called "${entityInfo.Name}" and has an ID of "${entityInfo.ID}"
|
|
133
|
+
|
|
134
|
+
You won't be using this Entity name or ID in your SQL, unless you need to use it for List filtering (more on that below).
|
|
135
|
+
|
|
129
136
|
The view that the user is querying is called ${entityInfo.BaseView} and has these fields:
|
|
130
137
|
${entityInfo.Fields.map(f => {
|
|
131
138
|
let ret: string = `${f.Name} (${f.Type})`;
|
|
@@ -179,7 +186,43 @@ ${
|
|
|
179
186
|
else
|
|
180
187
|
return '';
|
|
181
188
|
}).join('\n')
|
|
182
|
-
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
<IMPORTANT - LISTS FEATURE>
|
|
192
|
+
In addition to the above related views, a user may talk about "Lists" in their request. A List is a static set of records modeled in our database with the ${listsEntity.SchemaName}.vwLists view and
|
|
193
|
+
the ${listsEntity.SchemaName}.vwListDetails view. ${listsEntity.SchemaName}.vwLists contains the list "header" information with these columns:
|
|
194
|
+
${listsEntity.Fields.map(f => {
|
|
195
|
+
return f.Name + ' (' + f.SQLFullType + ')';
|
|
196
|
+
}).join(', ')}
|
|
197
|
+
The vwListDetails view contains the list "detail" information with these columns which is basically the records that are part of the list. ${listsEntity.SchemaName}.vwListDetails contains these columns:
|
|
198
|
+
${listDetailsEntity.Fields.map(f => {
|
|
199
|
+
return f.Name + ' (' + f.SQLFullType + ')';
|
|
200
|
+
}).join(', ')}.
|
|
201
|
+
|
|
202
|
+
If a user is asking to use a list in creating a view, you need to use a sub-query along these lines:
|
|
203
|
+
|
|
204
|
+
ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails WHERE ListID='My List ID')
|
|
205
|
+
|
|
206
|
+
In this example we're assuming the user has asked us to filter to include only records that are part of the list with the ID of 'My List ID'. In reality the prompt you will have will have a UUID/GUID type ID not a text string like this.
|
|
207
|
+
You can use any fields at the detail level filter the records and of course combine this type of list-oriented sub-query with other filters as appropriate to satisfy the user's request.
|
|
208
|
+
|
|
209
|
+
It is also possible that a user will provide the name of the list they want to filter on. This isn't ideal as names can collide but if they do this use this style of query with a join to the vwLists view (the list "header") to filter on the name
|
|
210
|
+
of the view or other header information if they want to filter on other list header attributes you can do this. Here is an example:
|
|
211
|
+
|
|
212
|
+
ID IN (SELECT ld.ID FROM ${listsEntity.SchemaName}.vwListDetails ld INNER JOIN ${listsEntity.SchemaName}.vwLists l ON ld.ListID=l.ID WHERE l.Name='My List Name')
|
|
213
|
+
|
|
214
|
+
Remember to use the Entity ID in filtering the ${listsEntity}.vwListDetails view as it is a unique identifier that will properly filter the records in the list to only the entity that the user is querying.
|
|
215
|
+
</IMPORTANT - LISTS FEATURE>
|
|
216
|
+
<IMPORTANT - OTHER VIEWS>
|
|
217
|
+
The user might reference other "views" in their request. In the user's terminology a view is what we call a "User View" in MemberJunction system-speak. The idea is a user might ask for a filter that includes or excludes
|
|
218
|
+
records from another view. Unlike Lists, which are STATIC sets of records, User Views are dynamic and can change based on the underlying data. So, what we need to do is use a sub-query that pulls in the SQL for the other view
|
|
219
|
+
The user will be referring to the other view by name, so what you need to do when generating SQL for this scenario is to simply embed a sub-query along the lines of this example, updated of course in the context of the user's request and the rest of any filters you are building:
|
|
220
|
+
ID IN ({%UserView "ViewID"%}) -- this is for filtering the primary key using other User Views for this entity: "${entityInfo.Name}"
|
|
221
|
+
AccountID IN ({%UserView "ViewID"%}) -- this is an example where the foreign key relationship for the AccountID field in this entity (${entityInfo.Name}) links to another entity hypothetically called "Accounts" and we want to use an Accounts view for filtering in some way
|
|
222
|
+
By including this sub-query in your generated WHERE clause, it will give me what I need to dynamically replace the {%UserView "View Name"%} with the actual SQL for the view that the user is referring to. Since that actual SQL
|
|
223
|
+
can change over time, I don't want to embed it directly here but rather have it templatized and each time it is run, I will pre-process the SQL to replace the template with the actual SQL for the view.
|
|
224
|
+
</IMPORTANT - OTHER VIEWS>
|
|
225
|
+
`
|
|
183
226
|
|
|
184
227
|
return gptSysPrompt + (processedViews.length > 1 /*we always have 1 from the entity base view*/ ? relationships : '') + `
|
|
185
228
|
**** REMEMBER **** I am a BOT, do not return anything other than JSON to me or I will choke on your response!`;
|
|
@@ -88,7 +88,7 @@ export class ReportResolverExtended {
|
|
|
88
88
|
ON
|
|
89
89
|
cd.ConversationID = c.ID
|
|
90
90
|
WHERE
|
|
91
|
-
cd.ID
|
|
91
|
+
cd.ID='${ConversationDetailID}'`;
|
|
92
92
|
|
|
93
93
|
const result = await dataSource.query(sql);
|
|
94
94
|
if (!result || result.length === 0) throw new Error('Unable to retrieve converation details');
|