@memberjunction/server 2.15.2 → 2.16.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/dist/generated/generated.d.ts +41 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +267 -0
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts +3 -2
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +41 -5
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/dist/resolvers/InfoResolver.d.ts +9 -0
- package/dist/resolvers/InfoResolver.d.ts.map +1 -0
- package/dist/resolvers/InfoResolver.js +41 -0
- package/dist/resolvers/InfoResolver.js.map +1 -0
- package/package.json +23 -23
- package/src/generated/generated.ts +167 -1
- package/src/resolvers/AskSkipResolver.ts +50 -7
- package/src/resolvers/InfoResolver.ts +19 -0
|
@@ -18,7 +18,7 @@ import { mj_core_schema } from '../config.js';
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, AIPromptEntity, AIResultCacheEntity, AIPromptCategoryEntity, AIPromptTypeEntity, CompanyEntity, EmployeeEntity, UserFavoriteEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, RoleEntity, SkillEntity, IntegrationURLFormatEntity, IntegrationEntity, CompanyIntegrationEntity, EntityFieldEntity, EntityEntity, UserEntity, EntityRelationshipEntity, UserRecordLogEntity, UserViewEntity, CompanyIntegrationRunEntity, CompanyIntegrationRunDetailEntity, ErrorLogEntity, ApplicationEntity, ApplicationEntityEntity, EntityPermissionEntity, UserApplicationEntityEntity, UserApplicationEntity, CompanyIntegrationRunAPILogEntity, ListEntity, ListDetailEntity, UserViewRunEntity, UserViewRunDetailEntity, WorkflowRunEntity, WorkflowEntity, WorkflowEngineEntity, RecordChangeEntity, UserRoleEntity, RowLevelSecurityFilterEntity, AuditLogEntity, AuthorizationEntity, AuthorizationRoleEntity, AuditLogTypeEntity, EntityFieldValueEntity, AIModelEntity, AIActionEntity, AIModelActionEntity, EntityAIActionEntity, AIModelTypeEntity, QueueTypeEntity, QueueEntity, QueueTaskEntity, DashboardEntity, OutputTriggerTypeEntity, OutputFormatTypeEntity, OutputDeliveryTypeEntity, ReportEntity, ReportSnapshotEntity, ResourceTypeEntity, TagEntity, TaggedItemEntity, WorkspaceEntity, WorkspaceItemEntity, DatasetEntity, DatasetItemEntity, ConversationDetailEntity, ConversationEntity, UserNotificationEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity, DataContextItemEntity, DataContextEntity, UserViewCategoryEntity, DashboardCategoryEntity, ReportCategoryEntity, FileStorageProviderEntity, FileEntity, FileCategoryEntity, FileEntityRecordLinkEntity, VersionInstallationEntity, DuplicateRunDetailMatchEntity, EntityDocumentSettingEntity, EntitySettingEntity, DuplicateRunEntity, DuplicateRunDetailEntity, ApplicationSettingEntity, ActionCategoryEntity, EntityActionEntity, EntityActionInvocationEntity, ActionAuthorizationEntity, EntityActionInvocationTypeEntity, ActionEntity, EntityActionFilterEntity, ActionFilterEntity, ActionContextTypeEntity, ActionResultCodeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionParamEntity, ActionLibraryEntity, LibraryEntity, ListCategoryEntity, CommunicationProviderEntity, CommunicationRunEntity, CommunicationProviderMessageTypeEntity, CommunicationLogEntity, CommunicationBaseMessageTypeEntity, TemplateEntity, TemplateCategoryEntity, TemplateContentEntity, TemplateParamEntity, TemplateContentTypeEntity, RecommendationEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationItemEntity, EntityCommunicationMessageTypeEntity, EntityCommunicationFieldEntity, RecordChangeReplayRunEntity, LibraryItemEntity, EntityRelationshipDisplayComponentEntity, EntityActionParamEntity, ResourcePermissionEntity, ResourceLinkEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, flyway_schema_historyEntity } from '@memberjunction/core-entities';
|
|
21
|
+
import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, AIPromptEntity, AIResultCacheEntity, AIPromptCategoryEntity, AIPromptTypeEntity, CompanyEntity, EmployeeEntity, UserFavoriteEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, RoleEntity, SkillEntity, IntegrationURLFormatEntity, IntegrationEntity, CompanyIntegrationEntity, EntityFieldEntity, EntityEntity, UserEntity, EntityRelationshipEntity, UserRecordLogEntity, UserViewEntity, CompanyIntegrationRunEntity, CompanyIntegrationRunDetailEntity, ErrorLogEntity, ApplicationEntity, ApplicationEntityEntity, EntityPermissionEntity, UserApplicationEntityEntity, UserApplicationEntity, CompanyIntegrationRunAPILogEntity, ListEntity, ListDetailEntity, UserViewRunEntity, UserViewRunDetailEntity, WorkflowRunEntity, WorkflowEntity, WorkflowEngineEntity, RecordChangeEntity, UserRoleEntity, RowLevelSecurityFilterEntity, AuditLogEntity, AuthorizationEntity, AuthorizationRoleEntity, AuditLogTypeEntity, EntityFieldValueEntity, AIModelEntity, AIActionEntity, AIModelActionEntity, EntityAIActionEntity, AIModelTypeEntity, QueueTypeEntity, QueueEntity, QueueTaskEntity, DashboardEntity, OutputTriggerTypeEntity, OutputFormatTypeEntity, OutputDeliveryTypeEntity, ReportEntity, ReportSnapshotEntity, ResourceTypeEntity, TagEntity, TaggedItemEntity, WorkspaceEntity, WorkspaceItemEntity, DatasetEntity, DatasetItemEntity, ConversationDetailEntity, ConversationEntity, UserNotificationEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity, DataContextItemEntity, DataContextEntity, UserViewCategoryEntity, DashboardCategoryEntity, ReportCategoryEntity, FileStorageProviderEntity, FileEntity, FileCategoryEntity, FileEntityRecordLinkEntity, VersionInstallationEntity, DuplicateRunDetailMatchEntity, EntityDocumentSettingEntity, EntitySettingEntity, DuplicateRunEntity, DuplicateRunDetailEntity, ApplicationSettingEntity, ActionCategoryEntity, EntityActionEntity, EntityActionInvocationEntity, ActionAuthorizationEntity, EntityActionInvocationTypeEntity, ActionEntity, EntityActionFilterEntity, ActionFilterEntity, ActionContextTypeEntity, ActionResultCodeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionParamEntity, ActionLibraryEntity, LibraryEntity, ListCategoryEntity, CommunicationProviderEntity, CommunicationRunEntity, CommunicationProviderMessageTypeEntity, CommunicationLogEntity, CommunicationBaseMessageTypeEntity, TemplateEntity, TemplateCategoryEntity, TemplateContentEntity, TemplateParamEntity, TemplateContentTypeEntity, RecommendationEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationItemEntity, EntityCommunicationMessageTypeEntity, EntityCommunicationFieldEntity, RecordChangeReplayRunEntity, LibraryItemEntity, EntityRelationshipDisplayComponentEntity, EntityActionParamEntity, ResourcePermissionEntity, ResourceLinkEntity, QueryEntityEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, flyway_schema_historyEntity } from '@memberjunction/core-entities';
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
//****************************************************************************
|
|
@@ -4042,6 +4042,9 @@ export class Entity_ {
|
|
|
4042
4042
|
@Field(() => [ResourceType_])
|
|
4043
4043
|
ResourceTypes_EntityIDArray: ResourceType_[]; // Link to ResourceTypes
|
|
4044
4044
|
|
|
4045
|
+
@Field(() => [QueryEntity_])
|
|
4046
|
+
QueryEntities_EntityIDArray: QueryEntity_[]; // Link to QueryEntities
|
|
4047
|
+
|
|
4045
4048
|
}
|
|
4046
4049
|
|
|
4047
4050
|
//****************************************************************************
|
|
@@ -4655,6 +4658,14 @@ export class EntityResolverBase extends ResolverBase {
|
|
|
4655
4658
|
return result;
|
|
4656
4659
|
}
|
|
4657
4660
|
|
|
4661
|
+
@FieldResolver(() => [QueryEntity_])
|
|
4662
|
+
async QueryEntities_EntityIDArray(@Root() entity_: Entity_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
4663
|
+
this.CheckUserReadPermissions('Query Entities', userPayload);
|
|
4664
|
+
const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwQueryEntities] WHERE [EntityID]='${entity_.ID}' ` + this.getRowLevelSecurityWhereClause('Query Entities', userPayload, EntityPermissionType.Read, 'AND');
|
|
4665
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Entities', await dataSource.query(sSQL));
|
|
4666
|
+
return result;
|
|
4667
|
+
}
|
|
4668
|
+
|
|
4658
4669
|
@Mutation(() => Entity_)
|
|
4659
4670
|
async CreateEntity(
|
|
4660
4671
|
@Arg('input', () => CreateEntityInput) input: CreateEntityInput,
|
|
@@ -15552,6 +15563,9 @@ export class Query_ {
|
|
|
15552
15563
|
@Field(() => [QueryPermission_])
|
|
15553
15564
|
QueryPermissions_QueryIDArray: QueryPermission_[]; // Link to QueryPermissions
|
|
15554
15565
|
|
|
15566
|
+
@Field(() => [QueryEntity_])
|
|
15567
|
+
QueryEntities_QueryIDArray: QueryEntity_[]; // Link to QueryEntities
|
|
15568
|
+
|
|
15555
15569
|
}
|
|
15556
15570
|
|
|
15557
15571
|
//****************************************************************************
|
|
@@ -15715,6 +15729,14 @@ export class QueryResolver extends ResolverBase {
|
|
|
15715
15729
|
return result;
|
|
15716
15730
|
}
|
|
15717
15731
|
|
|
15732
|
+
@FieldResolver(() => [QueryEntity_])
|
|
15733
|
+
async QueryEntities_QueryIDArray(@Root() query_: Query_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
15734
|
+
this.CheckUserReadPermissions('Query Entities', userPayload);
|
|
15735
|
+
const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwQueryEntities] WHERE [QueryID]='${query_.ID}' ` + this.getRowLevelSecurityWhereClause('Query Entities', userPayload, EntityPermissionType.Read, 'AND');
|
|
15736
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Entities', await dataSource.query(sSQL));
|
|
15737
|
+
return result;
|
|
15738
|
+
}
|
|
15739
|
+
|
|
15718
15740
|
@Mutation(() => Query_)
|
|
15719
15741
|
async CreateQuery(
|
|
15720
15742
|
@Arg('input', () => CreateQueryInput) input: CreateQueryInput,
|
|
@@ -26654,6 +26676,150 @@ export class ResourceLinkResolver extends ResolverBase {
|
|
|
26654
26676
|
|
|
26655
26677
|
}
|
|
26656
26678
|
|
|
26679
|
+
//****************************************************************************
|
|
26680
|
+
// ENTITY CLASS for Query Entities
|
|
26681
|
+
//****************************************************************************
|
|
26682
|
+
@ObjectType({ description: 'Tracks which entities are involved in a given query. The Queries table stores SQL and descriptions for stored queries that can be executed and serve as examples for AI.' })
|
|
26683
|
+
export class QueryEntity_ {
|
|
26684
|
+
@Field({description: 'Unique identifier for the QueryEntity record.'})
|
|
26685
|
+
@MaxLength(16)
|
|
26686
|
+
ID: string;
|
|
26687
|
+
|
|
26688
|
+
@Field({description: 'References the ID of the query in the Queries table.'})
|
|
26689
|
+
@MaxLength(16)
|
|
26690
|
+
QueryID: string;
|
|
26691
|
+
|
|
26692
|
+
@Field({description: 'References the ID of the entity in the Entities table.'})
|
|
26693
|
+
@MaxLength(16)
|
|
26694
|
+
EntityID: string;
|
|
26695
|
+
|
|
26696
|
+
@Field()
|
|
26697
|
+
@MaxLength(10)
|
|
26698
|
+
_mj__CreatedAt: Date;
|
|
26699
|
+
|
|
26700
|
+
@Field()
|
|
26701
|
+
@MaxLength(10)
|
|
26702
|
+
_mj__UpdatedAt: Date;
|
|
26703
|
+
|
|
26704
|
+
@Field()
|
|
26705
|
+
@MaxLength(510)
|
|
26706
|
+
Query: string;
|
|
26707
|
+
|
|
26708
|
+
@Field()
|
|
26709
|
+
@MaxLength(510)
|
|
26710
|
+
Entity: string;
|
|
26711
|
+
|
|
26712
|
+
}
|
|
26713
|
+
|
|
26714
|
+
//****************************************************************************
|
|
26715
|
+
// INPUT TYPE for Query Entities
|
|
26716
|
+
//****************************************************************************
|
|
26717
|
+
@InputType()
|
|
26718
|
+
export class CreateQueryEntityInput {
|
|
26719
|
+
@Field()
|
|
26720
|
+
QueryID: string;
|
|
26721
|
+
|
|
26722
|
+
@Field()
|
|
26723
|
+
EntityID: string;
|
|
26724
|
+
}
|
|
26725
|
+
|
|
26726
|
+
|
|
26727
|
+
//****************************************************************************
|
|
26728
|
+
// INPUT TYPE for Query Entities
|
|
26729
|
+
//****************************************************************************
|
|
26730
|
+
@InputType()
|
|
26731
|
+
export class UpdateQueryEntityInput {
|
|
26732
|
+
@Field()
|
|
26733
|
+
ID: string;
|
|
26734
|
+
|
|
26735
|
+
@Field()
|
|
26736
|
+
QueryID: string;
|
|
26737
|
+
|
|
26738
|
+
@Field()
|
|
26739
|
+
EntityID: string;
|
|
26740
|
+
|
|
26741
|
+
@Field(() => [KeyValuePairInput], { nullable: true })
|
|
26742
|
+
OldValues___?: KeyValuePairInput[];
|
|
26743
|
+
}
|
|
26744
|
+
|
|
26745
|
+
//****************************************************************************
|
|
26746
|
+
// RESOLVER for Query Entities
|
|
26747
|
+
//****************************************************************************
|
|
26748
|
+
@ObjectType()
|
|
26749
|
+
export class RunQueryEntityViewResult {
|
|
26750
|
+
@Field(() => [QueryEntity_])
|
|
26751
|
+
Results: QueryEntity_[];
|
|
26752
|
+
|
|
26753
|
+
@Field(() => String, {nullable: true})
|
|
26754
|
+
UserViewRunID?: string;
|
|
26755
|
+
|
|
26756
|
+
@Field(() => Int, {nullable: true})
|
|
26757
|
+
RowCount: number;
|
|
26758
|
+
|
|
26759
|
+
@Field(() => Int, {nullable: true})
|
|
26760
|
+
TotalRowCount: number;
|
|
26761
|
+
|
|
26762
|
+
@Field(() => Int, {nullable: true})
|
|
26763
|
+
ExecutionTime: number;
|
|
26764
|
+
|
|
26765
|
+
@Field({nullable: true})
|
|
26766
|
+
ErrorMessage?: string;
|
|
26767
|
+
|
|
26768
|
+
@Field(() => Boolean, {nullable: false})
|
|
26769
|
+
Success: boolean;
|
|
26770
|
+
}
|
|
26771
|
+
|
|
26772
|
+
@Resolver(QueryEntity_)
|
|
26773
|
+
export class QueryEntityResolver extends ResolverBase {
|
|
26774
|
+
@Query(() => RunQueryEntityViewResult)
|
|
26775
|
+
async RunQueryEntityViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
26776
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
26777
|
+
}
|
|
26778
|
+
|
|
26779
|
+
@Query(() => RunQueryEntityViewResult)
|
|
26780
|
+
async RunQueryEntityViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
26781
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
26782
|
+
}
|
|
26783
|
+
|
|
26784
|
+
@Query(() => RunQueryEntityViewResult)
|
|
26785
|
+
async RunQueryEntityDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
26786
|
+
input.EntityName = 'Query Entities';
|
|
26787
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
26788
|
+
}
|
|
26789
|
+
@Query(() => QueryEntity_, { nullable: true })
|
|
26790
|
+
async QueryEntity(@Arg('ID', () => String) ID: string, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<QueryEntity_ | null> {
|
|
26791
|
+
this.CheckUserReadPermissions('Query Entities', userPayload);
|
|
26792
|
+
const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwQueryEntities] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('Query Entities', userPayload, EntityPermissionType.Read, 'AND');
|
|
26793
|
+
const result = this.MapFieldNamesToCodeNames('Query Entities', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
26794
|
+
return result;
|
|
26795
|
+
}
|
|
26796
|
+
|
|
26797
|
+
@Mutation(() => QueryEntity_)
|
|
26798
|
+
async CreateQueryEntity(
|
|
26799
|
+
@Arg('input', () => CreateQueryEntityInput) input: CreateQueryEntityInput,
|
|
26800
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
26801
|
+
@PubSub() pubSub: PubSubEngine
|
|
26802
|
+
) {
|
|
26803
|
+
return this.CreateRecord('Query Entities', input, dataSource, userPayload, pubSub)
|
|
26804
|
+
}
|
|
26805
|
+
|
|
26806
|
+
@Mutation(() => QueryEntity_)
|
|
26807
|
+
async UpdateQueryEntity(
|
|
26808
|
+
@Arg('input', () => UpdateQueryEntityInput) input: UpdateQueryEntityInput,
|
|
26809
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
26810
|
+
@PubSub() pubSub: PubSubEngine
|
|
26811
|
+
) {
|
|
26812
|
+
return this.UpdateRecord('Query Entities', input, dataSource, userPayload, pubSub);
|
|
26813
|
+
}
|
|
26814
|
+
|
|
26815
|
+
@Mutation(() => QueryEntity_)
|
|
26816
|
+
async DeleteQueryEntity(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
26817
|
+
const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
|
|
26818
|
+
return this.DeleteRecord('Query Entities', key, options, dataSource, userPayload, pubSub);
|
|
26819
|
+
}
|
|
26820
|
+
|
|
26821
|
+
}
|
|
26822
|
+
|
|
26657
26823
|
//****************************************************************************
|
|
26658
26824
|
// ENTITY CLASS for Content Process Runs
|
|
26659
26825
|
//****************************************************************************
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
SkipAPIRunScriptRequest,
|
|
19
19
|
SkipAPIRequestAPIKey,
|
|
20
20
|
SkipRequestPhase,
|
|
21
|
+
SkipAPIAgentNote,
|
|
21
22
|
} from '@memberjunction/skip-types';
|
|
22
23
|
|
|
23
24
|
import { PUSH_STATUS_UPDATES_TOPIC } from '../generic/PushStatusResolver.js';
|
|
@@ -75,7 +76,7 @@ export class AskSkipResultType {
|
|
|
75
76
|
@Resolver(AskSkipResultType)
|
|
76
77
|
export class AskSkipResolver {
|
|
77
78
|
private static _defaultNewChatName = 'New Chat';
|
|
78
|
-
private static _maxHistoricalMessages =
|
|
79
|
+
private static _maxHistoricalMessages = 30;
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* Handles a simple chat request from a user to Skip, using a particular data record
|
|
@@ -146,7 +147,7 @@ export class AskSkipResolver {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
const input = this.buildSkipAPIRequest(messages, ConversationId, dataContext, 'chat_with_a_record', false, false);
|
|
150
|
+
const input = await this.buildSkipAPIRequest(messages, ConversationId, dataContext, 'chat_with_a_record', false, false, false, user);
|
|
150
151
|
messages.push({
|
|
151
152
|
content: UserQuestion,
|
|
152
153
|
role: 'user',
|
|
@@ -219,16 +220,19 @@ export class AskSkipResolver {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
protected buildSkipAPIRequest(
|
|
223
|
+
protected async buildSkipAPIRequest(
|
|
223
224
|
messages: SkipMessage[],
|
|
224
225
|
conversationId: string,
|
|
225
226
|
dataContext: DataContext,
|
|
226
227
|
requestPhase: SkipRequestPhase,
|
|
227
228
|
includeEntities: boolean,
|
|
228
|
-
includeQueries: boolean
|
|
229
|
-
|
|
229
|
+
includeQueries: boolean,
|
|
230
|
+
includeNotes: boolean,
|
|
231
|
+
contextUser: UserInfo
|
|
232
|
+
): Promise<SkipAPIRequest> {
|
|
230
233
|
const entities = includeEntities ? this.BuildSkipEntities() : [];
|
|
231
234
|
const queries = includeQueries ? this.BuildSkipQueries() : [];
|
|
235
|
+
const notes = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : [];
|
|
232
236
|
const input: SkipAPIRequest = {
|
|
233
237
|
apiKeys: this.buildSkipAPIKeys(),
|
|
234
238
|
organizationInfo: configInfo?.askSkip?.organizationInfo,
|
|
@@ -239,6 +243,7 @@ export class AskSkipResolver {
|
|
|
239
243
|
requestPhase: requestPhase,
|
|
240
244
|
entities: entities,
|
|
241
245
|
queries: queries,
|
|
246
|
+
notes: notes
|
|
242
247
|
};
|
|
243
248
|
return input;
|
|
244
249
|
}
|
|
@@ -260,7 +265,7 @@ export class AskSkipResolver {
|
|
|
260
265
|
if (!user) throw new Error(`User ${userPayload.email} not found in UserCache`);
|
|
261
266
|
const dataContext: DataContext = new DataContext();
|
|
262
267
|
await dataContext.Load(DataContextId, dataSource, true, false, 0, user);
|
|
263
|
-
const input = this.buildSkipAPIRequest([], '', dataContext, 'run_existing_script', false, false);
|
|
268
|
+
const input = await this.buildSkipAPIRequest([], '', dataContext, 'run_existing_script', false, false, false, user);
|
|
264
269
|
return this.handleSimpleSkipPostRequest(input);
|
|
265
270
|
}
|
|
266
271
|
|
|
@@ -319,7 +324,7 @@ export class AskSkipResolver {
|
|
|
319
324
|
);
|
|
320
325
|
|
|
321
326
|
const conversationDetailCount = 1
|
|
322
|
-
const input = this.buildSkipAPIRequest(messages, ConversationId, dataContext, 'initial_request', true, true);
|
|
327
|
+
const input = await this.buildSkipAPIRequest(messages, ConversationId, dataContext, 'initial_request', true, true, true, user);
|
|
323
328
|
|
|
324
329
|
return this.HandleSkipRequest(
|
|
325
330
|
input,
|
|
@@ -378,6 +383,44 @@ export class AskSkipResolver {
|
|
|
378
383
|
});
|
|
379
384
|
}
|
|
380
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Builds up the array of notes that are applicable for Skip to receive from MJAPI
|
|
388
|
+
*/
|
|
389
|
+
protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<SkipAPIAgentNote[]> {
|
|
390
|
+
try {
|
|
391
|
+
const md = new Metadata();
|
|
392
|
+
if (md.EntityByName('AI Agent Notes')) {
|
|
393
|
+
const rv = new RunView();
|
|
394
|
+
const result = await rv.RunView({
|
|
395
|
+
EntityName: "AI Agent Notes",
|
|
396
|
+
ExtraFilter: "Agent='Skip'"
|
|
397
|
+
}, contextUser)
|
|
398
|
+
if (result && result.Success) {
|
|
399
|
+
return result.Results.map((r) => {
|
|
400
|
+
return {
|
|
401
|
+
id: r.ID,
|
|
402
|
+
typeId: r.TypeID,
|
|
403
|
+
type: r.Type,
|
|
404
|
+
note: r.Note,
|
|
405
|
+
createdAt: r.__mj_CreatedAt,
|
|
406
|
+
updatedAt: r.__mj_UpdatedAt,
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
else
|
|
411
|
+
return [];
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
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
|
+
}
|
|
417
|
+
}
|
|
418
|
+
catch (e) {
|
|
419
|
+
LogError(e);
|
|
420
|
+
return []; // non- fatal error just return an empty array
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
381
424
|
protected BuildSkipEntities(): SkipEntityInfo[] {
|
|
382
425
|
// build the entity info for skip in its format which is
|
|
383
426
|
// narrower in scope than our native MJ metadata
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Field, ObjectType, Query, Resolver } from 'type-graphql';
|
|
2
|
+
import { Public } from '../directives/index.js';
|
|
3
|
+
import packageJson from '../../package.json' assert { type: 'json' };
|
|
4
|
+
|
|
5
|
+
@ObjectType()
|
|
6
|
+
export class Info {
|
|
7
|
+
@Field(() => String)
|
|
8
|
+
@Public()
|
|
9
|
+
Version: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Resolver(Info)
|
|
13
|
+
export class InfoResolver {
|
|
14
|
+
@Query(() => Info)
|
|
15
|
+
@Public()
|
|
16
|
+
async Info() {
|
|
17
|
+
return { Version: packageJson.version };
|
|
18
|
+
}
|
|
19
|
+
}
|