@memberjunction/server 2.30.0 → 2.32.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.
@@ -19,7 +19,7 @@ import { mj_core_schema } from '../config.js';
19
19
 
20
20
 
21
21
 
22
- import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, GeneratedCodeCategoryEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentEntity, AIAgentNoteEntity, AIAgentActionEntity, 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, AIAgentRequestEntity, QueryEntityEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIAgentLearningCycleEntity } from '@memberjunction/core-entities';
22
+ import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, GeneratedCodeCategoryEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentEntity, AIAgentNoteEntity, AIAgentActionEntity, 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, AIAgentRequestEntity, ReportUserStateEntity, QueryEntityEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIAgentLearningCycleEntity, ReportVersionEntity } from '@memberjunction/core-entities';
23
23
 
24
24
 
25
25
  //****************************************************************************
@@ -6320,6 +6320,9 @@ export class User_ {
6320
6320
  @Field(() => [AIAgentRequest_])
6321
6321
  AIAgentRequests_ResponseByUserIDArray: AIAgentRequest_[]; // Link to AIAgentRequests
6322
6322
 
6323
+ @Field(() => [ReportUserState_])
6324
+ MJ_ReportUserStates_UserIDArray: ReportUserState_[]; // Link to MJ_ReportUserStates
6325
+
6323
6326
  @Field(() => [AIAgentNote_])
6324
6327
  AIAgentNotes_UserIDArray: AIAgentNote_[]; // Link to AIAgentNotes
6325
6328
 
@@ -6790,6 +6793,15 @@ export class UserResolverBase extends ResolverBase {
6790
6793
  return result;
6791
6794
  }
6792
6795
 
6796
+ @FieldResolver(() => [ReportUserState_])
6797
+ async MJ_ReportUserStates_UserIDArray(@Root() user_: User_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
6798
+ this.CheckUserReadPermissions('MJ: Report User States', userPayload);
6799
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
6800
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwReportUserStates] WHERE [UserID]='${user_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: Report User States', userPayload, EntityPermissionType.Read, 'AND');
6801
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: Report User States', await dataSource.query(sSQL));
6802
+ return result;
6803
+ }
6804
+
6793
6805
  @FieldResolver(() => [AIAgentNote_])
6794
6806
  async AIAgentNotes_UserIDArray(@Root() user_: User_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
6795
6807
  this.CheckUserReadPermissions('AI Agent Notes', userPayload);
@@ -14339,6 +14351,12 @@ export class Report_ {
14339
14351
  @Field(() => [ReportSnapshot_])
14340
14352
  ReportSnapshots_ReportIDArray: ReportSnapshot_[]; // Link to ReportSnapshots
14341
14353
 
14354
+ @Field(() => [ReportVersion_])
14355
+ MJ_ReportVersions_ReportIDArray: ReportVersion_[]; // Link to MJ_ReportVersions
14356
+
14357
+ @Field(() => [ReportUserState_])
14358
+ MJ_ReportUserStates_ReportIDArray: ReportUserState_[]; // Link to MJ_ReportUserStates
14359
+
14342
14360
  }
14343
14361
 
14344
14362
  //****************************************************************************
@@ -14515,6 +14533,24 @@ export class ReportResolver extends ResolverBase {
14515
14533
  return result;
14516
14534
  }
14517
14535
 
14536
+ @FieldResolver(() => [ReportVersion_])
14537
+ async MJ_ReportVersions_ReportIDArray(@Root() report_: Report_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
14538
+ this.CheckUserReadPermissions('MJ: Report Versions', userPayload);
14539
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
14540
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwReportVersions] WHERE [ReportID]='${report_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: Report Versions', userPayload, EntityPermissionType.Read, 'AND');
14541
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: Report Versions', await dataSource.query(sSQL));
14542
+ return result;
14543
+ }
14544
+
14545
+ @FieldResolver(() => [ReportUserState_])
14546
+ async MJ_ReportUserStates_ReportIDArray(@Root() report_: Report_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
14547
+ this.CheckUserReadPermissions('MJ: Report User States', userPayload);
14548
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
14549
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwReportUserStates] WHERE [ReportID]='${report_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: Report User States', userPayload, EntityPermissionType.Read, 'AND');
14550
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: Report User States', await dataSource.query(sSQL));
14551
+ return result;
14552
+ }
14553
+
14518
14554
  @Mutation(() => Report_)
14519
14555
  async CreateReport(
14520
14556
  @Arg('input', () => CreateReportInput) input: CreateReportInput,
@@ -29564,6 +29600,166 @@ export class AIAgentRequestResolver extends ResolverBase {
29564
29600
 
29565
29601
  }
29566
29602
 
29603
+ //****************************************************************************
29604
+ // ENTITY CLASS for MJ: Report User States
29605
+ //****************************************************************************
29606
+ @ObjectType()
29607
+ export class ReportUserState_ {
29608
+ @Field()
29609
+ @MaxLength(16)
29610
+ ID: string;
29611
+
29612
+ @Field()
29613
+ @MaxLength(16)
29614
+ ReportID: string;
29615
+
29616
+ @Field()
29617
+ @MaxLength(16)
29618
+ UserID: string;
29619
+
29620
+ @Field({nullable: true, description: `JSON serialized state of user interaction with the report`})
29621
+ ReportState?: string;
29622
+
29623
+ @Field()
29624
+ @MaxLength(10)
29625
+ _mj__CreatedAt: Date;
29626
+
29627
+ @Field()
29628
+ @MaxLength(10)
29629
+ _mj__UpdatedAt: Date;
29630
+
29631
+ @Field()
29632
+ @MaxLength(510)
29633
+ Report: string;
29634
+
29635
+ @Field()
29636
+ @MaxLength(200)
29637
+ User: string;
29638
+
29639
+ }
29640
+
29641
+ //****************************************************************************
29642
+ // INPUT TYPE for MJ: Report User States
29643
+ //****************************************************************************
29644
+ @InputType()
29645
+ export class CreateReportUserStateInput {
29646
+ @Field({ nullable: true })
29647
+ ReportID?: string;
29648
+
29649
+ @Field({ nullable: true })
29650
+ UserID?: string;
29651
+
29652
+ @Field({ nullable: true })
29653
+ ReportState: string | null;
29654
+ }
29655
+
29656
+
29657
+ //****************************************************************************
29658
+ // INPUT TYPE for MJ: Report User States
29659
+ //****************************************************************************
29660
+ @InputType()
29661
+ export class UpdateReportUserStateInput {
29662
+ @Field()
29663
+ ID: string;
29664
+
29665
+ @Field({ nullable: true })
29666
+ ReportID?: string;
29667
+
29668
+ @Field({ nullable: true })
29669
+ UserID?: string;
29670
+
29671
+ @Field({ nullable: true })
29672
+ ReportState?: string | null;
29673
+
29674
+ @Field(() => [KeyValuePairInput], { nullable: true })
29675
+ OldValues___?: KeyValuePairInput[];
29676
+ }
29677
+
29678
+ //****************************************************************************
29679
+ // RESOLVER for MJ: Report User States
29680
+ //****************************************************************************
29681
+ @ObjectType()
29682
+ export class RunReportUserStateViewResult {
29683
+ @Field(() => [ReportUserState_])
29684
+ Results: ReportUserState_[];
29685
+
29686
+ @Field(() => String, {nullable: true})
29687
+ UserViewRunID?: string;
29688
+
29689
+ @Field(() => Int, {nullable: true})
29690
+ RowCount: number;
29691
+
29692
+ @Field(() => Int, {nullable: true})
29693
+ TotalRowCount: number;
29694
+
29695
+ @Field(() => Int, {nullable: true})
29696
+ ExecutionTime: number;
29697
+
29698
+ @Field({nullable: true})
29699
+ ErrorMessage?: string;
29700
+
29701
+ @Field(() => Boolean, {nullable: false})
29702
+ Success: boolean;
29703
+ }
29704
+
29705
+ @Resolver(ReportUserState_)
29706
+ export class ReportUserStateResolver extends ResolverBase {
29707
+ @Query(() => RunReportUserStateViewResult)
29708
+ async RunReportUserStateViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
29709
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
29710
+ return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
29711
+ }
29712
+
29713
+ @Query(() => RunReportUserStateViewResult)
29714
+ async RunReportUserStateViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
29715
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
29716
+ return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
29717
+ }
29718
+
29719
+ @Query(() => RunReportUserStateViewResult)
29720
+ async RunReportUserStateDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
29721
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
29722
+ input.EntityName = 'MJ: Report User States';
29723
+ return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
29724
+ }
29725
+ @Query(() => ReportUserState_, { nullable: true })
29726
+ async ReportUserState(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<ReportUserState_ | null> {
29727
+ this.CheckUserReadPermissions('MJ: Report User States', userPayload);
29728
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
29729
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwReportUserStates] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: Report User States', userPayload, EntityPermissionType.Read, 'AND');
29730
+ const result = this.MapFieldNamesToCodeNames('MJ: Report User States', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
29731
+ return result;
29732
+ }
29733
+
29734
+ @Mutation(() => ReportUserState_)
29735
+ async CreateReportUserState(
29736
+ @Arg('input', () => CreateReportUserStateInput) input: CreateReportUserStateInput,
29737
+ @Ctx() { dataSources, userPayload }: AppContext,
29738
+ @PubSub() pubSub: PubSubEngine
29739
+ ) {
29740
+ const dataSource = GetReadWriteDataSource(dataSources);
29741
+ return this.CreateRecord('MJ: Report User States', input, dataSource, userPayload, pubSub)
29742
+ }
29743
+
29744
+ @Mutation(() => ReportUserState_)
29745
+ async UpdateReportUserState(
29746
+ @Arg('input', () => UpdateReportUserStateInput) input: UpdateReportUserStateInput,
29747
+ @Ctx() { dataSources, userPayload }: AppContext,
29748
+ @PubSub() pubSub: PubSubEngine
29749
+ ) {
29750
+ const dataSource = GetReadWriteDataSource(dataSources);
29751
+ return this.UpdateRecord('MJ: Report User States', input, dataSource, userPayload, pubSub);
29752
+ }
29753
+
29754
+ @Mutation(() => ReportUserState_)
29755
+ async DeleteReportUserState(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
29756
+ const dataSource = GetReadWriteDataSource(dataSources);
29757
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
29758
+ return this.DeleteRecord('MJ: Report User States', key, options, dataSource, userPayload, pubSub);
29759
+ }
29760
+
29761
+ }
29762
+
29567
29763
  //****************************************************************************
29568
29764
  // ENTITY CLASS for Query Entities
29569
29765
  //****************************************************************************
@@ -32100,4 +32296,187 @@ export class AIAgentLearningCycleResolver extends ResolverBase {
32100
32296
  return this.DeleteRecord('AI Agent Learning Cycles', key, options, dataSource, userPayload, pubSub);
32101
32297
  }
32102
32298
 
32299
+ }
32300
+
32301
+ //****************************************************************************
32302
+ // ENTITY CLASS for MJ: Report Versions
32303
+ //****************************************************************************
32304
+ @ObjectType()
32305
+ export class ReportVersion_ {
32306
+ @Field()
32307
+ @MaxLength(16)
32308
+ ID: string;
32309
+
32310
+ @Field()
32311
+ @MaxLength(16)
32312
+ ReportID: string;
32313
+
32314
+ @Field(() => Int, {description: `Report version number, sequential per report starting at 1`})
32315
+ VersionNumber: number;
32316
+
32317
+ @Field({description: `Name of this report version`})
32318
+ @MaxLength(510)
32319
+ Name: string;
32320
+
32321
+ @Field({nullable: true, description: `Description of this report version`})
32322
+ Description?: string;
32323
+
32324
+ @Field({nullable: true, description: `JSON configuration of report structure, layout and logic`})
32325
+ Configuration?: string;
32326
+
32327
+ @Field(() => Boolean, {description: `Indicates if the data context was updated in this version`})
32328
+ DataContextUpdated: boolean;
32329
+
32330
+ @Field()
32331
+ @MaxLength(10)
32332
+ _mj__CreatedAt: Date;
32333
+
32334
+ @Field()
32335
+ @MaxLength(10)
32336
+ _mj__UpdatedAt: Date;
32337
+
32338
+ @Field()
32339
+ @MaxLength(510)
32340
+ Report: string;
32341
+
32342
+ }
32343
+
32344
+ //****************************************************************************
32345
+ // INPUT TYPE for MJ: Report Versions
32346
+ //****************************************************************************
32347
+ @InputType()
32348
+ export class CreateReportVersionInput {
32349
+ @Field({ nullable: true })
32350
+ ReportID?: string;
32351
+
32352
+ @Field(() => Int, { nullable: true })
32353
+ VersionNumber?: number;
32354
+
32355
+ @Field({ nullable: true })
32356
+ Name?: string;
32357
+
32358
+ @Field({ nullable: true })
32359
+ Description: string | null;
32360
+
32361
+ @Field({ nullable: true })
32362
+ Configuration: string | null;
32363
+
32364
+ @Field(() => Boolean, { nullable: true })
32365
+ DataContextUpdated?: boolean;
32366
+ }
32367
+
32368
+
32369
+ //****************************************************************************
32370
+ // INPUT TYPE for MJ: Report Versions
32371
+ //****************************************************************************
32372
+ @InputType()
32373
+ export class UpdateReportVersionInput {
32374
+ @Field()
32375
+ ID: string;
32376
+
32377
+ @Field({ nullable: true })
32378
+ ReportID?: string;
32379
+
32380
+ @Field(() => Int, { nullable: true })
32381
+ VersionNumber?: number;
32382
+
32383
+ @Field({ nullable: true })
32384
+ Name?: string;
32385
+
32386
+ @Field({ nullable: true })
32387
+ Description?: string | null;
32388
+
32389
+ @Field({ nullable: true })
32390
+ Configuration?: string | null;
32391
+
32392
+ @Field(() => Boolean, { nullable: true })
32393
+ DataContextUpdated?: boolean;
32394
+
32395
+ @Field(() => [KeyValuePairInput], { nullable: true })
32396
+ OldValues___?: KeyValuePairInput[];
32397
+ }
32398
+
32399
+ //****************************************************************************
32400
+ // RESOLVER for MJ: Report Versions
32401
+ //****************************************************************************
32402
+ @ObjectType()
32403
+ export class RunReportVersionViewResult {
32404
+ @Field(() => [ReportVersion_])
32405
+ Results: ReportVersion_[];
32406
+
32407
+ @Field(() => String, {nullable: true})
32408
+ UserViewRunID?: string;
32409
+
32410
+ @Field(() => Int, {nullable: true})
32411
+ RowCount: number;
32412
+
32413
+ @Field(() => Int, {nullable: true})
32414
+ TotalRowCount: number;
32415
+
32416
+ @Field(() => Int, {nullable: true})
32417
+ ExecutionTime: number;
32418
+
32419
+ @Field({nullable: true})
32420
+ ErrorMessage?: string;
32421
+
32422
+ @Field(() => Boolean, {nullable: false})
32423
+ Success: boolean;
32424
+ }
32425
+
32426
+ @Resolver(ReportVersion_)
32427
+ export class ReportVersionResolver extends ResolverBase {
32428
+ @Query(() => RunReportVersionViewResult)
32429
+ async RunReportVersionViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
32430
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
32431
+ return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
32432
+ }
32433
+
32434
+ @Query(() => RunReportVersionViewResult)
32435
+ async RunReportVersionViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
32436
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
32437
+ return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
32438
+ }
32439
+
32440
+ @Query(() => RunReportVersionViewResult)
32441
+ async RunReportVersionDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
32442
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
32443
+ input.EntityName = 'MJ: Report Versions';
32444
+ return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
32445
+ }
32446
+ @Query(() => ReportVersion_, { nullable: true })
32447
+ async ReportVersion(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<ReportVersion_ | null> {
32448
+ this.CheckUserReadPermissions('MJ: Report Versions', userPayload);
32449
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
32450
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwReportVersions] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: Report Versions', userPayload, EntityPermissionType.Read, 'AND');
32451
+ const result = this.MapFieldNamesToCodeNames('MJ: Report Versions', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
32452
+ return result;
32453
+ }
32454
+
32455
+ @Mutation(() => ReportVersion_)
32456
+ async CreateReportVersion(
32457
+ @Arg('input', () => CreateReportVersionInput) input: CreateReportVersionInput,
32458
+ @Ctx() { dataSources, userPayload }: AppContext,
32459
+ @PubSub() pubSub: PubSubEngine
32460
+ ) {
32461
+ const dataSource = GetReadWriteDataSource(dataSources);
32462
+ return this.CreateRecord('MJ: Report Versions', input, dataSource, userPayload, pubSub)
32463
+ }
32464
+
32465
+ @Mutation(() => ReportVersion_)
32466
+ async UpdateReportVersion(
32467
+ @Arg('input', () => UpdateReportVersionInput) input: UpdateReportVersionInput,
32468
+ @Ctx() { dataSources, userPayload }: AppContext,
32469
+ @PubSub() pubSub: PubSubEngine
32470
+ ) {
32471
+ const dataSource = GetReadWriteDataSource(dataSources);
32472
+ return this.UpdateRecord('MJ: Report Versions', input, dataSource, userPayload, pubSub);
32473
+ }
32474
+
32475
+ @Mutation(() => ReportVersion_)
32476
+ async DeleteReportVersion(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
32477
+ const dataSource = GetReadWriteDataSource(dataSources);
32478
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
32479
+ return this.DeleteRecord('MJ: Report Versions', key, options, dataSource, userPayload, pubSub);
32480
+ }
32481
+
32103
32482
  }
package/src/index.ts CHANGED
@@ -63,6 +63,7 @@ export * from './resolvers/ReportResolver.js';
63
63
  export * from './resolvers/SyncRolesUsersResolver.js';
64
64
  export * from './resolvers/SyncDataResolver.js';
65
65
  export * from './resolvers/GetDataResolver.js';
66
+ export * from './resolvers/GetDataContextDataResolver.js';
66
67
  export * from './resolvers/TransactionGroupResolver.js';
67
68
 
68
69
  export { GetReadOnlyDataSource, GetReadWriteDataSource } from './util.js';
@@ -0,0 +1,136 @@
1
+ import { Arg, Ctx, Field, ObjectType, Query } from "type-graphql";
2
+ import { AppContext } from "../types";
3
+ import { DataContext } from "@memberjunction/data-context";
4
+ import { GetReadOnlyDataSource } from "../util";
5
+ import { Metadata } from "@memberjunction/core";
6
+ import { DataContextItemEntity } from "@memberjunction/core-entities";
7
+
8
+ @ObjectType()
9
+ export class GetDataContextItemDataOutputType {
10
+ @Field(() => Boolean)
11
+ Success: boolean;
12
+
13
+ /**
14
+ * If not successful, this will be the error message.
15
+ */
16
+ @Field(() => String, { nullable: true })
17
+ ErrorMessage: string | null;
18
+
19
+ /**
20
+ * If successful, this will be the JSON for the data context item's data.
21
+ */
22
+ @Field(() => String, { nullable: true })
23
+ Result: string | null;
24
+ }
25
+
26
+ @ObjectType()
27
+ export class GetDataContextDataOutputType {
28
+ @Field(() => Boolean)
29
+ Success: boolean;
30
+
31
+ @Field(() => [String], { nullable: 'itemsAndList' }) // Allow nulls inside array & entire field nullable
32
+ ErrorMessages: (string | null)[];
33
+
34
+ /**
35
+ * Each data context item's results will be converted to JSON and returned as a string
36
+ */
37
+ @Field(() => [String], { nullable: 'itemsAndList' }) // Allow nulls inside array & entire field nullable
38
+ Results: (string | null)[];
39
+ }
40
+
41
+
42
+ export class GetDataContextDataResolver {
43
+ /**
44
+ * Returns data for a given data context item.
45
+ * @param DataContextItemID
46
+ */
47
+ @Query(() => GetDataContextItemDataOutputType)
48
+ async GetDataContextItemData(
49
+ @Arg('DataContextItemID', () => String) DataContextItemID: string,
50
+ @Ctx() appCtx: AppContext
51
+ ) {
52
+ try {
53
+ const ds = GetReadOnlyDataSource(appCtx.dataSources, {
54
+ allowFallbackToReadWrite: true,
55
+ })
56
+ const md = new Metadata();
57
+ const dciData = await md.GetEntityObject<DataContextItemEntity>("Data Context Items", appCtx.userPayload.userRecord);
58
+ if (await dciData.Load(DataContextItemID)) {
59
+ const dci = DataContext.CreateDataContextItem(); // use class factory to get whatever lowest level sub-class is registered
60
+ await dci.LoadMetadataFromEntityRecord(dciData, Metadata.Provider, appCtx.userPayload.userRecord);
61
+ // now the metadata is loaded so we can call the regular load function
62
+ if (await dci.LoadData(ds)) {
63
+ return {
64
+ Success: true,
65
+ ErrorMessage: null,
66
+ Result: JSON.stringify(dci.Data),
67
+ }
68
+ }
69
+ else {
70
+ return {
71
+ Success: false,
72
+ ErrorMessage: 'Error loading data context item data',
73
+ Result: null,
74
+ }
75
+ }
76
+ }
77
+ else {
78
+ return {
79
+ Success: false,
80
+ ErrorMessage: 'Error loading data context item metadata',
81
+ Result: null,
82
+ }
83
+ }
84
+ }
85
+ catch (e) {
86
+ return {
87
+ Success: false,
88
+ ErrorMessage: e,
89
+ Result: null,
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Returns data for a given data context.
96
+ * @param DataContextID
97
+ */
98
+ @Query(() => GetDataContextDataOutputType)
99
+ async GetDataContextData(
100
+ @Arg('DataContextID', () => String) DataContextID: string,
101
+ @Ctx() appCtx: AppContext
102
+ ) {
103
+ try {
104
+ // our job here is to load the entire data context, so we do that with the Data Context object
105
+ const dc = new DataContext();
106
+ const ds = GetReadOnlyDataSource(appCtx.dataSources, {
107
+ allowFallbackToReadWrite: true,
108
+ })
109
+ const success = await dc.Load(DataContextID, ds, true, false, 0, appCtx.userPayload.userRecord);
110
+ if (success) {
111
+ const retVal = {
112
+ Success: true,
113
+ ErrorMessages: null,
114
+ Results: dc.Items.map((item) => {
115
+ return JSON.stringify(item.Data);
116
+ }),
117
+ }
118
+ return retVal;
119
+ }
120
+ else {
121
+ return {
122
+ Success: false,
123
+ ErrorMessages: ['Error loading data context'],
124
+ Results: null,
125
+ }
126
+ }
127
+ }
128
+ catch (e) {
129
+ return {
130
+ Success: false,
131
+ ErrorMessages: [e],
132
+ Results: null,
133
+ }
134
+ }
135
+ }
136
+ }
@@ -96,7 +96,9 @@ export class SimpleEntityFieldOutputType {
96
96
  MaxLength: number;
97
97
  }
98
98
 
99
-
99
+ /**
100
+ * General purpose resolver for fetching different kinds of data payloads for SYSTEM users only.
101
+ */
100
102
  export class GetDataResolver {
101
103
  /**
102
104
  * This query will sync the specified items with the existing system. Items will be processed in order and the results of each operation will be returned in the Results array within the return value.