@memberjunction/server 0.9.181 → 0.9.183
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/build.log.json +6 -0
- package/dist/generated/generated.js +1004 -445
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +31 -2
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/package.json +9 -9
- package/src/generated/generated.ts +673 -248
- package/src/resolvers/AskSkipResolver.ts +31 -3
|
@@ -65,6 +65,33 @@ export class AskSkipResolver {
|
|
|
65
65
|
private static _defaultNewChatName = 'New Chat';
|
|
66
66
|
private static _maxHistoricalMessages = 20;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Executes a script in the context of a data context and returns the results
|
|
70
|
+
* @param pubSub
|
|
71
|
+
* @param DataContextId
|
|
72
|
+
* @param ScriptText
|
|
73
|
+
*/
|
|
74
|
+
@Query(() => AskSkipResultType)
|
|
75
|
+
async ExecuteAskSkipRunScript(@Ctx() { dataSource, userPayload }: AppContext,
|
|
76
|
+
@PubSub() pubSub: PubSubEngine,
|
|
77
|
+
@Arg('DataContextId', () => Int) DataContextId: number,
|
|
78
|
+
@Arg('ScriptText', () => String) ScriptText: string) {
|
|
79
|
+
const md = new Metadata();
|
|
80
|
+
const user = UserCache.Instance.Users.find((u) => u.Email === userPayload.email);
|
|
81
|
+
if (!user) throw new Error(`User ${userPayload.email} not found in UserCache`);
|
|
82
|
+
const dataContext: DataContext = new DataContext();
|
|
83
|
+
await dataContext.Load(DataContextId, dataSource, true, user);
|
|
84
|
+
const input: SkipAPIRequest = {
|
|
85
|
+
messages: [], // not needed for this request
|
|
86
|
+
conversationID: '', // not needed for this request
|
|
87
|
+
dataContext: <DataContext>CopyScalarsAndArrays(dataContext), // we are casting this to DataContext as we're pushing this to the Skip API, and we don't want to send the real DataContext object, just a copy of the scalar and array properties
|
|
88
|
+
organizationID: !isNaN(parseInt(___skipAPIOrgId)) ? parseInt(___skipAPIOrgId) : 0,
|
|
89
|
+
requestPhase: 'run_existing_script',
|
|
90
|
+
entities: [], // not needed for this request
|
|
91
|
+
queries: [], // not needed for this request
|
|
92
|
+
};
|
|
93
|
+
return this.HandleSkipRequest(input, '',user,dataSource,0,userPayload, pubSub, md, null, null, dataContext, null)
|
|
94
|
+
}
|
|
68
95
|
|
|
69
96
|
@Query(() => AskSkipResultType)
|
|
70
97
|
async ExecuteAskSkipAnalysisQuery(
|
|
@@ -80,8 +107,6 @@ export class AskSkipResolver {
|
|
|
80
107
|
|
|
81
108
|
const {convoEntity, dataContextEntity, convoDetailEntity, dataContext} = await this.HandleSkipInitialObjectLoading(dataSource, ConversationId, UserQuestion, user, userPayload, md, DataContextId);
|
|
82
109
|
|
|
83
|
-
const OrganizationId = ___skipAPIOrgId;
|
|
84
|
-
|
|
85
110
|
// now load up the messages. We will load up ALL of the messages for this conversation, and then pass them to the Skip API
|
|
86
111
|
const messages: SkipMessage[] = await this.LoadConversationDetailsIntoSkipMessages(dataSource, convoEntity.ID, AskSkipResolver._maxHistoricalMessages);
|
|
87
112
|
|
|
@@ -89,7 +114,7 @@ export class AskSkipResolver {
|
|
|
89
114
|
messages: messages,
|
|
90
115
|
conversationID: ConversationId.toString(),
|
|
91
116
|
dataContext: <DataContext>CopyScalarsAndArrays(dataContext), // we are casting this to DataContext as we're pushing this to the Skip API, and we don't want to send the real DataContext object, just a copy of the scalar and array properties
|
|
92
|
-
organizationID: !isNaN(parseInt(
|
|
117
|
+
organizationID: !isNaN(parseInt(___skipAPIOrgId)) ? parseInt(___skipAPIOrgId) : 0,
|
|
93
118
|
requestPhase: 'initial_request',
|
|
94
119
|
entities: this.BuildSkipEntities(),
|
|
95
120
|
queries: this.BuildSkipQueries(),
|
|
@@ -586,6 +611,9 @@ export class AskSkipResolver {
|
|
|
586
611
|
}
|
|
587
612
|
}
|
|
588
613
|
else {
|
|
614
|
+
await dataContext.SaveItems(user, false); // save the data context items
|
|
615
|
+
// replace the data context copy that is in the apiRequest.
|
|
616
|
+
apiRequest.dataContext = <DataContext>CopyScalarsAndArrays(dataContext); // we are casting this to DataContext as we're pushing this to the Skip API, and we don't want to send the real DataContext object, just a copy of the scalar and array properties
|
|
589
617
|
apiRequest.requestPhase = 'data_gathering_response';
|
|
590
618
|
}
|
|
591
619
|
// we have all of the data now, add it to the data context and then submit it back to the Skip API
|