@memberjunction/server 1.8.0 → 2.0.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.
- package/CHANGELOG.json +160 -1
- package/CHANGELOG.md +34 -2
- package/package.json +30 -39
- package/src/apolloServer/index.ts +0 -1
- package/src/auth/newUsers.ts +4 -3
- package/src/context.ts +19 -27
- package/src/entitySubclasses/entityPermissions.server.ts +3 -3
- package/src/generated/generated.ts +13440 -12226
- package/src/generic/ResolverBase.ts +297 -172
- package/src/generic/RunViewResolver.ts +204 -14
- package/src/index.ts +18 -19
- package/src/resolvers/AskSkipResolver.ts +44 -44
- package/src/resolvers/ColorResolver.ts +3 -14
- package/src/resolvers/DatasetResolver.ts +4 -4
- package/src/resolvers/EntityCommunicationsResolver.ts +42 -20
- package/src/resolvers/FileCategoryResolver.ts +2 -2
- package/src/resolvers/FileResolver.ts +6 -4
- package/src/resolvers/MergeRecordsResolver.ts +3 -2
- package/src/resolvers/PotentialDuplicateRecordResolver.ts +48 -40
- package/src/resolvers/QueryResolver.ts +2 -2
- package/src/resolvers/ReportResolver.ts +6 -6
- package/src/resolvers/UserFavoriteResolver.ts +8 -8
- package/src/resolvers/UserResolver.ts +3 -1
- package/src/resolvers/UserViewResolver.ts +1 -1
- package/src/types.ts +21 -0
- package/tsconfig.json +3 -4
- package/dist/apolloServer/TransactionPlugin.d.ts +0 -4
- package/dist/apolloServer/TransactionPlugin.d.ts.map +0 -1
- package/dist/apolloServer/TransactionPlugin.js +0 -49
- package/dist/apolloServer/TransactionPlugin.js.map +0 -1
- package/dist/apolloServer/index.d.ts +0 -11
- package/dist/apolloServer/index.d.ts.map +0 -1
- package/dist/apolloServer/index.js +0 -27
- package/dist/apolloServer/index.js.map +0 -1
- package/dist/auth/exampleNewUserSubClass.d.ts +0 -6
- package/dist/auth/exampleNewUserSubClass.d.ts.map +0 -1
- package/dist/auth/exampleNewUserSubClass.js +0 -54
- package/dist/auth/exampleNewUserSubClass.js.map +0 -1
- package/dist/auth/index.d.ts +0 -30
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -129
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/newUsers.d.ts +0 -5
- package/dist/auth/newUsers.d.ts.map +0 -1
- package/dist/auth/newUsers.js +0 -66
- package/dist/auth/newUsers.js.map +0 -1
- package/dist/auth/tokenExpiredError.d.ts +0 -5
- package/dist/auth/tokenExpiredError.d.ts.map +0 -1
- package/dist/auth/tokenExpiredError.js +0 -16
- package/dist/auth/tokenExpiredError.js.map +0 -1
- package/dist/cache.d.ts +0 -3
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js +0 -11
- package/dist/cache.js.map +0 -1
- package/dist/config.d.ts +0 -196
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -72
- package/dist/config.js.map +0 -1
- package/dist/context.d.ts +0 -17
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -114
- package/dist/context.js.map +0 -1
- package/dist/directives/Public.d.ts +0 -4
- package/dist/directives/Public.d.ts.map +0 -1
- package/dist/directives/Public.js +0 -34
- package/dist/directives/Public.js.map +0 -1
- package/dist/directives/index.d.ts +0 -2
- package/dist/directives/index.d.ts.map +0 -1
- package/dist/directives/index.js +0 -18
- package/dist/directives/index.js.map +0 -1
- package/dist/entitySubclasses/DuplicateRunEntity.server.d.ts +0 -6
- package/dist/entitySubclasses/DuplicateRunEntity.server.d.ts.map +0 -1
- package/dist/entitySubclasses/DuplicateRunEntity.server.js +0 -37
- package/dist/entitySubclasses/DuplicateRunEntity.server.js.map +0 -1
- package/dist/entitySubclasses/EntityBehavior.server.d.ts +0 -29
- package/dist/entitySubclasses/EntityBehavior.server.d.ts.map +0 -1
- package/dist/entitySubclasses/EntityBehavior.server.js +0 -213
- package/dist/entitySubclasses/EntityBehavior.server.js.map +0 -1
- package/dist/entitySubclasses/entityPermissions.server.d.ts +0 -23
- package/dist/entitySubclasses/entityPermissions.server.d.ts.map +0 -1
- package/dist/entitySubclasses/entityPermissions.server.js +0 -99
- package/dist/entitySubclasses/entityPermissions.server.js.map +0 -1
- package/dist/entitySubclasses/userViewEntity.server.d.ts +0 -13
- package/dist/entitySubclasses/userViewEntity.server.d.ts.map +0 -1
- package/dist/entitySubclasses/userViewEntity.server.js +0 -164
- package/dist/entitySubclasses/userViewEntity.server.js.map +0 -1
- package/dist/generated/generated.d.ts +0 -6420
- package/dist/generated/generated.d.ts.map +0 -1
- package/dist/generated/generated.js +0 -34770
- package/dist/generated/generated.js.map +0 -1
- package/dist/generic/DeleteOptionsInput.d.ts +0 -5
- package/dist/generic/DeleteOptionsInput.d.ts.map +0 -1
- package/dist/generic/DeleteOptionsInput.js +0 -28
- package/dist/generic/DeleteOptionsInput.js.map +0 -1
- package/dist/generic/KeyInputOutputTypes.d.ts +0 -16
- package/dist/generic/KeyInputOutputTypes.d.ts.map +0 -1
- package/dist/generic/KeyInputOutputTypes.js +0 -62
- package/dist/generic/KeyInputOutputTypes.js.map +0 -1
- package/dist/generic/KeyValuePairInput.d.ts +0 -5
- package/dist/generic/KeyValuePairInput.d.ts.map +0 -1
- package/dist/generic/KeyValuePairInput.js +0 -28
- package/dist/generic/KeyValuePairInput.js.map +0 -1
- package/dist/generic/PushStatusResolver.d.ts +0 -14
- package/dist/generic/PushStatusResolver.d.ts.map +0 -1
- package/dist/generic/PushStatusResolver.js +0 -58
- package/dist/generic/PushStatusResolver.js.map +0 -1
- package/dist/generic/ResolverBase.d.ts +0 -37
- package/dist/generic/ResolverBase.d.ts.map +0 -1
- package/dist/generic/ResolverBase.js +0 -468
- package/dist/generic/ResolverBase.js.map +0 -1
- package/dist/generic/RunViewResolver.d.ts +0 -88
- package/dist/generic/RunViewResolver.d.ts.map +0 -1
- package/dist/generic/RunViewResolver.js +0 -443
- package/dist/generic/RunViewResolver.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -145
- package/dist/index.js.map +0 -1
- package/dist/orm.d.ts +0 -4
- package/dist/orm.d.ts.map +0 -1
- package/dist/orm.js +0 -34
- package/dist/orm.js.map +0 -1
- package/dist/resolvers/AskSkipResolver.d.ts +0 -54
- package/dist/resolvers/AskSkipResolver.d.ts.map +0 -1
- package/dist/resolvers/AskSkipResolver.js +0 -800
- package/dist/resolvers/AskSkipResolver.js.map +0 -1
- package/dist/resolvers/ColorResolver.d.ts +0 -22
- package/dist/resolvers/ColorResolver.d.ts.map +0 -1
- package/dist/resolvers/ColorResolver.js +0 -94
- package/dist/resolvers/ColorResolver.js.map +0 -1
- package/dist/resolvers/DatasetResolver.d.ts +0 -42
- package/dist/resolvers/DatasetResolver.d.ts.map +0 -1
- package/dist/resolvers/DatasetResolver.js +0 -168
- package/dist/resolvers/DatasetResolver.js.map +0 -1
- package/dist/resolvers/EntityCommunicationsResolver.d.ts +0 -49
- package/dist/resolvers/EntityCommunicationsResolver.d.ts.map +0 -1
- package/dist/resolvers/EntityCommunicationsResolver.js +0 -228
- package/dist/resolvers/EntityCommunicationsResolver.js.map +0 -1
- package/dist/resolvers/EntityRecordNameResolver.d.ts +0 -21
- package/dist/resolvers/EntityRecordNameResolver.d.ts.map +0 -1
- package/dist/resolvers/EntityRecordNameResolver.js +0 -113
- package/dist/resolvers/EntityRecordNameResolver.js.map +0 -1
- package/dist/resolvers/EntityResolver.d.ts +0 -6
- package/dist/resolvers/EntityResolver.d.ts.map +0 -1
- package/dist/resolvers/EntityResolver.js +0 -60
- package/dist/resolvers/EntityResolver.js.map +0 -1
- package/dist/resolvers/FileCategoryResolver.d.ts +0 -6
- package/dist/resolvers/FileCategoryResolver.d.ts.map +0 -1
- package/dist/resolvers/FileCategoryResolver.js +0 -65
- package/dist/resolvers/FileCategoryResolver.js.map +0 -1
- package/dist/resolvers/FileResolver.d.ts +0 -24
- package/dist/resolvers/FileResolver.d.ts.map +0 -1
- package/dist/resolvers/FileResolver.js +0 -162
- package/dist/resolvers/FileResolver.js.map +0 -1
- package/dist/resolvers/MergeRecordsResolver.d.ts +0 -59
- package/dist/resolvers/MergeRecordsResolver.d.ts.map +0 -1
- package/dist/resolvers/MergeRecordsResolver.js +0 -256
- package/dist/resolvers/MergeRecordsResolver.js.map +0 -1
- package/dist/resolvers/PotentialDuplicateRecordResolver.d.ts +0 -29
- package/dist/resolvers/PotentialDuplicateRecordResolver.d.ts.map +0 -1
- package/dist/resolvers/PotentialDuplicateRecordResolver.js +0 -127
- package/dist/resolvers/PotentialDuplicateRecordResolver.js.map +0 -1
- package/dist/resolvers/QueryResolver.d.ts +0 -13
- package/dist/resolvers/QueryResolver.d.ts.map +0 -1
- package/dist/resolvers/QueryResolver.js +0 -74
- package/dist/resolvers/QueryResolver.js.map +0 -1
- package/dist/resolvers/ReportResolver.d.ts +0 -20
- package/dist/resolvers/ReportResolver.d.ts.map +0 -1
- package/dist/resolvers/ReportResolver.js +0 -175
- package/dist/resolvers/ReportResolver.js.map +0 -1
- package/dist/resolvers/UserFavoriteResolver.d.ts +0 -42
- package/dist/resolvers/UserFavoriteResolver.d.ts.map +0 -1
- package/dist/resolvers/UserFavoriteResolver.js +0 -221
- package/dist/resolvers/UserFavoriteResolver.js.map +0 -1
- package/dist/resolvers/UserResolver.d.ts +0 -10
- package/dist/resolvers/UserResolver.d.ts.map +0 -1
- package/dist/resolvers/UserResolver.js +0 -72
- package/dist/resolvers/UserResolver.js.map +0 -1
- package/dist/resolvers/UserViewResolver.d.ts +0 -13
- package/dist/resolvers/UserViewResolver.d.ts.map +0 -1
- package/dist/resolvers/UserViewResolver.js +0 -102
- package/dist/resolvers/UserViewResolver.js.map +0 -1
- package/dist/types.d.ts +0 -17
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/util.d.ts +0 -4
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -89
- package/dist/util.js.map +0 -1
- package/src/entitySubclasses/EntityBehavior.server.ts +0 -241
|
@@ -48,13 +48,13 @@ export class AskSkipResultType {
|
|
|
48
48
|
Result: string;
|
|
49
49
|
|
|
50
50
|
@Field(() => Int)
|
|
51
|
-
ConversationId:
|
|
51
|
+
ConversationId: string;
|
|
52
52
|
|
|
53
53
|
@Field(() => Int)
|
|
54
|
-
UserMessageConversationDetailId:
|
|
54
|
+
UserMessageConversationDetailId: string;
|
|
55
55
|
|
|
56
56
|
@Field(() => Int)
|
|
57
|
-
AIMessageConversationDetailId:
|
|
57
|
+
AIMessageConversationDetailId: string;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
|
|
@@ -71,7 +71,7 @@ export class AskSkipResolver {
|
|
|
71
71
|
*/
|
|
72
72
|
@Query(() => AskSkipResultType)
|
|
73
73
|
async ExecuteAskSkipRecordChat(@Arg('UserQuestion', () => String) UserQuestion: string,
|
|
74
|
-
@Arg('ConversationId', () =>
|
|
74
|
+
@Arg('ConversationId', () => String) ConversationId: string,
|
|
75
75
|
@Arg('EntityName', () => String) EntityName: string,
|
|
76
76
|
@Arg('CompositeKey', () => CompositeKeyInputType) compositeKey: CompositeKeyInputType,
|
|
77
77
|
@Ctx() { dataSource, userPayload }: AppContext,
|
|
@@ -91,7 +91,7 @@ export class AskSkipResolver {
|
|
|
91
91
|
await this.HandleSkipInitialObjectLoading(dataSource, ConversationId, UserQuestion, user, userPayload, md, null);
|
|
92
92
|
|
|
93
93
|
// if we have a new conversation, update the data context to have an item for this record
|
|
94
|
-
if (!ConversationId || ConversationId
|
|
94
|
+
if (!ConversationId || ConversationId.length === 0) {
|
|
95
95
|
const dci = await md.GetEntityObject<DataContextItemEntity>('Data Context Items', user);
|
|
96
96
|
dci.DataContextID = dataContext.ID;
|
|
97
97
|
dci.Type = 'single_record';
|
|
@@ -126,7 +126,7 @@ export class AskSkipResolver {
|
|
|
126
126
|
return this.handleSimpleSkipPostRequest(input, convoEntity.ID, convoDetailEntity.ID, true, user);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
protected async handleSimpleSkipPostRequest(input: SkipAPIRequest, conversationID:
|
|
129
|
+
protected async handleSimpleSkipPostRequest(input: SkipAPIRequest, conversationID: string = "", UserMessageConversationDetailId: string = "", createAIMessageConversationDetail: boolean = false, user: UserInfo = null): Promise<AskSkipResultType> {
|
|
130
130
|
LogStatus(` >>> HandleSimpleSkipPostRequest Sending request to Skip API: ${___skipAPIurl}`);
|
|
131
131
|
|
|
132
132
|
const response = await sendPostRequest(___skipAPIurl, input, true, null);
|
|
@@ -134,7 +134,7 @@ export class AskSkipResolver {
|
|
|
134
134
|
if (response && response.length > 0) {
|
|
135
135
|
// the last object in the response array is the final response from the Skip API
|
|
136
136
|
const apiResponse = <SkipAPIResponse>response[response.length - 1].value;
|
|
137
|
-
const AIMessageConversationDetailID = createAIMessageConversationDetail ? await this.CreateAIMessageConversationDetail(apiResponse, conversationID, user) :
|
|
137
|
+
const AIMessageConversationDetailID = createAIMessageConversationDetail ? await this.CreateAIMessageConversationDetail(apiResponse, conversationID, user) : "";
|
|
138
138
|
// const apiResponse = <SkipAPIResponse>response.data;
|
|
139
139
|
LogStatus(` Skip API response: ${apiResponse.responsePhase}`)
|
|
140
140
|
return {
|
|
@@ -155,12 +155,12 @@ export class AskSkipResolver {
|
|
|
155
155
|
ResponsePhase: SkipResponsePhase.AnalysisComplete,
|
|
156
156
|
ConversationId: conversationID,
|
|
157
157
|
UserMessageConversationDetailId: UserMessageConversationDetailId,
|
|
158
|
-
AIMessageConversationDetailId:
|
|
158
|
+
AIMessageConversationDetailId: "",
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
protected async CreateAIMessageConversationDetail(apiResponse: SkipAPIResponse, conversationID:
|
|
163
|
+
protected async CreateAIMessageConversationDetail(apiResponse: SkipAPIResponse, conversationID: string, user: UserInfo): Promise<string> {
|
|
164
164
|
const md = new Metadata();
|
|
165
165
|
const convoDetailEntityAI = <ConversationDetailEntity>await md.GetEntityObject('Conversation Details', user);
|
|
166
166
|
convoDetailEntityAI.NewRecord();
|
|
@@ -175,11 +175,11 @@ export class AskSkipResolver {
|
|
|
175
175
|
}
|
|
176
176
|
else{
|
|
177
177
|
LogError(`Error saving conversation detail entity for AI message: ${lastSystemMessage?.content}`, undefined, convoDetailEntityAI.LatestResult);
|
|
178
|
-
return
|
|
178
|
+
return "";
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
protected buildSkipAPIRequest(messages: SkipMessage[], conversationId:
|
|
182
|
+
protected buildSkipAPIRequest(messages: SkipMessage[], conversationId: string, dataContext: DataContext, requestPhase: SkipRequestPhase, includeEntities: boolean, includeQueries: boolean): SkipAPIRequest {
|
|
183
183
|
const entities = includeEntities ? this.BuildSkipEntities() : [];
|
|
184
184
|
const queries = includeQueries ? this.BuildSkipQueries() : [];
|
|
185
185
|
const input: SkipAPIRequest = {
|
|
@@ -188,7 +188,7 @@ export class AskSkipResolver {
|
|
|
188
188
|
messages: messages,
|
|
189
189
|
conversationID: conversationId.toString(),
|
|
190
190
|
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
|
|
191
|
-
organizationID:
|
|
191
|
+
organizationID: ___skipAPIOrgId,
|
|
192
192
|
requestPhase: requestPhase,
|
|
193
193
|
entities: entities,
|
|
194
194
|
queries: queries
|
|
@@ -205,13 +205,13 @@ export class AskSkipResolver {
|
|
|
205
205
|
@Query(() => AskSkipResultType)
|
|
206
206
|
async ExecuteAskSkipRunScript(@Ctx() { dataSource, userPayload }: AppContext,
|
|
207
207
|
@PubSub() pubSub: PubSubEngine,
|
|
208
|
-
@Arg('DataContextId', () =>
|
|
208
|
+
@Arg('DataContextId', () => String) DataContextId: string,
|
|
209
209
|
@Arg('ScriptText', () => String) ScriptText: string) {
|
|
210
210
|
const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
|
|
211
211
|
if (!user) throw new Error(`User ${userPayload.email} not found in UserCache`);
|
|
212
212
|
const dataContext: DataContext = new DataContext();
|
|
213
213
|
await dataContext.Load(DataContextId, dataSource, true, false, 0, user);
|
|
214
|
-
const input = this.buildSkipAPIRequest([],
|
|
214
|
+
const input = this.buildSkipAPIRequest([], "", dataContext, 'run_existing_script', false, false);
|
|
215
215
|
return this.handleSimpleSkipPostRequest(input);
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -243,10 +243,10 @@ export class AskSkipResolver {
|
|
|
243
243
|
@Query(() => AskSkipResultType)
|
|
244
244
|
async ExecuteAskSkipAnalysisQuery(
|
|
245
245
|
@Arg('UserQuestion', () => String) UserQuestion: string,
|
|
246
|
-
@Arg('ConversationId', () =>
|
|
246
|
+
@Arg('ConversationId', () => String) ConversationId: string,
|
|
247
247
|
@Ctx() { dataSource, userPayload }: AppContext,
|
|
248
248
|
@PubSub() pubSub: PubSubEngine,
|
|
249
|
-
@Arg('DataContextId', () =>
|
|
249
|
+
@Arg('DataContextId', () => String, { nullable: true }) DataContextId?: string
|
|
250
250
|
) {
|
|
251
251
|
const md = new Metadata();
|
|
252
252
|
const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
|
|
@@ -275,8 +275,8 @@ export class AskSkipResolver {
|
|
|
275
275
|
feedback: q.Feedback,
|
|
276
276
|
status: q.Status,
|
|
277
277
|
qualityRank: q.QualityRank,
|
|
278
|
-
createdAt: q.
|
|
279
|
-
updatedAt: q.
|
|
278
|
+
createdAt: q.__mj_CreatedAt,
|
|
279
|
+
updatedAt: q.__mj_UpdatedAt,
|
|
280
280
|
categoryID: q.CategoryID,
|
|
281
281
|
fields: q.Fields.map((f) => {
|
|
282
282
|
return {
|
|
@@ -294,8 +294,8 @@ export class AskSkipResolver {
|
|
|
294
294
|
computationDescription: f.ComputationDescription,
|
|
295
295
|
isSummary: f.IsSummary,
|
|
296
296
|
summaryDescription: f.SummaryDescription,
|
|
297
|
-
createdAt: f.
|
|
298
|
-
updatedAt: f.
|
|
297
|
+
createdAt: f.__mj_CreatedAt,
|
|
298
|
+
updatedAt: f.__mj_UpdatedAt,
|
|
299
299
|
}
|
|
300
300
|
})
|
|
301
301
|
}
|
|
@@ -370,19 +370,19 @@ export class AskSkipResolver {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
protected async HandleSkipInitialObjectLoading(dataSource: DataSource,
|
|
373
|
-
ConversationId:
|
|
373
|
+
ConversationId: string,
|
|
374
374
|
UserQuestion: string,
|
|
375
375
|
user: UserInfo,
|
|
376
376
|
userPayload: UserPayload,
|
|
377
377
|
md: Metadata,
|
|
378
|
-
DataContextId:
|
|
378
|
+
DataContextId: string): Promise<{convoEntity: ConversationEntity,
|
|
379
379
|
dataContextEntity: DataContextEntity,
|
|
380
380
|
convoDetailEntity: ConversationDetailEntity,
|
|
381
381
|
dataContext: DataContext}> {
|
|
382
382
|
const convoEntity = <ConversationEntity>await md.GetEntityObject('Conversations', user);
|
|
383
383
|
let dataContextEntity: DataContextEntity;
|
|
384
384
|
|
|
385
|
-
if (!ConversationId || ConversationId
|
|
385
|
+
if (!ConversationId || ConversationId.length === 0) {
|
|
386
386
|
// create a new conversation id
|
|
387
387
|
convoEntity.NewRecord();
|
|
388
388
|
if (user) {
|
|
@@ -390,7 +390,7 @@ export class AskSkipResolver {
|
|
|
390
390
|
convoEntity.Name = AskSkipResolver._defaultNewChatName;
|
|
391
391
|
|
|
392
392
|
dataContextEntity = await md.GetEntityObject<DataContextEntity>('Data Contexts', user);
|
|
393
|
-
if (!DataContextId || DataContextId
|
|
393
|
+
if (!DataContextId || DataContextId.length === 0) {
|
|
394
394
|
dataContextEntity.NewRecord();
|
|
395
395
|
dataContextEntity.UserID = user.ID;
|
|
396
396
|
dataContextEntity.Name = 'Data Context for Skip Conversation';
|
|
@@ -408,7 +408,7 @@ export class AskSkipResolver {
|
|
|
408
408
|
convoEntity.DataContextID = dataContextEntity.ID;
|
|
409
409
|
if (await convoEntity.Save()) {
|
|
410
410
|
ConversationId = convoEntity.ID;
|
|
411
|
-
if (!DataContextId || dataContextEntity.ID
|
|
411
|
+
if (!DataContextId || dataContextEntity.ID.length === 0) {
|
|
412
412
|
// only do this if we created a new data context for this conversation
|
|
413
413
|
dataContextEntity.Name += ` ${ConversationId}`;
|
|
414
414
|
const dciSaveResult: boolean = await dataContextEntity.Save();
|
|
@@ -430,7 +430,7 @@ export class AskSkipResolver {
|
|
|
430
430
|
dataContextEntity = await md.GetEntityObject<DataContextEntity>('Data Contexts', user);
|
|
431
431
|
|
|
432
432
|
// note - we ignore the parameter DataContextId if it is passed in, we will use the data context from the conversation that is saved. If a user wants to change the data context for a convo, they can do that elsewhere
|
|
433
|
-
if (DataContextId && DataContextId > 0 && DataContextId !== convoEntity.DataContextID) {
|
|
433
|
+
if (DataContextId && DataContextId.length > 0 && DataContextId !== convoEntity.DataContextID) {
|
|
434
434
|
if (convoEntity.DataContextID === null) {
|
|
435
435
|
convoEntity.DataContextID = DataContextId;
|
|
436
436
|
const convoEntitySaveResult: boolean = await convoEntity.Save();
|
|
@@ -464,29 +464,29 @@ export class AskSkipResolver {
|
|
|
464
464
|
return {dataContext, convoEntity, dataContextEntity, convoDetailEntity};
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
protected async LoadConversationDetailsIntoSkipMessages(dataSource: DataSource, ConversationId:
|
|
467
|
+
protected async LoadConversationDetailsIntoSkipMessages(dataSource: DataSource, ConversationId: string, maxHistoricalMessages?: number): Promise<SkipMessage[]> {
|
|
468
468
|
try {
|
|
469
469
|
// load up all the conversation details from the database server
|
|
470
470
|
const md = new Metadata();
|
|
471
471
|
const e = md.Entities.find((e) => e.Name === 'Conversation Details');
|
|
472
472
|
const sql = `SELECT
|
|
473
|
-
${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''} ID, Message, Role,
|
|
473
|
+
${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''} ID, Message, Role, __mj_CreatedAt
|
|
474
474
|
FROM
|
|
475
475
|
${e.SchemaName}.${e.BaseView}
|
|
476
476
|
WHERE
|
|
477
|
-
ConversationID = ${ConversationId}
|
|
477
|
+
ConversationID = '${ConversationId}'
|
|
478
478
|
ORDER
|
|
479
|
-
BY
|
|
479
|
+
BY __mj_CreatedAt DESC`;
|
|
480
480
|
const result = await dataSource.query(sql);
|
|
481
481
|
if (!result)
|
|
482
482
|
throw new Error(`Error running SQL: ${sql}`);
|
|
483
483
|
else {
|
|
484
|
-
// first, let's sort the result array into a local variable called returnData and in that we will sort by
|
|
484
|
+
// first, let's sort the result array into a local variable called returnData and in that we will sort by __mj_CreatedAt in ASCENDING order so we have the right chronological order
|
|
485
485
|
// the reason we're doing a LOCAL sort here is because in the SQL query above, we're sorting in DESCENDING order so we can use the TOP clause to limit the number of records and get the
|
|
486
486
|
// N most recent records. We want to sort in ASCENDING order because we want to send the messages to the Skip API in the order they were created.
|
|
487
487
|
const returnData = result.sort((a: any, b: any) => {
|
|
488
|
-
const aDate = new Date(a.
|
|
489
|
-
const bDate = new Date(b.
|
|
488
|
+
const aDate = new Date(a.__mj_CreatedAt);
|
|
489
|
+
const bDate = new Date(b.__mj_CreatedAt);
|
|
490
490
|
return aDate.getTime() - bDate.getTime();
|
|
491
491
|
});
|
|
492
492
|
|
|
@@ -555,7 +555,7 @@ export class AskSkipResolver {
|
|
|
555
555
|
}
|
|
556
556
|
|
|
557
557
|
protected async HandleSkipRequest(input: SkipAPIRequest, UserQuestion: string, user: UserInfo, dataSource: DataSource,
|
|
558
|
-
ConversationId:
|
|
558
|
+
ConversationId: string, userPayload: UserPayload, pubSub: PubSubEngine, md: Metadata,
|
|
559
559
|
convoEntity: ConversationEntity, convoDetailEntity: ConversationDetailEntity,
|
|
560
560
|
dataContext: DataContext, dataContextEntity: DataContextEntity): Promise<AskSkipResultType> {
|
|
561
561
|
LogStatus(` >>> HandleSkipRequest: Sending request to Skip API: ${___skipAPIurl}`);
|
|
@@ -628,13 +628,13 @@ export class AskSkipResolver {
|
|
|
628
628
|
Result: `User Question ${UserQuestion} didn't work!`,
|
|
629
629
|
ResponsePhase: SkipResponsePhase.AnalysisComplete,
|
|
630
630
|
ConversationId: ConversationId,
|
|
631
|
-
UserMessageConversationDetailId:
|
|
632
|
-
AIMessageConversationDetailId:
|
|
631
|
+
UserMessageConversationDetailId: "",
|
|
632
|
+
AIMessageConversationDetailId: "",
|
|
633
633
|
};
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
-
protected async PublishApiResponseUserUpdateMessage(apiResponse: SkipAPIResponse, userPayload: UserPayload, conversationID:
|
|
637
|
+
protected async PublishApiResponseUserUpdateMessage(apiResponse: SkipAPIResponse, userPayload: UserPayload, conversationID: string, pubSub: PubSubEngine) {
|
|
638
638
|
let sUserMessage: string = '';
|
|
639
639
|
switch (apiResponse.responsePhase) {
|
|
640
640
|
case 'data_request':
|
|
@@ -662,7 +662,7 @@ export class AskSkipResolver {
|
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
protected async HandleAnalysisComplete(apiRequest: SkipAPIRequest, apiResponse: SkipAPIAnalysisCompleteResponse, UserQuestion: string, user: UserInfo, dataSource: DataSource,
|
|
665
|
-
ConversationId:
|
|
665
|
+
ConversationId: string, userPayload: UserPayload, pubSub: PubSubEngine, convoEntity: ConversationEntity, convoDetailEntity: ConversationDetailEntity,
|
|
666
666
|
dataContext: DataContext, dataContextEntity: DataContextEntity): Promise<AskSkipResultType> {
|
|
667
667
|
// analysis is complete
|
|
668
668
|
// all done, wrap things up
|
|
@@ -681,7 +681,7 @@ export class AskSkipResolver {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
protected async HandleClarifyingQuestionPhase(apiRequest: SkipAPIRequest, apiResponse: SkipAPIClarifyingQuestionResponse, UserQuestion: string, user: UserInfo, dataSource: DataSource,
|
|
684
|
-
ConversationId:
|
|
684
|
+
ConversationId: string, userPayload: UserPayload, pubSub: PubSubEngine, convoEntity: ConversationEntity, convoDetailEntity: ConversationDetailEntity): Promise<AskSkipResultType> {
|
|
685
685
|
// need to create a message here in the COnversation and then pass that id below
|
|
686
686
|
const md = new Metadata();
|
|
687
687
|
const convoDetailEntityAI = <ConversationDetailEntity>await md.GetEntityObject('Conversation Details', user);
|
|
@@ -716,7 +716,7 @@ export class AskSkipResolver {
|
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
protected async HandleDataRequestPhase(apiRequest: SkipAPIRequest, apiResponse: SkipAPIDataRequestResponse, UserQuestion: string, user: UserInfo, dataSource: DataSource,
|
|
719
|
-
ConversationId:
|
|
719
|
+
ConversationId: string, userPayload: UserPayload, pubSub: PubSubEngine, convoEntity: ConversationEntity, convoDetailEntity: ConversationDetailEntity,
|
|
720
720
|
dataContext: DataContext, dataContextEntity: DataContextEntity): Promise<AskSkipResultType> {
|
|
721
721
|
// our job in this method is to go through each of the data requests from the Skip API, get the data, and then go back to the Skip API again and to the next phase
|
|
722
722
|
try {
|
|
@@ -728,7 +728,7 @@ export class AskSkipResolver {
|
|
|
728
728
|
ResponsePhase: SkipResponsePhase.DataRequest,
|
|
729
729
|
ConversationId: ConversationId,
|
|
730
730
|
UserMessageConversationDetailId: convoDetailEntity.ID,
|
|
731
|
-
AIMessageConversationDetailId:
|
|
731
|
+
AIMessageConversationDetailId: "",
|
|
732
732
|
Result: JSON.stringify(apiResponse)
|
|
733
733
|
};
|
|
734
734
|
}
|
|
@@ -806,7 +806,7 @@ export class AskSkipResolver {
|
|
|
806
806
|
ResponsePhase: SkipResponsePhase.DataRequest,
|
|
807
807
|
ConversationId: ConversationId,
|
|
808
808
|
UserMessageConversationDetailId: convoDetailEntity.ID,
|
|
809
|
-
AIMessageConversationDetailId:
|
|
809
|
+
AIMessageConversationDetailId: "",
|
|
810
810
|
Result: JSON.stringify(apiResponse)
|
|
811
811
|
};
|
|
812
812
|
}
|
|
@@ -846,7 +846,7 @@ export class AskSkipResolver {
|
|
|
846
846
|
* @param userPayload
|
|
847
847
|
* @returns
|
|
848
848
|
*/
|
|
849
|
-
protected async FinishConversationAndNotifyUser(apiResponse: SkipAPIAnalysisCompleteResponse, dataContext: DataContext, dataContextEntity: DataContextEntity, md: Metadata, user: UserInfo, convoEntity: ConversationEntity, pubSub: PubSubEngine, userPayload: UserPayload): Promise<{AIMessageConversationDetailID:
|
|
849
|
+
protected async FinishConversationAndNotifyUser(apiResponse: SkipAPIAnalysisCompleteResponse, dataContext: DataContext, dataContextEntity: DataContextEntity, md: Metadata, user: UserInfo, convoEntity: ConversationEntity, pubSub: PubSubEngine, userPayload: UserPayload): Promise<{AIMessageConversationDetailID: string}> {
|
|
850
850
|
const sTitle = apiResponse.reportTitle;
|
|
851
851
|
const sResult = JSON.stringify(apiResponse);
|
|
852
852
|
|
|
@@ -913,7 +913,7 @@ export class AskSkipResolver {
|
|
|
913
913
|
};
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
protected async getViewData(ViewId:
|
|
916
|
+
protected async getViewData(ViewId: string, user: UserInfo): Promise<any> {
|
|
917
917
|
const rv = new RunView();
|
|
918
918
|
const result = await rv.RunView({ViewID: ViewId, IgnoreMaxRows: true}, user);
|
|
919
919
|
if (result && result.Success)
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Field,
|
|
5
|
-
Int,
|
|
6
|
-
ObjectType,
|
|
7
|
-
PubSub,
|
|
8
|
-
PubSubEngine,
|
|
9
|
-
Public,
|
|
10
|
-
Query,
|
|
11
|
-
Resolver,
|
|
12
|
-
Root,
|
|
13
|
-
Subscription,
|
|
14
|
-
} from '@memberjunction/server';
|
|
1
|
+
import { AppContext } from '../types';
|
|
2
|
+
import { Ctx, Field, Int, ObjectType, PubSub, PubSubEngine, Query, Resolver, Root, Subscription } from 'type-graphql';
|
|
3
|
+
import { Public } from '../directives';
|
|
15
4
|
|
|
16
5
|
@ObjectType()
|
|
17
6
|
export class Color {
|
|
@@ -4,8 +4,8 @@ import { LogError, Metadata } from '@memberjunction/core';
|
|
|
4
4
|
|
|
5
5
|
@ObjectType()
|
|
6
6
|
export class DatasetResultType {
|
|
7
|
-
@Field(() =>
|
|
8
|
-
DatasetID:
|
|
7
|
+
@Field(() => String)
|
|
8
|
+
DatasetID: string;
|
|
9
9
|
|
|
10
10
|
@Field(() => String)
|
|
11
11
|
DatasetName: string;
|
|
@@ -65,8 +65,8 @@ export class DatasetResolverExtended {
|
|
|
65
65
|
|
|
66
66
|
@ObjectType()
|
|
67
67
|
export class DatasetStatusResultType {
|
|
68
|
-
@Field(() =>
|
|
69
|
-
DatasetID:
|
|
68
|
+
@Field(() => String)
|
|
69
|
+
DatasetID: string;
|
|
70
70
|
|
|
71
71
|
@Field(() => String)
|
|
72
72
|
DatasetName: string;
|
|
@@ -6,6 +6,7 @@ import { EntityCommunicationsEngine } from '@memberjunction/entity-communication
|
|
|
6
6
|
import { RunViewParams } from '@memberjunction/core';
|
|
7
7
|
import { GraphQLJSONObject } from 'graphql-type-json';
|
|
8
8
|
import { TemplateEngineServer } from '@memberjunction/templates';
|
|
9
|
+
import { EntityCommunicationParams } from '@memberjunction/entity-communications-base';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@InputType()
|
|
@@ -29,10 +30,10 @@ export class CommunicationProviderMessageType {
|
|
|
29
30
|
AdditionalAttributes: string;
|
|
30
31
|
|
|
31
32
|
@Field()
|
|
32
|
-
|
|
33
|
+
_mj_CreatedAt: Date;
|
|
33
34
|
|
|
34
35
|
@Field()
|
|
35
|
-
|
|
36
|
+
_mj_UpdatedAt: Date;
|
|
36
37
|
|
|
37
38
|
@Field()
|
|
38
39
|
CommunicationProvider?: string;
|
|
@@ -71,10 +72,10 @@ export class TemplateInputType {
|
|
|
71
72
|
IsActive: boolean;
|
|
72
73
|
|
|
73
74
|
@Field()
|
|
74
|
-
|
|
75
|
+
_mj_CreatedAt: Date;
|
|
75
76
|
|
|
76
77
|
@Field()
|
|
77
|
-
|
|
78
|
+
_mj_UpdatedAt: Date;
|
|
78
79
|
|
|
79
80
|
@Field({ nullable: true})
|
|
80
81
|
Category?: string;
|
|
@@ -151,25 +152,33 @@ export class CommunicationMessageInput {
|
|
|
151
152
|
|
|
152
153
|
@ObjectType()
|
|
153
154
|
export class RunEntityCommunicationResultType {
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
@Field()
|
|
156
|
+
Success: boolean;
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
158
|
+
@Field({nullable: true})
|
|
159
|
+
ErrorMessage?: string;
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Optional, any context data that is needed to render the message template
|
|
163
|
+
*/
|
|
164
|
+
@Field(() => GraphQLJSONObject, { nullable: true })
|
|
165
|
+
public Results?: any;
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
@Resolver(RunEntityCommunicationResultType)
|
|
162
|
-
export class ReportResolver {
|
|
169
|
+
export class ReportResolver {
|
|
163
170
|
@Query(() => RunEntityCommunicationResultType)
|
|
164
|
-
async RunEntityCommunicationByViewID( @Arg('entityID', () =>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
async RunEntityCommunicationByViewID( @Arg('entityID', () => String) entityID: string,
|
|
172
|
+
@Arg('runViewByIDInput', () => RunViewByIDInput) runViewByIDInput: RunViewByIDInput,
|
|
173
|
+
@Arg('providerName', () => String) providerName: string,
|
|
174
|
+
@Arg('providerMessageTypeName', () => String) providerMessageTypeName: string,
|
|
175
|
+
@Arg('message', () => CommunicationMessageInput) message: CommunicationMessageInput,
|
|
176
|
+
@Arg('previewOnly', () => Boolean) previewOnly: boolean,
|
|
177
|
+
@Arg('includeProcessedMessages', () => Boolean) includeProcessedMessages: boolean,
|
|
178
|
+
@Ctx() { userPayload }: AppContext): Promise<RunEntityCommunicationResultType> {
|
|
170
179
|
try {
|
|
171
180
|
await EntityCommunicationsEngine.Instance.Config(false, userPayload.userRecord);
|
|
172
|
-
const newMessage = new Message(
|
|
181
|
+
const newMessage = new Message(message as unknown as Message);
|
|
173
182
|
await TemplateEngineServer.Instance.Config(false, userPayload.userRecord);
|
|
174
183
|
// for the templates, replace the values from the input with the objects from the Template Engine we have here
|
|
175
184
|
if (newMessage.BodyTemplate) {
|
|
@@ -181,8 +190,21 @@ export class ReportResolver {
|
|
|
181
190
|
if (newMessage.SubjectTemplate) {
|
|
182
191
|
newMessage.SubjectTemplate = TemplateEngineServer.Instance.FindTemplate(newMessage.SubjectTemplate.Name);
|
|
183
192
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
193
|
+
const params: EntityCommunicationParams = {
|
|
194
|
+
EntityID: entityID,
|
|
195
|
+
RunViewParams: <RunViewParams>runViewByIDInput,
|
|
196
|
+
ProviderName: providerName,
|
|
197
|
+
ProviderMessageTypeName: providerMessageTypeName,
|
|
198
|
+
Message: newMessage,
|
|
199
|
+
PreviewOnly: previewOnly,
|
|
200
|
+
IncludeProcessedMessages: includeProcessedMessages
|
|
201
|
+
}
|
|
202
|
+
const result = await EntityCommunicationsEngine.Instance.RunEntityCommunication(params);
|
|
203
|
+
return {
|
|
204
|
+
Success: result.Success,
|
|
205
|
+
ErrorMessage: result.ErrorMessage,
|
|
206
|
+
Results: includeProcessedMessages && result.Results ? {Results: result.Results} : undefined
|
|
207
|
+
};
|
|
186
208
|
}
|
|
187
209
|
catch (e) {
|
|
188
210
|
return {
|
|
@@ -190,5 +212,5 @@ export class ReportResolver {
|
|
|
190
212
|
ErrorMessage: e.message
|
|
191
213
|
}
|
|
192
214
|
}
|
|
193
|
-
}
|
|
215
|
+
}
|
|
194
216
|
}
|
|
@@ -6,7 +6,7 @@ import { FileCategoryResolver as FileCategoryResolverBase, FileCategory_ } from
|
|
|
6
6
|
|
|
7
7
|
export class FileResolver extends FileCategoryResolverBase {
|
|
8
8
|
@Mutation(() => FileCategory_)
|
|
9
|
-
async DeleteFileCategory(@Arg('ID', () =>
|
|
9
|
+
async DeleteFileCategory(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSource, userPayload }: AppContext) {
|
|
10
10
|
const key = new CompositeKey();
|
|
11
11
|
key.LoadFromSingleKeyValuePair('ID', ID);
|
|
12
12
|
if (!(await this.BeforeDelete(dataSource, key))) {
|
|
@@ -40,7 +40,7 @@ export class FileResolver extends FileCategoryResolverBase {
|
|
|
40
40
|
const rv = new RunView();
|
|
41
41
|
const filesResult = await rv.RunView({
|
|
42
42
|
EntityName: 'Files',
|
|
43
|
-
ExtraFilter:
|
|
43
|
+
ExtraFilter: `CategoryID='${fileCategoryEntity.ID}'`,
|
|
44
44
|
ResultType: 'entity_object'
|
|
45
45
|
}, user);
|
|
46
46
|
if (filesResult) {
|
|
@@ -18,11 +18,12 @@ import {
|
|
|
18
18
|
} from '@memberjunction/server';
|
|
19
19
|
import { createDownloadUrl, createUploadUrl, deleteObject, moveObject } from '@memberjunction/storage';
|
|
20
20
|
import { CreateFileInput, FileResolver as FileResolverBase, File_, UpdateFileInput } from '../generated/generated';
|
|
21
|
+
import { FieldMapper } from '@memberjunction/graphql-dataprovider';
|
|
21
22
|
|
|
22
23
|
@InputType()
|
|
23
24
|
export class CreateUploadURLInput {
|
|
24
|
-
@Field(() =>
|
|
25
|
-
FileID:
|
|
25
|
+
@Field(() => String)
|
|
26
|
+
FileID: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
@ObjectType()
|
|
@@ -70,7 +71,8 @@ export class FileResolver extends FileResolverBase {
|
|
|
70
71
|
const { updatedInput, UploadUrl } = await createUploadUrl(providerEntity, fileRecord);
|
|
71
72
|
|
|
72
73
|
// Save the file record with the updated input
|
|
73
|
-
|
|
74
|
+
const mapper = new FieldMapper();
|
|
75
|
+
fileEntity.LoadFromData(mapper.ReverseMapFields({ ...input }));
|
|
74
76
|
fileEntity.SetMany(updatedInput);
|
|
75
77
|
await fileEntity.Save();
|
|
76
78
|
const File = fileEntity.GetAll();
|
|
@@ -122,7 +124,7 @@ export class FileResolver extends FileResolverBase {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
@Mutation(() => File_)
|
|
125
|
-
async DeleteFile(@Arg('ID', () =>
|
|
127
|
+
async DeleteFile(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
126
128
|
const md = new Metadata();
|
|
127
129
|
const userInfo = this.GetUserFromPayload(userPayload);
|
|
128
130
|
|
|
@@ -59,13 +59,14 @@ export class RecordDependencyResolver {
|
|
|
59
59
|
@Query(() => [RecordDependencyResult])
|
|
60
60
|
async GetRecordDependencies(
|
|
61
61
|
@Arg('entityName', () => String) entityName: string,
|
|
62
|
-
@Arg('CompositeKey', () => CompositeKeyInputType)
|
|
62
|
+
@Arg('CompositeKey', () => CompositeKeyInputType) ckInput: CompositeKeyInputType,
|
|
63
63
|
@Ctx() { dataSource, userPayload }: AppContext,
|
|
64
64
|
@PubSub() pubSub: PubSubEngine
|
|
65
65
|
) {
|
|
66
66
|
try {
|
|
67
67
|
const md = new Metadata();
|
|
68
|
-
const
|
|
68
|
+
const ck = new CompositeKey(ckInput.KeyValuePairs);
|
|
69
|
+
const result = await md.GetRecordDependencies(entityName, ck);
|
|
69
70
|
return result;
|
|
70
71
|
}
|
|
71
72
|
catch (e) {
|