@memberjunction/server 2.7.0 → 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.
@@ -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;CAqG3D"}
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"}
@@ -159,7 +159,7 @@ ${entityInfo.RelatedEntities.map(r => {
159
159
  }).join('\n')}
160
160
 
161
161
  <IMPORTANT - LISTS FEATURE>
162
- Finally, 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
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
163
  the ${listsEntity.SchemaName}.vwListDetails view. ${listsEntity.SchemaName}.vwLists contains the list "header" information with these columns:
164
164
  ${listsEntity.Fields.map(f => {
165
165
  return f.Name + ' (' + f.SQLFullType + ')';
@@ -171,13 +171,27 @@ ${listDetailsEntity.Fields.map(f => {
171
171
 
172
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
173
 
174
- ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails INNER JOIN ${listsEntity.SchemaName}.vwLists ON vwListDetails.ListID = vwLists.ID WHERE vwLists.Name = 'My List Name')
174
+ ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails WHERE ListID='My List ID')
175
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 named 'My List Name'. You can use any fields at the detail level or header level to filter the records and of course
177
- combine this type of list-oriented sub-query with other filters as appropriate to satisfy the user's request.
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')
178
183
 
179
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.
180
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>
181
195
  `;
182
196
  return gptSysPrompt + (processedViews.length > 1 ? relationships : '') + `
183
197
  **** REMEMBER **** I am a BOT, do not return anything other than JSON to me or I will choke on your response!`;
@@ -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,EA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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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/server",
3
- "version": "2.7.0",
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.7.0",
26
- "@memberjunction/ai": "2.7.0",
27
- "@memberjunction/ai-mistral": "2.7.0",
28
- "@memberjunction/ai-openai": "2.7.0",
29
- "@memberjunction/ai-vectors-pinecone": "2.7.0",
30
- "@memberjunction/aiengine": "2.7.0",
31
- "@memberjunction/core": "2.7.0",
32
- "@memberjunction/core-actions": "2.7.0",
33
- "@memberjunction/core-entities": "2.7.0",
34
- "@memberjunction/data-context": "2.7.0",
35
- "@memberjunction/data-context-server": "2.7.0",
36
- "@memberjunction/doc-utils": "2.7.0",
37
- "@memberjunction/entity-communications-server": "2.7.0",
38
- "@memberjunction/external-change-detection": "2.7.0",
39
- "@memberjunction/global": "2.7.0",
40
- "@memberjunction/queue": "2.7.0",
41
- "@memberjunction/skip-types": "2.7.0",
42
- "@memberjunction/sqlserver-dataprovider": "2.7.0",
43
- "@memberjunction/graphql-dataprovider": "2.7.0",
44
- "@memberjunction/storage": "2.7.0",
45
- "@memberjunction/templates": "2.7.0",
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",
@@ -189,7 +189,7 @@ ${
189
189
  }
190
190
 
191
191
  <IMPORTANT - LISTS FEATURE>
192
- Finally, 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
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
193
  the ${listsEntity.SchemaName}.vwListDetails view. ${listsEntity.SchemaName}.vwLists contains the list "header" information with these columns:
194
194
  ${listsEntity.Fields.map(f => {
195
195
  return f.Name + ' (' + f.SQLFullType + ')';
@@ -201,13 +201,27 @@ ${listDetailsEntity.Fields.map(f => {
201
201
 
202
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
203
 
204
- ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails INNER JOIN ${listsEntity.SchemaName}.vwLists ON vwListDetails.ListID = vwLists.ID WHERE vwLists.Name = 'My List Name')
204
+ ID IN (SELECT ID FROM ${listsEntity.SchemaName}.vwListDetails WHERE ListID='My List ID')
205
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 named 'My List Name'. You can use any fields at the detail level or header level to filter the records and of course
207
- combine this type of list-oriented sub-query with other filters as appropriate to satisfy the user's request.
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')
208
213
 
209
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.
210
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>
211
225
  `
212
226
 
213
227
  return gptSysPrompt + (processedViews.length > 1 /*we always have 1 from the entity base view*/ ? relationships : '') + `