@memberjunction/server 2.16.0 → 2.17.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.
@@ -573,8 +573,11 @@ export class ResolverBase {
573
573
  return this.MapFieldNamesToCodeNames(entityName, entityObject.GetAll());
574
574
  }
575
575
  // save failed, return null
576
- else throw entityObject.LatestResult.Message;
577
- } else return null;
576
+ else
577
+ throw entityObject.LatestResult?.Message;
578
+ }
579
+ else
580
+ return null;
578
581
  }
579
582
 
580
583
  // Before/After CREATE Event Hooks for Sub-Classes to Override
@@ -19,6 +19,7 @@ import {
19
19
  SkipAPIRequestAPIKey,
20
20
  SkipRequestPhase,
21
21
  SkipAPIAgentNote,
22
+ SkipAPIAgentNoteType,
22
23
  } from '@memberjunction/skip-types';
23
24
 
24
25
  import { PUSH_STATUS_UPDATES_TOPIC } from '../generic/PushStatusResolver.js';
@@ -232,7 +233,7 @@ export class AskSkipResolver {
232
233
  ): Promise<SkipAPIRequest> {
233
234
  const entities = includeEntities ? this.BuildSkipEntities() : [];
234
235
  const queries = includeQueries ? this.BuildSkipQueries() : [];
235
- const notes = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : [];
236
+ const {notes, noteTypes} = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : {notes: [], noteTypes: []};
236
237
  const input: SkipAPIRequest = {
237
238
  apiKeys: this.buildSkipAPIKeys(),
238
239
  organizationInfo: configInfo?.askSkip?.organizationInfo,
@@ -243,7 +244,8 @@ export class AskSkipResolver {
243
244
  requestPhase: requestPhase,
244
245
  entities: entities,
245
246
  queries: queries,
246
- notes: notes
247
+ notes: notes,
248
+ noteTypes: noteTypes
247
249
  };
248
250
  return input;
249
251
  }
@@ -386,9 +388,12 @@ export class AskSkipResolver {
386
388
  /**
387
389
  * Builds up the array of notes that are applicable for Skip to receive from MJAPI
388
390
  */
389
- protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<SkipAPIAgentNote[]> {
391
+ protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<{notes: SkipAPIAgentNote[], noteTypes: SkipAPIAgentNoteType[]}> {
390
392
  try {
391
393
  const md = new Metadata();
394
+ let notes: SkipAPIAgentNote[] = [];
395
+ let noteTypes: SkipAPIAgentNoteType[] = [];
396
+
392
397
  if (md.EntityByName('AI Agent Notes')) {
393
398
  const rv = new RunView();
394
399
  const result = await rv.RunView({
@@ -396,7 +401,7 @@ export class AskSkipResolver {
396
401
  ExtraFilter: "Agent='Skip'"
397
402
  }, contextUser)
398
403
  if (result && result.Success) {
399
- return result.Results.map((r) => {
404
+ notes = result.Results.map((r) => {
400
405
  return {
401
406
  id: r.ID,
402
407
  typeId: r.TypeID,
@@ -407,17 +412,33 @@ export class AskSkipResolver {
407
412
  }
408
413
  });
409
414
  }
410
- else
411
- return [];
412
415
  }
413
416
  else {
414
417
  console.warn(`No AI Agent Notes entity found in the metadata, so no notes will be sent to Skip`);
415
- return []; // no agent notes configured in this MJ system, so not an error, just return empty array
416
418
  }
419
+
420
+ if (md.EntityByName('AI Agent Note Types')) {
421
+ const rv = new RunView();
422
+ const result = await rv.RunView({
423
+ EntityName: "AI Agent Note Types"
424
+ }, contextUser);
425
+ if (result && result.Success) {
426
+ noteTypes = result.Results.map((r) => {
427
+ return {
428
+ id: r.ID,
429
+ name: r.Name,
430
+ description: r.Description
431
+ }
432
+ });
433
+ }
434
+ }
435
+
436
+ // now return the notes and note types
437
+ return {notes, noteTypes};
417
438
  }
418
439
  catch (e) {
419
440
  LogError(e);
420
- return []; // non- fatal error just return an empty array
441
+ return {notes: [], noteTypes: []}; // non- fatal error just return empty arrays
421
442
  }
422
443
  }
423
444
 
@@ -629,7 +650,7 @@ export class AskSkipResolver {
629
650
  const md = new Metadata();
630
651
  const e = md.Entities.find((e) => e.Name === 'Conversation Details');
631
652
  const sql = `SELECT
632
- ${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''} ID, Message, Role, __mj_CreatedAt
653
+ ${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''} *
633
654
  FROM
634
655
  ${e.SchemaName}.${e.BaseView}
635
656
  WHERE
@@ -689,6 +710,13 @@ export class AskSkipResolver {
689
710
  content: skipRole === 'system' ? outputMessage : r.Message,
690
711
  role: skipRole,
691
712
  conversationDetailID: r.ID,
713
+ hiddenToUser: r.HiddenToUser,
714
+ userRating: r.UserRating,
715
+ userFeedback: r.UserFeedback,
716
+ reflectionInsights: r.ReflectionInsights,
717
+ summaryOfEarlierConveration: r.SummaryOfEarlierConversation,
718
+ createdAt: r.__mj_CreatedAt,
719
+ updatedAt: r.__mj_UpdatedAt,
692
720
  };
693
721
  return m;
694
722
  });