@memberjunction/server 3.2.0 → 3.3.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.
Files changed (53) hide show
  1. package/README.md +47 -1
  2. package/dist/auth/APIKeyScopeAuth.d.ts +51 -0
  3. package/dist/auth/APIKeyScopeAuth.d.ts.map +1 -0
  4. package/dist/auth/APIKeyScopeAuth.js +163 -0
  5. package/dist/auth/APIKeyScopeAuth.js.map +1 -0
  6. package/dist/auth/index.d.ts +1 -0
  7. package/dist/auth/index.d.ts.map +1 -1
  8. package/dist/auth/index.js +1 -0
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/context.d.ts +8 -1
  11. package/dist/context.d.ts.map +1 -1
  12. package/dist/context.js +44 -7
  13. package/dist/context.js.map +1 -1
  14. package/dist/generated/generated.d.ts +252 -2
  15. package/dist/generated/generated.d.ts.map +1 -1
  16. package/dist/generated/generated.js +1754 -209
  17. package/dist/generated/generated.js.map +1 -1
  18. package/dist/generic/ResolverBase.d.ts +2 -2
  19. package/dist/generic/ResolverBase.d.ts.map +1 -1
  20. package/dist/generic/ResolverBase.js +22 -4
  21. package/dist/generic/ResolverBase.js.map +1 -1
  22. package/dist/generic/RunViewResolver.d.ts +29 -1
  23. package/dist/generic/RunViewResolver.d.ts.map +1 -1
  24. package/dist/generic/RunViewResolver.js +143 -0
  25. package/dist/generic/RunViewResolver.js.map +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/resolvers/APIKeyResolver.d.ts +23 -0
  31. package/dist/resolvers/APIKeyResolver.d.ts.map +1 -0
  32. package/dist/resolvers/APIKeyResolver.js +191 -0
  33. package/dist/resolvers/APIKeyResolver.js.map +1 -0
  34. package/dist/resolvers/RunAIAgentResolver.js +1 -1
  35. package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
  36. package/dist/resolvers/UserResolver.d.ts.map +1 -1
  37. package/dist/resolvers/UserResolver.js +31 -1
  38. package/dist/resolvers/UserResolver.js.map +1 -1
  39. package/dist/types.d.ts +4 -1
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/types.js.map +1 -1
  42. package/package.json +46 -45
  43. package/src/auth/APIKeyScopeAuth.ts +366 -0
  44. package/src/auth/index.ts +1 -0
  45. package/src/context.ts +91 -9
  46. package/src/generated/generated.ts +987 -14
  47. package/src/generic/ResolverBase.ts +38 -5
  48. package/src/generic/RunViewResolver.ts +132 -5
  49. package/src/index.ts +2 -0
  50. package/src/resolvers/APIKeyResolver.ts +234 -0
  51. package/src/resolvers/RunAIAgentResolver.ts +1 -1
  52. package/src/resolvers/UserResolver.ts +37 -1
  53. package/src/types.ts +7 -2
@@ -19,7 +19,7 @@ import { mj_core_schema } from '../config.js';
19
19
 
20
20
 
21
21
 
22
- import { ActionAuthorizationEntity, ActionCategoryEntity, ActionContextTypeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionFilterEntity, ActionLibraryEntity, ActionParamEntity, ActionResultCodeEntity, ActionEntity, AIActionEntity, AIAgentActionEntity, AIAgentLearningCycleEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentNoteEntity, AIAgentRequestEntity, AIAgentEntity, AIModelActionEntity, AIModelTypeEntity, AIModelEntity, AIPromptCategoryEntity, AIPromptTypeEntity, AIPromptEntity, AIResultCacheEntity, ApplicationEntityEntity, ApplicationSettingEntity, ApplicationEntity, AuditLogTypeEntity, AuditLogEntity, AuthorizationRoleEntity, AuthorizationEntity, CommunicationBaseMessageTypeEntity, CommunicationLogEntity, CommunicationProviderMessageTypeEntity, CommunicationProviderEntity, CommunicationRunEntity, CompanyEntity, CompanyIntegrationRecordMapEntity, CompanyIntegrationRunAPILogEntity, CompanyIntegrationRunDetailEntity, CompanyIntegrationRunEntity, CompanyIntegrationEntity, ContentFileTypeEntity, ContentItemAttributeEntity, ContentItemTagEntity, ContentItemEntity, ContentProcessRunEntity, ContentSourceParamEntity, ContentSourceTypeParamEntity, ContentSourceTypeEntity, ContentSourceEntity, ContentTypeAttributeEntity, ContentTypeEntity, ConversationDetailEntity, ConversationEntity, DashboardCategoryEntity, DashboardEntity, DataContextItemEntity, DataContextEntity, DatasetItemEntity, DatasetEntity, DuplicateRunDetailMatchEntity, DuplicateRunDetailEntity, DuplicateRunEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, EmployeeEntity, EntityEntity, EntityActionFilterEntity, EntityActionInvocationTypeEntity, EntityActionInvocationEntity, EntityActionParamEntity, EntityActionEntity, EntityAIActionEntity, EntityCommunicationFieldEntity, EntityCommunicationMessageTypeEntity, EntityDocumentRunEntity, EntityDocumentSettingEntity, EntityDocumentTypeEntity, EntityDocumentEntity, EntityFieldValueEntity, EntityFieldEntity, EntityPermissionEntity, EntityRecordDocumentEntity, EntityRelationshipDisplayComponentEntity, EntityRelationshipEntity, EntitySettingEntity, ErrorLogEntity, ExplorerNavigationItemEntity, FileCategoryEntity, FileEntityRecordLinkEntity, FileStorageProviderEntity, FileEntity, GeneratedCodeCategoryEntity, GeneratedCodeEntity, IntegrationURLFormatEntity, IntegrationEntity, LibraryEntity, LibraryItemEntity, ListCategoryEntity, ListDetailEntity, ListEntity, AccessControlRuleEntity, AIAgentArtifactTypeEntity, AIAgentConfigurationEntity, AIAgentDataSourceEntity, AIAgentExampleEntity, AIAgentModalityEntity, AIAgentPermissionEntity, AIAgentPromptEntity, AIAgentRelationshipEntity, AIAgentRunMediaEntity, AIAgentRunStepEntity, AIAgentRunEntity, AIAgentStepPathEntity, AIAgentStepEntity, AIAgentTypeEntity, AIArchitectureEntity, AIConfigurationParamEntity, AIConfigurationEntity, AICredentialBindingEntity, AIModalityEntity, AIModelArchitectureEntity, AIModelCostEntity, AIModelModalityEntity, AIModelPriceTypeEntity, AIModelPriceUnitTypeEntity, AIModelVendorEntity, AIPromptModelEntity, AIPromptRunMediaEntity, AIPromptRunEntity, AIVendorTypeDefinitionEntity, AIVendorTypeEntity, AIVendorEntity, APIKeyScopeEntity, APIKeyUsageLogEntity, APIKeyEntity, APIScopeEntity, ArtifactPermissionEntity, ArtifactTypeEntity, ArtifactUseEntity, ArtifactVersionAttributeEntity, ArtifactVersionEntity, ArtifactEntity, CollectionArtifactEntity, CollectionPermissionEntity, CollectionEntity, ComponentDependencyEntity, ComponentLibraryEntity, ComponentLibraryLinkEntity, ComponentRegistryEntity, ComponentEntity, ConversationArtifactPermissionEntity, ConversationArtifactVersionEntity, ConversationArtifactEntity, ConversationDetailArtifactEntity, ConversationDetailAttachmentEntity, ConversationDetailRatingEntity, CredentialCategoryEntity, CredentialTypeEntity, CredentialEntity, DashboardCategoryLinkEntity, DashboardCategoryPermissionEntity, DashboardPartTypeEntity, DashboardPermissionEntity, DashboardUserPreferenceEntity, DashboardUserStateEntity, EncryptionAlgorithmEntity, EncryptionKeySourceEntity, EncryptionKeyEntity, EnvironmentEntity, FileStorageAccountEntity, ListInvitationEntity, ListShareEntity, ProjectEntity, PublicLinkEntity, QueryParameterEntity, RecordLinkEntity, ReportUserStateEntity, ReportVersionEntity, ScheduledJobRunEntity, ScheduledJobTypeEntity, ScheduledJobEntity, TaskDependencyEntity, TaskTypeEntity, TaskEntity, TestRubricEntity, TestRunFeedbackEntity, TestRunEntity, TestSuiteRunEntity, TestSuiteTestEntity, TestSuiteEntity, TestTypeEntity, TestEntity, UserNotificationPreferenceEntity, UserNotificationTypeEntity, UserSettingEntity, OutputDeliveryTypeEntity, OutputFormatTypeEntity, OutputTriggerTypeEntity, QueryEntity, QueryCategoryEntity, QueryEntityEntity, QueryFieldEntity, QueryPermissionEntity, QueueTaskEntity, QueueTypeEntity, QueueEntity, RecommendationItemEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationEntity, RecordChangeReplayRunEntity, RecordChangeEntity, RecordMergeDeletionLogEntity, RecordMergeLogEntity, ReportCategoryEntity, ReportSnapshotEntity, ReportEntity, ResourceLinkEntity, ResourcePermissionEntity, ResourceTypeEntity, RoleEntity, RowLevelSecurityFilterEntity, ScheduledActionParamEntity, ScheduledActionEntity, SchemaInfoEntity, SkillEntity, TaggedItemEntity, TagEntity, TemplateCategoryEntity, TemplateContentTypeEntity, TemplateContentEntity, TemplateParamEntity, TemplateEntity, UserApplicationEntityEntity, UserApplicationEntity, UserFavoriteEntity, UserNotificationEntity, UserRecordLogEntity, UserRoleEntity, UserViewCategoryEntity, UserViewRunDetailEntity, UserViewRunEntity, UserViewEntity, UserEntity, VectorDatabaseEntity, VectorIndexEntity, VersionInstallationEntity, WorkflowEngineEntity, WorkflowRunEntity, WorkflowEntity, WorkspaceItemEntity, WorkspaceEntity } from '@memberjunction/core-entities';
22
+ import { ActionAuthorizationEntity, ActionCategoryEntity, ActionContextTypeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionFilterEntity, ActionLibraryEntity, ActionParamEntity, ActionResultCodeEntity, ActionEntity, AIActionEntity, AIAgentActionEntity, AIAgentLearningCycleEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentNoteEntity, AIAgentRequestEntity, AIAgentEntity, AIModelActionEntity, AIModelTypeEntity, AIModelEntity, AIPromptCategoryEntity, AIPromptTypeEntity, AIPromptEntity, AIResultCacheEntity, ApplicationEntityEntity, ApplicationSettingEntity, ApplicationEntity, AuditLogTypeEntity, AuditLogEntity, AuthorizationRoleEntity, AuthorizationEntity, CommunicationBaseMessageTypeEntity, CommunicationLogEntity, CommunicationProviderMessageTypeEntity, CommunicationProviderEntity, CommunicationRunEntity, CompanyEntity, CompanyIntegrationRecordMapEntity, CompanyIntegrationRunAPILogEntity, CompanyIntegrationRunDetailEntity, CompanyIntegrationRunEntity, CompanyIntegrationEntity, ContentFileTypeEntity, ContentItemAttributeEntity, ContentItemTagEntity, ContentItemEntity, ContentProcessRunEntity, ContentSourceParamEntity, ContentSourceTypeParamEntity, ContentSourceTypeEntity, ContentSourceEntity, ContentTypeAttributeEntity, ContentTypeEntity, ConversationDetailEntity, ConversationEntity, DashboardCategoryEntity, DashboardEntity, DataContextItemEntity, DataContextEntity, DatasetItemEntity, DatasetEntity, DuplicateRunDetailMatchEntity, DuplicateRunDetailEntity, DuplicateRunEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, EmployeeEntity, EntityEntity, EntityActionFilterEntity, EntityActionInvocationTypeEntity, EntityActionInvocationEntity, EntityActionParamEntity, EntityActionEntity, EntityAIActionEntity, EntityCommunicationFieldEntity, EntityCommunicationMessageTypeEntity, EntityDocumentRunEntity, EntityDocumentSettingEntity, EntityDocumentTypeEntity, EntityDocumentEntity, EntityFieldValueEntity, EntityFieldEntity, EntityPermissionEntity, EntityRecordDocumentEntity, EntityRelationshipDisplayComponentEntity, EntityRelationshipEntity, EntitySettingEntity, ErrorLogEntity, ExplorerNavigationItemEntity, FileCategoryEntity, FileEntityRecordLinkEntity, FileStorageProviderEntity, FileEntity, GeneratedCodeCategoryEntity, GeneratedCodeEntity, IntegrationURLFormatEntity, IntegrationEntity, LibraryEntity, LibraryItemEntity, ListCategoryEntity, ListDetailEntity, ListEntity, AccessControlRuleEntity, AIAgentArtifactTypeEntity, AIAgentConfigurationEntity, AIAgentDataSourceEntity, AIAgentExampleEntity, AIAgentModalityEntity, AIAgentPermissionEntity, AIAgentPromptEntity, AIAgentRelationshipEntity, AIAgentRunMediaEntity, AIAgentRunStepEntity, AIAgentRunEntity, AIAgentStepPathEntity, AIAgentStepEntity, AIAgentTypeEntity, AIArchitectureEntity, AIConfigurationParamEntity, AIConfigurationEntity, AICredentialBindingEntity, AIModalityEntity, AIModelArchitectureEntity, AIModelCostEntity, AIModelModalityEntity, AIModelPriceTypeEntity, AIModelPriceUnitTypeEntity, AIModelVendorEntity, AIPromptModelEntity, AIPromptRunMediaEntity, AIPromptRunEntity, AIVendorTypeDefinitionEntity, AIVendorTypeEntity, AIVendorEntity, APIApplicationScopeEntity, APIApplicationEntity, APIKeyApplicationEntity, APIKeyScopeEntity, APIKeyUsageLogEntity, APIKeyEntity, APIScopeEntity, ArtifactPermissionEntity, ArtifactTypeEntity, ArtifactUseEntity, ArtifactVersionAttributeEntity, ArtifactVersionEntity, ArtifactEntity, CollectionArtifactEntity, CollectionPermissionEntity, CollectionEntity, ComponentDependencyEntity, ComponentLibraryEntity, ComponentLibraryLinkEntity, ComponentRegistryEntity, ComponentEntity, ConversationArtifactPermissionEntity, ConversationArtifactVersionEntity, ConversationArtifactEntity, ConversationDetailArtifactEntity, ConversationDetailAttachmentEntity, ConversationDetailRatingEntity, CredentialCategoryEntity, CredentialTypeEntity, CredentialEntity, DashboardCategoryLinkEntity, DashboardCategoryPermissionEntity, DashboardPartTypeEntity, DashboardPermissionEntity, DashboardUserPreferenceEntity, DashboardUserStateEntity, EncryptionAlgorithmEntity, EncryptionKeySourceEntity, EncryptionKeyEntity, EnvironmentEntity, FileStorageAccountEntity, ListInvitationEntity, ListShareEntity, ProjectEntity, PublicLinkEntity, QueryParameterEntity, RecordLinkEntity, ReportUserStateEntity, ReportVersionEntity, ScheduledJobRunEntity, ScheduledJobTypeEntity, ScheduledJobEntity, TaskDependencyEntity, TaskTypeEntity, TaskEntity, TestRubricEntity, TestRunFeedbackEntity, TestRunEntity, TestSuiteRunEntity, TestSuiteTestEntity, TestSuiteEntity, TestTypeEntity, TestEntity, UserNotificationPreferenceEntity, UserNotificationTypeEntity, UserSettingEntity, OutputDeliveryTypeEntity, OutputFormatTypeEntity, OutputTriggerTypeEntity, QueryEntity, QueryCategoryEntity, QueryEntityEntity, QueryFieldEntity, QueryPermissionEntity, QueueTaskEntity, QueueTypeEntity, QueueEntity, RecommendationItemEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationEntity, RecordChangeReplayRunEntity, RecordChangeEntity, RecordMergeDeletionLogEntity, RecordMergeLogEntity, ReportCategoryEntity, ReportSnapshotEntity, ReportEntity, ResourceLinkEntity, ResourcePermissionEntity, ResourceTypeEntity, RoleEntity, RowLevelSecurityFilterEntity, ScheduledActionParamEntity, ScheduledActionEntity, SchemaInfoEntity, SkillEntity, TaggedItemEntity, TagEntity, TemplateCategoryEntity, TemplateContentTypeEntity, TemplateContentEntity, TemplateParamEntity, TemplateEntity, UserApplicationEntityEntity, UserApplicationEntity, UserFavoriteEntity, UserNotificationEntity, UserRecordLogEntity, UserRoleEntity, UserViewCategoryEntity, UserViewRunDetailEntity, UserViewRunEntity, UserViewEntity, UserEntity, VectorDatabaseEntity, VectorIndexEntity, VersionInstallationEntity, WorkflowEngineEntity, WorkflowRunEntity, WorkflowEntity, WorkspaceItemEntity, WorkspaceEntity } from '@memberjunction/core-entities';
23
23
 
24
24
 
25
25
  //****************************************************************************
@@ -3240,6 +3240,28 @@ export class MJAIAgentNote_ {
3240
3240
  @MaxLength(16)
3241
3241
  EmbeddingModelID?: string;
3242
3242
 
3243
+ @Field({nullable: true, description: `Foreign key to Entity table identifying which entity type is used for primary scoping. NULL means this is a global note.`})
3244
+ @MaxLength(16)
3245
+ PrimaryScopeEntityID?: string;
3246
+
3247
+ @Field({nullable: true, description: `The record ID within the primary scope entity. NULL means global note. When set with empty SecondaryScopes, indicates primary-scope-only note.`})
3248
+ @MaxLength(200)
3249
+ PrimaryScopeRecordID?: string;
3250
+
3251
+ @Field({nullable: true, description: `JSON object containing additional scope dimensions. Empty/NULL with PrimaryScopeRecordID set = org-level note. Populated = fully-scoped note.`})
3252
+ SecondaryScopes?: string;
3253
+
3254
+ @Field({nullable: true, description: `Timestamp of when this note was last accessed/injected into agent context. Used for lifecycle management and cleanup.`})
3255
+ @MaxLength(10)
3256
+ LastAccessedAt?: Date;
3257
+
3258
+ @Field(() => Int, {description: `Number of times this note has been accessed/injected into agent context. Used for analytics and determining note value.`})
3259
+ AccessCount: number;
3260
+
3261
+ @Field({nullable: true, description: `Optional expiration timestamp. Notes past this date are candidates for archival. NULL means no expiration.`})
3262
+ @MaxLength(10)
3263
+ ExpiresAt?: Date;
3264
+
3243
3265
  @Field({nullable: true})
3244
3266
  @MaxLength(510)
3245
3267
  Agent?: string;
@@ -3271,6 +3293,10 @@ export class MJAIAgentNote_ {
3271
3293
  @MaxLength(100)
3272
3294
  EmbeddingModel?: string;
3273
3295
 
3296
+ @Field({nullable: true})
3297
+ @MaxLength(510)
3298
+ PrimaryScopeEntity?: string;
3299
+
3274
3300
  }
3275
3301
 
3276
3302
  //****************************************************************************
@@ -3322,6 +3348,24 @@ export class CreateMJAIAgentNoteInput {
3322
3348
 
3323
3349
  @Field({ nullable: true })
3324
3350
  EmbeddingModelID: string | null;
3351
+
3352
+ @Field({ nullable: true })
3353
+ PrimaryScopeEntityID: string | null;
3354
+
3355
+ @Field({ nullable: true })
3356
+ PrimaryScopeRecordID: string | null;
3357
+
3358
+ @Field({ nullable: true })
3359
+ SecondaryScopes: string | null;
3360
+
3361
+ @Field({ nullable: true })
3362
+ LastAccessedAt: Date | null;
3363
+
3364
+ @Field(() => Int, { nullable: true })
3365
+ AccessCount?: number;
3366
+
3367
+ @Field({ nullable: true })
3368
+ ExpiresAt: Date | null;
3325
3369
  }
3326
3370
 
3327
3371
 
@@ -3375,6 +3419,24 @@ export class UpdateMJAIAgentNoteInput {
3375
3419
  @Field({ nullable: true })
3376
3420
  EmbeddingModelID?: string | null;
3377
3421
 
3422
+ @Field({ nullable: true })
3423
+ PrimaryScopeEntityID?: string | null;
3424
+
3425
+ @Field({ nullable: true })
3426
+ PrimaryScopeRecordID?: string | null;
3427
+
3428
+ @Field({ nullable: true })
3429
+ SecondaryScopes?: string | null;
3430
+
3431
+ @Field({ nullable: true })
3432
+ LastAccessedAt?: Date | null;
3433
+
3434
+ @Field(() => Int, { nullable: true })
3435
+ AccessCount?: number;
3436
+
3437
+ @Field({ nullable: true })
3438
+ ExpiresAt?: Date | null;
3439
+
3378
3440
  @Field(() => [KeyValuePairInput], { nullable: true })
3379
3441
  OldValues___?: KeyValuePairInput[];
3380
3442
  }
@@ -3898,6 +3960,21 @@ if this limit is exceeded.`})
3898
3960
  @Field({nullable: true, description: `JSON object containing parameter values that customize how this agent's type-level system prompt is rendered. The schema is defined by the agent type's PromptParamsSchema field. Allows per-agent control over which prompt sections are included, enabling token savings by excluding unused documentation.`})
3899
3961
  AgentTypePromptParams?: string;
3900
3962
 
3963
+ @Field({nullable: true, description: `JSON configuration defining scope dimensions for multi-tenant deployments. Example: {"dimensions":[{"name":"OrganizationID","entityId":"...","isPrimary":true,"required":true},{"name":"ContactID","entityId":"...","isPrimary":false,"required":false}],"inheritanceMode":"cascading"}`})
3964
+ ScopeConfig?: string;
3965
+
3966
+ @Field(() => Int, {nullable: true, description: `Number of days to retain notes before archiving due to inactivity. Default 90. NULL means use system default.`})
3967
+ NoteRetentionDays?: number;
3968
+
3969
+ @Field(() => Int, {nullable: true, description: `Number of days to retain examples before archiving due to inactivity. Default 180. NULL means use system default.`})
3970
+ ExampleRetentionDays?: number;
3971
+
3972
+ @Field(() => Boolean, {description: `Whether automatic archival of stale notes/examples is enabled for this agent. Default true.`})
3973
+ AutoArchiveEnabled: boolean;
3974
+
3975
+ @Field({nullable: true, description: `JSON configuration for optional reranking of retrieved memory items. Schema: { enabled: boolean, rerankerModelId: string, retrievalMultiplier: number (default 3), minRelevanceThreshold: number (default 0.5), rerankPromptId?: string, contextFields?: string[], fallbackOnError: boolean (default true) }. When null or disabled, vector search results are used directly without reranking.`})
3976
+ RerankerConfiguration?: string;
3977
+
3901
3978
  @Field({nullable: true})
3902
3979
  @MaxLength(510)
3903
3980
  Parent?: string;
@@ -4160,6 +4237,21 @@ export class CreateMJAIAgentInput {
4160
4237
 
4161
4238
  @Field({ nullable: true })
4162
4239
  AgentTypePromptParams: string | null;
4240
+
4241
+ @Field({ nullable: true })
4242
+ ScopeConfig: string | null;
4243
+
4244
+ @Field(() => Int, { nullable: true })
4245
+ NoteRetentionDays?: number | null;
4246
+
4247
+ @Field(() => Int, { nullable: true })
4248
+ ExampleRetentionDays?: number | null;
4249
+
4250
+ @Field(() => Boolean, { nullable: true })
4251
+ AutoArchiveEnabled?: boolean;
4252
+
4253
+ @Field({ nullable: true })
4254
+ RerankerConfiguration: string | null;
4163
4255
  }
4164
4256
 
4165
4257
 
@@ -4330,6 +4422,21 @@ export class UpdateMJAIAgentInput {
4330
4422
  @Field({ nullable: true })
4331
4423
  AgentTypePromptParams?: string | null;
4332
4424
 
4425
+ @Field({ nullable: true })
4426
+ ScopeConfig?: string | null;
4427
+
4428
+ @Field(() => Int, { nullable: true })
4429
+ NoteRetentionDays?: number | null;
4430
+
4431
+ @Field(() => Int, { nullable: true })
4432
+ ExampleRetentionDays?: number | null;
4433
+
4434
+ @Field(() => Boolean, { nullable: true })
4435
+ AutoArchiveEnabled?: boolean;
4436
+
4437
+ @Field({ nullable: true })
4438
+ RerankerConfiguration?: string | null;
4439
+
4333
4440
  @Field(() => [KeyValuePairInput], { nullable: true })
4334
4441
  OldValues___?: KeyValuePairInput[];
4335
4442
  }
@@ -17261,6 +17368,12 @@ export class MJEntity_ {
17261
17368
  @Field(() => [MJRecordLink_])
17262
17369
  MJ_RecordLinks_SourceEntityIDArray: MJRecordLink_[]; // Link to MJ_RecordLinks
17263
17370
 
17371
+ @Field(() => [MJAIAgentExample_])
17372
+ MJ_AIAgentExamples_PrimaryScopeEntityIDArray: MJAIAgentExample_[]; // Link to MJ_AIAgentExamples
17373
+
17374
+ @Field(() => [MJAIAgentNote_])
17375
+ AIAgentNotes_PrimaryScopeEntityIDArray: MJAIAgentNote_[]; // Link to AIAgentNotes
17376
+
17264
17377
  @Field(() => [MJGeneratedCode_])
17265
17378
  GeneratedCodes_LinkedEntityIDArray: MJGeneratedCode_[]; // Link to GeneratedCodes
17266
17379
 
@@ -17270,6 +17383,9 @@ export class MJEntity_ {
17270
17383
  @Field(() => [MJTestRun_])
17271
17384
  MJ_TestRuns_TargetLogEntityIDArray: MJTestRun_[]; // Link to MJ_TestRuns
17272
17385
 
17386
+ @Field(() => [MJAIAgentRun_])
17387
+ MJ_AIAgentRuns_PrimaryScopeEntityIDArray: MJAIAgentRun_[]; // Link to MJ_AIAgentRuns
17388
+
17273
17389
  }
17274
17390
 
17275
17391
  //****************************************************************************
@@ -18093,6 +18209,28 @@ export class MJEntityResolverBase extends ResolverBase {
18093
18209
  return result;
18094
18210
  }
18095
18211
 
18212
+ @FieldResolver(() => [MJAIAgentExample_])
18213
+ async MJ_AIAgentExamples_PrimaryScopeEntityIDArray(@Root() mjentity_: MJEntity_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
18214
+ this.CheckUserReadPermissions('MJ: AI Agent Examples', userPayload);
18215
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
18216
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
18217
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentExamples] WHERE [PrimaryScopeEntityID]='${mjentity_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: AI Agent Examples', userPayload, EntityPermissionType.Read, 'AND');
18218
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
18219
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Examples', rows, this.GetUserFromPayload(userPayload));
18220
+ return result;
18221
+ }
18222
+
18223
+ @FieldResolver(() => [MJAIAgentNote_])
18224
+ async AIAgentNotes_PrimaryScopeEntityIDArray(@Root() mjentity_: MJEntity_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
18225
+ this.CheckUserReadPermissions('AI Agent Notes', userPayload);
18226
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
18227
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
18228
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentNotes] WHERE [PrimaryScopeEntityID]='${mjentity_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'AI Agent Notes', userPayload, EntityPermissionType.Read, 'AND');
18229
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
18230
+ const result = await this.ArrayMapFieldNamesToCodeNames('AI Agent Notes', rows, this.GetUserFromPayload(userPayload));
18231
+ return result;
18232
+ }
18233
+
18096
18234
  @FieldResolver(() => [MJGeneratedCode_])
18097
18235
  async GeneratedCodes_LinkedEntityIDArray(@Root() mjentity_: MJEntity_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
18098
18236
  this.CheckUserReadPermissions('Generated Codes', userPayload);
@@ -18126,6 +18264,17 @@ export class MJEntityResolverBase extends ResolverBase {
18126
18264
  return result;
18127
18265
  }
18128
18266
 
18267
+ @FieldResolver(() => [MJAIAgentRun_])
18268
+ async MJ_AIAgentRuns_PrimaryScopeEntityIDArray(@Root() mjentity_: MJEntity_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
18269
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
18270
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
18271
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
18272
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [PrimaryScopeEntityID]='${mjentity_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
18273
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
18274
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Runs', rows, this.GetUserFromPayload(userPayload));
18275
+ return result;
18276
+ }
18277
+
18129
18278
  @Mutation(() => MJEntity_)
18130
18279
  async CreateMJEntity(
18131
18280
  @Arg('input', () => CreateMJEntityInput) input: CreateMJEntityInput,
@@ -26674,6 +26823,28 @@ export class MJAIAgentExample_ {
26674
26823
  @MaxLength(16)
26675
26824
  EmbeddingModelID?: string;
26676
26825
 
26826
+ @Field({nullable: true, description: `Foreign key to Entity table identifying which entity type is used for primary scoping. NULL means this is a global example.`})
26827
+ @MaxLength(16)
26828
+ PrimaryScopeEntityID?: string;
26829
+
26830
+ @Field({nullable: true, description: `The record ID within the primary scope entity. NULL means global example. When set with empty SecondaryScopes, indicates primary-scope-only example.`})
26831
+ @MaxLength(200)
26832
+ PrimaryScopeRecordID?: string;
26833
+
26834
+ @Field({nullable: true, description: `JSON object containing additional scope dimensions. Empty/NULL with PrimaryScopeRecordID set = org-level example. Populated = fully-scoped example.`})
26835
+ SecondaryScopes?: string;
26836
+
26837
+ @Field({nullable: true, description: `Timestamp of when this example was last accessed/used for agent context. Used for lifecycle management and cleanup.`})
26838
+ @MaxLength(10)
26839
+ LastAccessedAt?: Date;
26840
+
26841
+ @Field(() => Int, {description: `Number of times this example has been accessed/used. Used for analytics and determining example value.`})
26842
+ AccessCount: number;
26843
+
26844
+ @Field({nullable: true, description: `Optional expiration timestamp. Examples past this date are candidates for archival. NULL means no expiration.`})
26845
+ @MaxLength(10)
26846
+ ExpiresAt?: Date;
26847
+
26677
26848
  @Field({nullable: true})
26678
26849
  @MaxLength(510)
26679
26850
  Agent?: string;
@@ -26701,6 +26872,10 @@ export class MJAIAgentExample_ {
26701
26872
  @MaxLength(100)
26702
26873
  EmbeddingModel?: string;
26703
26874
 
26875
+ @Field({nullable: true})
26876
+ @MaxLength(510)
26877
+ PrimaryScopeEntity?: string;
26878
+
26704
26879
  }
26705
26880
 
26706
26881
  //****************************************************************************
@@ -26755,6 +26930,24 @@ export class CreateMJAIAgentExampleInput {
26755
26930
 
26756
26931
  @Field({ nullable: true })
26757
26932
  EmbeddingModelID: string | null;
26933
+
26934
+ @Field({ nullable: true })
26935
+ PrimaryScopeEntityID: string | null;
26936
+
26937
+ @Field({ nullable: true })
26938
+ PrimaryScopeRecordID: string | null;
26939
+
26940
+ @Field({ nullable: true })
26941
+ SecondaryScopes: string | null;
26942
+
26943
+ @Field({ nullable: true })
26944
+ LastAccessedAt: Date | null;
26945
+
26946
+ @Field(() => Int, { nullable: true })
26947
+ AccessCount?: number;
26948
+
26949
+ @Field({ nullable: true })
26950
+ ExpiresAt: Date | null;
26758
26951
  }
26759
26952
 
26760
26953
 
@@ -26811,6 +27004,24 @@ export class UpdateMJAIAgentExampleInput {
26811
27004
  @Field({ nullable: true })
26812
27005
  EmbeddingModelID?: string | null;
26813
27006
 
27007
+ @Field({ nullable: true })
27008
+ PrimaryScopeEntityID?: string | null;
27009
+
27010
+ @Field({ nullable: true })
27011
+ PrimaryScopeRecordID?: string | null;
27012
+
27013
+ @Field({ nullable: true })
27014
+ SecondaryScopes?: string | null;
27015
+
27016
+ @Field({ nullable: true })
27017
+ LastAccessedAt?: Date | null;
27018
+
27019
+ @Field(() => Int, { nullable: true })
27020
+ AccessCount?: number;
27021
+
27022
+ @Field({ nullable: true })
27023
+ ExpiresAt?: Date | null;
27024
+
26814
27025
  @Field(() => [KeyValuePairInput], { nullable: true })
26815
27026
  OldValues___?: KeyValuePairInput[];
26816
27027
  }
@@ -28521,6 +28732,17 @@ each time the agent processes a prompt step.`})
28521
28732
  @MaxLength(16)
28522
28733
  TestRunID?: string;
28523
28734
 
28735
+ @Field({nullable: true, description: `Foreign key to Entity table identifying which entity type is used for primary scoping (e.g., Organizations, Tenants)`})
28736
+ @MaxLength(16)
28737
+ PrimaryScopeEntityID?: string;
28738
+
28739
+ @Field({nullable: true, description: `The record ID within the primary scope entity (e.g., the specific OrganizationID). Indexed for fast multi-tenant filtering.`})
28740
+ @MaxLength(200)
28741
+ PrimaryScopeRecordID?: string;
28742
+
28743
+ @Field({nullable: true, description: `JSON object containing additional scope dimensions beyond the primary scope. Example: {"ContactID":"abc-123","TeamID":"team-456"}`})
28744
+ SecondaryScopes?: string;
28745
+
28524
28746
  @Field({nullable: true})
28525
28747
  @MaxLength(510)
28526
28748
  Agent?: string;
@@ -28564,6 +28786,10 @@ each time the agent processes a prompt step.`})
28564
28786
  @MaxLength(510)
28565
28787
  TestRun?: string;
28566
28788
 
28789
+ @Field({nullable: true})
28790
+ @MaxLength(510)
28791
+ PrimaryScopeEntity?: string;
28792
+
28567
28793
  @Field({nullable: true})
28568
28794
  @MaxLength(16)
28569
28795
  RootParentRunID?: string;
@@ -28713,6 +28939,15 @@ export class CreateMJAIAgentRunInput {
28713
28939
 
28714
28940
  @Field({ nullable: true })
28715
28941
  TestRunID: string | null;
28942
+
28943
+ @Field({ nullable: true })
28944
+ PrimaryScopeEntityID: string | null;
28945
+
28946
+ @Field({ nullable: true })
28947
+ PrimaryScopeRecordID: string | null;
28948
+
28949
+ @Field({ nullable: true })
28950
+ SecondaryScopes: string | null;
28716
28951
  }
28717
28952
 
28718
28953
 
@@ -28838,6 +29073,15 @@ export class UpdateMJAIAgentRunInput {
28838
29073
  @Field({ nullable: true })
28839
29074
  TestRunID?: string | null;
28840
29075
 
29076
+ @Field({ nullable: true })
29077
+ PrimaryScopeEntityID?: string | null;
29078
+
29079
+ @Field({ nullable: true })
29080
+ PrimaryScopeRecordID?: string | null;
29081
+
29082
+ @Field({ nullable: true })
29083
+ SecondaryScopes?: string | null;
29084
+
28841
29085
  @Field(() => [KeyValuePairInput], { nullable: true })
28842
29086
  OldValues___?: KeyValuePairInput[];
28843
29087
  }
@@ -34516,6 +34760,555 @@ export class MJAIVendorResolver extends ResolverBase {
34516
34760
 
34517
34761
  }
34518
34762
 
34763
+ //****************************************************************************
34764
+ // ENTITY CLASS for MJ: API Application Scopes
34765
+ //****************************************************************************
34766
+ @ObjectType({ description: `Defines the scope ceiling for each application with pattern-based rules. Controls which scopes and resource patterns an application can use, regardless of what API keys grant.` })
34767
+ export class MJAPIApplicationScope_ {
34768
+ @Field()
34769
+ @MaxLength(16)
34770
+ ID: string;
34771
+
34772
+ @Field({description: `Reference to the application this ceiling rule applies to.`})
34773
+ @MaxLength(16)
34774
+ ApplicationID: string;
34775
+
34776
+ @Field({description: `Reference to the scope this rule applies to.`})
34777
+ @MaxLength(16)
34778
+ ScopeID: string;
34779
+
34780
+ @Field({nullable: true, description: `Glob pattern for matching resources (e.g., Users,Accounts or Skip* or *). NULL means match all resources.`})
34781
+ @MaxLength(1500)
34782
+ ResourcePattern?: string;
34783
+
34784
+ @Field({description: `How to interpret the pattern: Include (grant if matches) or Exclude (grant if does NOT match).`})
34785
+ @MaxLength(40)
34786
+ PatternType: string;
34787
+
34788
+ @Field(() => Boolean, {description: `If true, this rule explicitly DENIES access. Deny rules trump allow rules at the same priority level.`})
34789
+ IsDeny: boolean;
34790
+
34791
+ @Field(() => Int, {description: `Rule evaluation order. Higher priority rules are evaluated first. Within same priority, deny rules are evaluated before allow rules.`})
34792
+ Priority: number;
34793
+
34794
+ @Field()
34795
+ @MaxLength(10)
34796
+ _mj__CreatedAt: Date;
34797
+
34798
+ @Field()
34799
+ @MaxLength(10)
34800
+ _mj__UpdatedAt: Date;
34801
+
34802
+ @Field()
34803
+ @MaxLength(200)
34804
+ Application: string;
34805
+
34806
+ @Field()
34807
+ @MaxLength(200)
34808
+ Scope: string;
34809
+
34810
+ }
34811
+
34812
+ //****************************************************************************
34813
+ // INPUT TYPE for MJ: API Application Scopes
34814
+ //****************************************************************************
34815
+ @InputType()
34816
+ export class CreateMJAPIApplicationScopeInput {
34817
+ @Field({ nullable: true })
34818
+ ID?: string;
34819
+
34820
+ @Field({ nullable: true })
34821
+ ApplicationID?: string;
34822
+
34823
+ @Field({ nullable: true })
34824
+ ScopeID?: string;
34825
+
34826
+ @Field({ nullable: true })
34827
+ ResourcePattern: string | null;
34828
+
34829
+ @Field({ nullable: true })
34830
+ PatternType?: string;
34831
+
34832
+ @Field(() => Boolean, { nullable: true })
34833
+ IsDeny?: boolean;
34834
+
34835
+ @Field(() => Int, { nullable: true })
34836
+ Priority?: number;
34837
+ }
34838
+
34839
+
34840
+ //****************************************************************************
34841
+ // INPUT TYPE for MJ: API Application Scopes
34842
+ //****************************************************************************
34843
+ @InputType()
34844
+ export class UpdateMJAPIApplicationScopeInput {
34845
+ @Field()
34846
+ ID: string;
34847
+
34848
+ @Field({ nullable: true })
34849
+ ApplicationID?: string;
34850
+
34851
+ @Field({ nullable: true })
34852
+ ScopeID?: string;
34853
+
34854
+ @Field({ nullable: true })
34855
+ ResourcePattern?: string | null;
34856
+
34857
+ @Field({ nullable: true })
34858
+ PatternType?: string;
34859
+
34860
+ @Field(() => Boolean, { nullable: true })
34861
+ IsDeny?: boolean;
34862
+
34863
+ @Field(() => Int, { nullable: true })
34864
+ Priority?: number;
34865
+
34866
+ @Field(() => [KeyValuePairInput], { nullable: true })
34867
+ OldValues___?: KeyValuePairInput[];
34868
+ }
34869
+
34870
+ //****************************************************************************
34871
+ // RESOLVER for MJ: API Application Scopes
34872
+ //****************************************************************************
34873
+ @ObjectType()
34874
+ export class RunMJAPIApplicationScopeViewResult {
34875
+ @Field(() => [MJAPIApplicationScope_])
34876
+ Results: MJAPIApplicationScope_[];
34877
+
34878
+ @Field(() => String, {nullable: true})
34879
+ UserViewRunID?: string;
34880
+
34881
+ @Field(() => Int, {nullable: true})
34882
+ RowCount: number;
34883
+
34884
+ @Field(() => Int, {nullable: true})
34885
+ TotalRowCount: number;
34886
+
34887
+ @Field(() => Int, {nullable: true})
34888
+ ExecutionTime: number;
34889
+
34890
+ @Field({nullable: true})
34891
+ ErrorMessage?: string;
34892
+
34893
+ @Field(() => Boolean, {nullable: false})
34894
+ Success: boolean;
34895
+ }
34896
+
34897
+ @Resolver(MJAPIApplicationScope_)
34898
+ export class MJAPIApplicationScopeResolver extends ResolverBase {
34899
+ @Query(() => RunMJAPIApplicationScopeViewResult)
34900
+ async RunMJAPIApplicationScopeViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
34901
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
34902
+ return super.RunViewByIDGeneric(input, provider, userPayload, pubSub);
34903
+ }
34904
+
34905
+ @Query(() => RunMJAPIApplicationScopeViewResult)
34906
+ async RunMJAPIApplicationScopeViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
34907
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
34908
+ return super.RunViewByNameGeneric(input, provider, userPayload, pubSub);
34909
+ }
34910
+
34911
+ @Query(() => RunMJAPIApplicationScopeViewResult)
34912
+ async RunMJAPIApplicationScopeDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
34913
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
34914
+ input.EntityName = 'MJ: API Application Scopes';
34915
+ return super.RunDynamicViewGeneric(input, provider, userPayload, pubSub);
34916
+ }
34917
+ @Query(() => MJAPIApplicationScope_, { nullable: true })
34918
+ async MJAPIApplicationScope(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<MJAPIApplicationScope_ | null> {
34919
+ this.CheckUserReadPermissions('MJ: API Application Scopes', userPayload);
34920
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
34921
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
34922
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIApplicationScopes] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Application Scopes', userPayload, EntityPermissionType.Read, 'AND');
34923
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
34924
+ const result = await this.MapFieldNamesToCodeNames('MJ: API Application Scopes', rows && rows.length > 0 ? rows[0] : {}, this.GetUserFromPayload(userPayload));
34925
+ return result;
34926
+ }
34927
+
34928
+ @Mutation(() => MJAPIApplicationScope_)
34929
+ async CreateMJAPIApplicationScope(
34930
+ @Arg('input', () => CreateMJAPIApplicationScopeInput) input: CreateMJAPIApplicationScopeInput,
34931
+ @Ctx() { providers, userPayload }: AppContext,
34932
+ @PubSub() pubSub: PubSubEngine
34933
+ ) {
34934
+ const provider = GetReadWriteProvider(providers);
34935
+ return this.CreateRecord('MJ: API Application Scopes', input, provider, userPayload, pubSub)
34936
+ }
34937
+
34938
+ @Mutation(() => MJAPIApplicationScope_)
34939
+ async UpdateMJAPIApplicationScope(
34940
+ @Arg('input', () => UpdateMJAPIApplicationScopeInput) input: UpdateMJAPIApplicationScopeInput,
34941
+ @Ctx() { providers, userPayload }: AppContext,
34942
+ @PubSub() pubSub: PubSubEngine
34943
+ ) {
34944
+ const provider = GetReadWriteProvider(providers);
34945
+ return this.UpdateRecord('MJ: API Application Scopes', input, provider, userPayload, pubSub);
34946
+ }
34947
+
34948
+ @Mutation(() => MJAPIApplicationScope_)
34949
+ async DeleteMJAPIApplicationScope(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
34950
+ const provider = GetReadWriteProvider(providers);
34951
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
34952
+ return this.DeleteRecord('MJ: API Application Scopes', key, options, provider, userPayload, pubSub);
34953
+ }
34954
+
34955
+ }
34956
+
34957
+ //****************************************************************************
34958
+ // ENTITY CLASS for MJ: API Applications
34959
+ //****************************************************************************
34960
+ @ObjectType({ description: `Registry of applications that can consume MemberJunction APIs. Each application defines a scope ceiling that limits what API keys can access when used with that application.` })
34961
+ export class MJAPIApplication_ {
34962
+ @Field()
34963
+ @MaxLength(16)
34964
+ ID: string;
34965
+
34966
+ @Field({description: `Unique name identifying the application (e.g., MJAPI, MCPServer, Portal, CLI).`})
34967
+ @MaxLength(200)
34968
+ Name: string;
34969
+
34970
+ @Field({nullable: true, description: `Human-readable description of the application and its purpose.`})
34971
+ @MaxLength(1000)
34972
+ Description?: string;
34973
+
34974
+ @Field(() => Boolean, {description: `Whether this application is currently active. Inactive applications reject all API key authentication.`})
34975
+ IsActive: boolean;
34976
+
34977
+ @Field()
34978
+ @MaxLength(10)
34979
+ _mj__CreatedAt: Date;
34980
+
34981
+ @Field()
34982
+ @MaxLength(10)
34983
+ _mj__UpdatedAt: Date;
34984
+
34985
+ @Field(() => [MJAPIApplicationScope_])
34986
+ MJ_APIApplicationScopes_ApplicationIDArray: MJAPIApplicationScope_[]; // Link to MJ_APIApplicationScopes
34987
+
34988
+ @Field(() => [MJAPIKeyUsageLog_])
34989
+ MJ_APIKeyUsageLogs_ApplicationIDArray: MJAPIKeyUsageLog_[]; // Link to MJ_APIKeyUsageLogs
34990
+
34991
+ @Field(() => [MJAPIKeyApplication_])
34992
+ MJ_APIKeyApplications_ApplicationIDArray: MJAPIKeyApplication_[]; // Link to MJ_APIKeyApplications
34993
+
34994
+ }
34995
+
34996
+ //****************************************************************************
34997
+ // INPUT TYPE for MJ: API Applications
34998
+ //****************************************************************************
34999
+ @InputType()
35000
+ export class CreateMJAPIApplicationInput {
35001
+ @Field({ nullable: true })
35002
+ ID?: string;
35003
+
35004
+ @Field({ nullable: true })
35005
+ Name?: string;
35006
+
35007
+ @Field({ nullable: true })
35008
+ Description: string | null;
35009
+
35010
+ @Field(() => Boolean, { nullable: true })
35011
+ IsActive?: boolean;
35012
+ }
35013
+
35014
+
35015
+ //****************************************************************************
35016
+ // INPUT TYPE for MJ: API Applications
35017
+ //****************************************************************************
35018
+ @InputType()
35019
+ export class UpdateMJAPIApplicationInput {
35020
+ @Field()
35021
+ ID: string;
35022
+
35023
+ @Field({ nullable: true })
35024
+ Name?: string;
35025
+
35026
+ @Field({ nullable: true })
35027
+ Description?: string | null;
35028
+
35029
+ @Field(() => Boolean, { nullable: true })
35030
+ IsActive?: boolean;
35031
+
35032
+ @Field(() => [KeyValuePairInput], { nullable: true })
35033
+ OldValues___?: KeyValuePairInput[];
35034
+ }
35035
+
35036
+ //****************************************************************************
35037
+ // RESOLVER for MJ: API Applications
35038
+ //****************************************************************************
35039
+ @ObjectType()
35040
+ export class RunMJAPIApplicationViewResult {
35041
+ @Field(() => [MJAPIApplication_])
35042
+ Results: MJAPIApplication_[];
35043
+
35044
+ @Field(() => String, {nullable: true})
35045
+ UserViewRunID?: string;
35046
+
35047
+ @Field(() => Int, {nullable: true})
35048
+ RowCount: number;
35049
+
35050
+ @Field(() => Int, {nullable: true})
35051
+ TotalRowCount: number;
35052
+
35053
+ @Field(() => Int, {nullable: true})
35054
+ ExecutionTime: number;
35055
+
35056
+ @Field({nullable: true})
35057
+ ErrorMessage?: string;
35058
+
35059
+ @Field(() => Boolean, {nullable: false})
35060
+ Success: boolean;
35061
+ }
35062
+
35063
+ @Resolver(MJAPIApplication_)
35064
+ export class MJAPIApplicationResolver extends ResolverBase {
35065
+ @Query(() => RunMJAPIApplicationViewResult)
35066
+ async RunMJAPIApplicationViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35067
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35068
+ return super.RunViewByIDGeneric(input, provider, userPayload, pubSub);
35069
+ }
35070
+
35071
+ @Query(() => RunMJAPIApplicationViewResult)
35072
+ async RunMJAPIApplicationViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35073
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35074
+ return super.RunViewByNameGeneric(input, provider, userPayload, pubSub);
35075
+ }
35076
+
35077
+ @Query(() => RunMJAPIApplicationViewResult)
35078
+ async RunMJAPIApplicationDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35079
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35080
+ input.EntityName = 'MJ: API Applications';
35081
+ return super.RunDynamicViewGeneric(input, provider, userPayload, pubSub);
35082
+ }
35083
+ @Query(() => MJAPIApplication_, { nullable: true })
35084
+ async MJAPIApplication(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<MJAPIApplication_ | null> {
35085
+ this.CheckUserReadPermissions('MJ: API Applications', userPayload);
35086
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35087
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35088
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIApplications] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Applications', userPayload, EntityPermissionType.Read, 'AND');
35089
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35090
+ const result = await this.MapFieldNamesToCodeNames('MJ: API Applications', rows && rows.length > 0 ? rows[0] : {}, this.GetUserFromPayload(userPayload));
35091
+ return result;
35092
+ }
35093
+
35094
+ @FieldResolver(() => [MJAPIApplicationScope_])
35095
+ async MJ_APIApplicationScopes_ApplicationIDArray(@Root() mjapiapplication_: MJAPIApplication_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
35096
+ this.CheckUserReadPermissions('MJ: API Application Scopes', userPayload);
35097
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35098
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35099
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIApplicationScopes] WHERE [ApplicationID]='${mjapiapplication_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Application Scopes', userPayload, EntityPermissionType.Read, 'AND');
35100
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35101
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Application Scopes', rows, this.GetUserFromPayload(userPayload));
35102
+ return result;
35103
+ }
35104
+
35105
+ @FieldResolver(() => [MJAPIKeyUsageLog_])
35106
+ async MJ_APIKeyUsageLogs_ApplicationIDArray(@Root() mjapiapplication_: MJAPIApplication_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
35107
+ this.CheckUserReadPermissions('MJ: API Key Usage Logs', userPayload);
35108
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35109
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35110
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeyUsageLogs] WHERE [ApplicationID]='${mjapiapplication_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Key Usage Logs', userPayload, EntityPermissionType.Read, 'AND');
35111
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35112
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Key Usage Logs', rows, this.GetUserFromPayload(userPayload));
35113
+ return result;
35114
+ }
35115
+
35116
+ @FieldResolver(() => [MJAPIKeyApplication_])
35117
+ async MJ_APIKeyApplications_ApplicationIDArray(@Root() mjapiapplication_: MJAPIApplication_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
35118
+ this.CheckUserReadPermissions('MJ: API Key Applications', userPayload);
35119
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35120
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35121
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeyApplications] WHERE [ApplicationID]='${mjapiapplication_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Key Applications', userPayload, EntityPermissionType.Read, 'AND');
35122
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35123
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Key Applications', rows, this.GetUserFromPayload(userPayload));
35124
+ return result;
35125
+ }
35126
+
35127
+ @Mutation(() => MJAPIApplication_)
35128
+ async CreateMJAPIApplication(
35129
+ @Arg('input', () => CreateMJAPIApplicationInput) input: CreateMJAPIApplicationInput,
35130
+ @Ctx() { providers, userPayload }: AppContext,
35131
+ @PubSub() pubSub: PubSubEngine
35132
+ ) {
35133
+ const provider = GetReadWriteProvider(providers);
35134
+ return this.CreateRecord('MJ: API Applications', input, provider, userPayload, pubSub)
35135
+ }
35136
+
35137
+ @Mutation(() => MJAPIApplication_)
35138
+ async UpdateMJAPIApplication(
35139
+ @Arg('input', () => UpdateMJAPIApplicationInput) input: UpdateMJAPIApplicationInput,
35140
+ @Ctx() { providers, userPayload }: AppContext,
35141
+ @PubSub() pubSub: PubSubEngine
35142
+ ) {
35143
+ const provider = GetReadWriteProvider(providers);
35144
+ return this.UpdateRecord('MJ: API Applications', input, provider, userPayload, pubSub);
35145
+ }
35146
+
35147
+ @Mutation(() => MJAPIApplication_)
35148
+ async DeleteMJAPIApplication(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35149
+ const provider = GetReadWriteProvider(providers);
35150
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
35151
+ return this.DeleteRecord('MJ: API Applications', key, options, provider, userPayload, pubSub);
35152
+ }
35153
+
35154
+ }
35155
+
35156
+ //****************************************************************************
35157
+ // ENTITY CLASS for MJ: API Key Applications
35158
+ //****************************************************************************
35159
+ @ObjectType({ description: `Optional binding of API keys to specific applications. If no records exist for a key, it works with all applications. If records exist, the key only works with those specific applications.` })
35160
+ export class MJAPIKeyApplication_ {
35161
+ @Field()
35162
+ @MaxLength(16)
35163
+ ID: string;
35164
+
35165
+ @Field({description: `Reference to the API key being bound to an application.`})
35166
+ @MaxLength(16)
35167
+ APIKeyID: string;
35168
+
35169
+ @Field({description: `Reference to the application this key is authorized to use.`})
35170
+ @MaxLength(16)
35171
+ ApplicationID: string;
35172
+
35173
+ @Field()
35174
+ @MaxLength(10)
35175
+ _mj__CreatedAt: Date;
35176
+
35177
+ @Field()
35178
+ @MaxLength(10)
35179
+ _mj__UpdatedAt: Date;
35180
+
35181
+ @Field()
35182
+ @MaxLength(510)
35183
+ APIKey: string;
35184
+
35185
+ @Field()
35186
+ @MaxLength(200)
35187
+ Application: string;
35188
+
35189
+ }
35190
+
35191
+ //****************************************************************************
35192
+ // INPUT TYPE for MJ: API Key Applications
35193
+ //****************************************************************************
35194
+ @InputType()
35195
+ export class CreateMJAPIKeyApplicationInput {
35196
+ @Field({ nullable: true })
35197
+ ID?: string;
35198
+
35199
+ @Field({ nullable: true })
35200
+ APIKeyID?: string;
35201
+
35202
+ @Field({ nullable: true })
35203
+ ApplicationID?: string;
35204
+ }
35205
+
35206
+
35207
+ //****************************************************************************
35208
+ // INPUT TYPE for MJ: API Key Applications
35209
+ //****************************************************************************
35210
+ @InputType()
35211
+ export class UpdateMJAPIKeyApplicationInput {
35212
+ @Field()
35213
+ ID: string;
35214
+
35215
+ @Field({ nullable: true })
35216
+ APIKeyID?: string;
35217
+
35218
+ @Field({ nullable: true })
35219
+ ApplicationID?: string;
35220
+
35221
+ @Field(() => [KeyValuePairInput], { nullable: true })
35222
+ OldValues___?: KeyValuePairInput[];
35223
+ }
35224
+
35225
+ //****************************************************************************
35226
+ // RESOLVER for MJ: API Key Applications
35227
+ //****************************************************************************
35228
+ @ObjectType()
35229
+ export class RunMJAPIKeyApplicationViewResult {
35230
+ @Field(() => [MJAPIKeyApplication_])
35231
+ Results: MJAPIKeyApplication_[];
35232
+
35233
+ @Field(() => String, {nullable: true})
35234
+ UserViewRunID?: string;
35235
+
35236
+ @Field(() => Int, {nullable: true})
35237
+ RowCount: number;
35238
+
35239
+ @Field(() => Int, {nullable: true})
35240
+ TotalRowCount: number;
35241
+
35242
+ @Field(() => Int, {nullable: true})
35243
+ ExecutionTime: number;
35244
+
35245
+ @Field({nullable: true})
35246
+ ErrorMessage?: string;
35247
+
35248
+ @Field(() => Boolean, {nullable: false})
35249
+ Success: boolean;
35250
+ }
35251
+
35252
+ @Resolver(MJAPIKeyApplication_)
35253
+ export class MJAPIKeyApplicationResolver extends ResolverBase {
35254
+ @Query(() => RunMJAPIKeyApplicationViewResult)
35255
+ async RunMJAPIKeyApplicationViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35256
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35257
+ return super.RunViewByIDGeneric(input, provider, userPayload, pubSub);
35258
+ }
35259
+
35260
+ @Query(() => RunMJAPIKeyApplicationViewResult)
35261
+ async RunMJAPIKeyApplicationViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35262
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35263
+ return super.RunViewByNameGeneric(input, provider, userPayload, pubSub);
35264
+ }
35265
+
35266
+ @Query(() => RunMJAPIKeyApplicationViewResult)
35267
+ async RunMJAPIKeyApplicationDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35268
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35269
+ input.EntityName = 'MJ: API Key Applications';
35270
+ return super.RunDynamicViewGeneric(input, provider, userPayload, pubSub);
35271
+ }
35272
+ @Query(() => MJAPIKeyApplication_, { nullable: true })
35273
+ async MJAPIKeyApplication(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<MJAPIKeyApplication_ | null> {
35274
+ this.CheckUserReadPermissions('MJ: API Key Applications', userPayload);
35275
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35276
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35277
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeyApplications] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Key Applications', userPayload, EntityPermissionType.Read, 'AND');
35278
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35279
+ const result = await this.MapFieldNamesToCodeNames('MJ: API Key Applications', rows && rows.length > 0 ? rows[0] : {}, this.GetUserFromPayload(userPayload));
35280
+ return result;
35281
+ }
35282
+
35283
+ @Mutation(() => MJAPIKeyApplication_)
35284
+ async CreateMJAPIKeyApplication(
35285
+ @Arg('input', () => CreateMJAPIKeyApplicationInput) input: CreateMJAPIKeyApplicationInput,
35286
+ @Ctx() { providers, userPayload }: AppContext,
35287
+ @PubSub() pubSub: PubSubEngine
35288
+ ) {
35289
+ const provider = GetReadWriteProvider(providers);
35290
+ return this.CreateRecord('MJ: API Key Applications', input, provider, userPayload, pubSub)
35291
+ }
35292
+
35293
+ @Mutation(() => MJAPIKeyApplication_)
35294
+ async UpdateMJAPIKeyApplication(
35295
+ @Arg('input', () => UpdateMJAPIKeyApplicationInput) input: UpdateMJAPIKeyApplicationInput,
35296
+ @Ctx() { providers, userPayload }: AppContext,
35297
+ @PubSub() pubSub: PubSubEngine
35298
+ ) {
35299
+ const provider = GetReadWriteProvider(providers);
35300
+ return this.UpdateRecord('MJ: API Key Applications', input, provider, userPayload, pubSub);
35301
+ }
35302
+
35303
+ @Mutation(() => MJAPIKeyApplication_)
35304
+ async DeleteMJAPIKeyApplication(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { providers, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35305
+ const provider = GetReadWriteProvider(providers);
35306
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
35307
+ return this.DeleteRecord('MJ: API Key Applications', key, options, provider, userPayload, pubSub);
35308
+ }
35309
+
35310
+ }
35311
+
34519
35312
  //****************************************************************************
34520
35313
  // ENTITY CLASS for MJ: API Key Scopes
34521
35314
  //****************************************************************************
@@ -34541,6 +35334,20 @@ export class MJAPIKeyScope_ {
34541
35334
  @MaxLength(10)
34542
35335
  _mj__UpdatedAt: Date;
34543
35336
 
35337
+ @Field({nullable: true, description: `Glob pattern for matching resources (e.g., Users,Accounts or Skip* or *). NULL means match all resources under this scope.`})
35338
+ @MaxLength(1500)
35339
+ ResourcePattern?: string;
35340
+
35341
+ @Field({description: `How to interpret the pattern: Include (grant if matches) or Exclude (grant if does NOT match).`})
35342
+ @MaxLength(40)
35343
+ PatternType: string;
35344
+
35345
+ @Field(() => Boolean, {description: `If true, this rule explicitly DENIES access. Deny rules trump allow rules at the same priority level.`})
35346
+ IsDeny: boolean;
35347
+
35348
+ @Field(() => Int, {description: `Rule evaluation order. Higher priority rules are evaluated first. Within same priority, deny rules are evaluated before allow rules.`})
35349
+ Priority: number;
35350
+
34544
35351
  @Field()
34545
35352
  @MaxLength(510)
34546
35353
  APIKey: string;
@@ -34564,6 +35371,18 @@ export class CreateMJAPIKeyScopeInput {
34564
35371
 
34565
35372
  @Field({ nullable: true })
34566
35373
  ScopeID?: string;
35374
+
35375
+ @Field({ nullable: true })
35376
+ ResourcePattern: string | null;
35377
+
35378
+ @Field({ nullable: true })
35379
+ PatternType?: string;
35380
+
35381
+ @Field(() => Boolean, { nullable: true })
35382
+ IsDeny?: boolean;
35383
+
35384
+ @Field(() => Int, { nullable: true })
35385
+ Priority?: number;
34567
35386
  }
34568
35387
 
34569
35388
 
@@ -34581,6 +35400,18 @@ export class UpdateMJAPIKeyScopeInput {
34581
35400
  @Field({ nullable: true })
34582
35401
  ScopeID?: string;
34583
35402
 
35403
+ @Field({ nullable: true })
35404
+ ResourcePattern?: string | null;
35405
+
35406
+ @Field({ nullable: true })
35407
+ PatternType?: string;
35408
+
35409
+ @Field(() => Boolean, { nullable: true })
35410
+ IsDeny?: boolean;
35411
+
35412
+ @Field(() => Int, { nullable: true })
35413
+ Priority?: number;
35414
+
34584
35415
  @Field(() => [KeyValuePairInput], { nullable: true })
34585
35416
  OldValues___?: KeyValuePairInput[];
34586
35417
  }
@@ -34719,10 +35550,33 @@ export class MJAPIKeyUsageLog_ {
34719
35550
  @MaxLength(10)
34720
35551
  _mj__UpdatedAt: Date;
34721
35552
 
35553
+ @Field({nullable: true, description: `The application through which this request was made (MJAPI, MCPServer, etc.).`})
35554
+ @MaxLength(16)
35555
+ ApplicationID?: string;
35556
+
35557
+ @Field({nullable: true, description: `The specific resource that was requested (e.g., entity name, agent name, query name).`})
35558
+ @MaxLength(1000)
35559
+ RequestedResource?: string;
35560
+
35561
+ @Field({nullable: true, description: `JSON array containing detailed evaluation of each scope rule checked during authorization.`})
35562
+ ScopesEvaluated?: string;
35563
+
35564
+ @Field({description: `Final authorization result: Allowed, Denied, or NoScopesRequired (for operations that do not require scope checks).`})
35565
+ @MaxLength(40)
35566
+ AuthorizationResult: string;
35567
+
35568
+ @Field({nullable: true, description: `When authorization is denied, explains why (e.g., app ceiling blocked, no matching key scope, explicit deny rule).`})
35569
+ @MaxLength(1000)
35570
+ DeniedReason?: string;
35571
+
34722
35572
  @Field()
34723
35573
  @MaxLength(510)
34724
35574
  APIKey: string;
34725
35575
 
35576
+ @Field({nullable: true})
35577
+ @MaxLength(200)
35578
+ Application?: string;
35579
+
34726
35580
  }
34727
35581
 
34728
35582
  //****************************************************************************
@@ -34756,6 +35610,21 @@ export class CreateMJAPIKeyUsageLogInput {
34756
35610
 
34757
35611
  @Field({ nullable: true })
34758
35612
  UserAgent: string | null;
35613
+
35614
+ @Field({ nullable: true })
35615
+ ApplicationID: string | null;
35616
+
35617
+ @Field({ nullable: true })
35618
+ RequestedResource: string | null;
35619
+
35620
+ @Field({ nullable: true })
35621
+ ScopesEvaluated: string | null;
35622
+
35623
+ @Field({ nullable: true })
35624
+ AuthorizationResult?: string;
35625
+
35626
+ @Field({ nullable: true })
35627
+ DeniedReason: string | null;
34759
35628
  }
34760
35629
 
34761
35630
 
@@ -34791,6 +35660,21 @@ export class UpdateMJAPIKeyUsageLogInput {
34791
35660
  @Field({ nullable: true })
34792
35661
  UserAgent?: string | null;
34793
35662
 
35663
+ @Field({ nullable: true })
35664
+ ApplicationID?: string | null;
35665
+
35666
+ @Field({ nullable: true })
35667
+ RequestedResource?: string | null;
35668
+
35669
+ @Field({ nullable: true })
35670
+ ScopesEvaluated?: string | null;
35671
+
35672
+ @Field({ nullable: true })
35673
+ AuthorizationResult?: string;
35674
+
35675
+ @Field({ nullable: true })
35676
+ DeniedReason?: string | null;
35677
+
34794
35678
  @Field(() => [KeyValuePairInput], { nullable: true })
34795
35679
  OldValues___?: KeyValuePairInput[];
34796
35680
  }
@@ -34945,6 +35829,9 @@ export class MJAPIKey_ {
34945
35829
  @Field(() => [MJAPIKeyScope_])
34946
35830
  MJ_APIKeyScopes_APIKeyIDArray: MJAPIKeyScope_[]; // Link to MJ_APIKeyScopes
34947
35831
 
35832
+ @Field(() => [MJAPIKeyApplication_])
35833
+ MJ_APIKeyApplications_APIKeyIDArray: MJAPIKeyApplication_[]; // Link to MJ_APIKeyApplications
35834
+
34948
35835
  }
34949
35836
 
34950
35837
  //****************************************************************************
@@ -35097,6 +35984,17 @@ export class MJAPIKeyResolver extends ResolverBase {
35097
35984
  return result;
35098
35985
  }
35099
35986
 
35987
+ @FieldResolver(() => [MJAPIKeyApplication_])
35988
+ async MJ_APIKeyApplications_APIKeyIDArray(@Root() mjapikey_: MJAPIKey_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
35989
+ this.CheckUserReadPermissions('MJ: API Key Applications', userPayload);
35990
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
35991
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
35992
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeyApplications] WHERE [APIKeyID]='${mjapikey_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Key Applications', userPayload, EntityPermissionType.Read, 'AND');
35993
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
35994
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Key Applications', rows, this.GetUserFromPayload(userPayload));
35995
+ return result;
35996
+ }
35997
+
35100
35998
  @Mutation(() => MJAPIKey_)
35101
35999
  async CreateMJAPIKey(
35102
36000
  @Arg('input', () => CreateMJAPIKeyInput) input: CreateMJAPIKeyInput,
@@ -35155,9 +36053,38 @@ export class MJAPIScope_ {
35155
36053
  @MaxLength(10)
35156
36054
  _mj__UpdatedAt: Date;
35157
36055
 
36056
+ @Field({nullable: true, description: `Reference to parent scope for hierarchical organization. NULL indicates a root-level scope.`})
36057
+ @MaxLength(16)
36058
+ ParentID?: string;
36059
+
36060
+ @Field({description: `Full hierarchical path of the scope (e.g., entity:runview, agent:execute). Used for matching during authorization.`})
36061
+ @MaxLength(1000)
36062
+ FullPath: string;
36063
+
36064
+ @Field({nullable: true, description: `Type of resource this scope applies to (Entity, Agent, Query, Mutation, or NULL for abstract grouping scopes).`})
36065
+ @MaxLength(100)
36066
+ ResourceType?: string;
36067
+
36068
+ @Field(() => Boolean, {description: `Whether this scope is currently active. Inactive scopes are ignored during authorization.`})
36069
+ IsActive: boolean;
36070
+
36071
+ @Field({nullable: true})
36072
+ @MaxLength(200)
36073
+ Parent?: string;
36074
+
36075
+ @Field({nullable: true})
36076
+ @MaxLength(16)
36077
+ RootParentID?: string;
36078
+
35158
36079
  @Field(() => [MJAPIKeyScope_])
35159
36080
  MJ_APIKeyScopes_ScopeIDArray: MJAPIKeyScope_[]; // Link to MJ_APIKeyScopes
35160
36081
 
36082
+ @Field(() => [MJAPIApplicationScope_])
36083
+ MJ_APIApplicationScopes_ScopeIDArray: MJAPIApplicationScope_[]; // Link to MJ_APIApplicationScopes
36084
+
36085
+ @Field(() => [MJAPIScope_])
36086
+ MJ_APIScopes_ParentIDArray: MJAPIScope_[]; // Link to MJ_APIScopes
36087
+
35161
36088
  }
35162
36089
 
35163
36090
  //****************************************************************************
@@ -35176,6 +36103,18 @@ export class CreateMJAPIScopeInput {
35176
36103
 
35177
36104
  @Field({ nullable: true })
35178
36105
  Description: string | null;
36106
+
36107
+ @Field({ nullable: true })
36108
+ ParentID: string | null;
36109
+
36110
+ @Field({ nullable: true })
36111
+ FullPath?: string;
36112
+
36113
+ @Field({ nullable: true })
36114
+ ResourceType: string | null;
36115
+
36116
+ @Field(() => Boolean, { nullable: true })
36117
+ IsActive?: boolean;
35179
36118
  }
35180
36119
 
35181
36120
 
@@ -35196,6 +36135,18 @@ export class UpdateMJAPIScopeInput {
35196
36135
  @Field({ nullable: true })
35197
36136
  Description?: string | null;
35198
36137
 
36138
+ @Field({ nullable: true })
36139
+ ParentID?: string | null;
36140
+
36141
+ @Field({ nullable: true })
36142
+ FullPath?: string;
36143
+
36144
+ @Field({ nullable: true })
36145
+ ResourceType?: string | null;
36146
+
36147
+ @Field(() => Boolean, { nullable: true })
36148
+ IsActive?: boolean;
36149
+
35199
36150
  @Field(() => [KeyValuePairInput], { nullable: true })
35200
36151
  OldValues___?: KeyValuePairInput[];
35201
36152
  }
@@ -35269,6 +36220,28 @@ export class MJAPIScopeResolver extends ResolverBase {
35269
36220
  return result;
35270
36221
  }
35271
36222
 
36223
+ @FieldResolver(() => [MJAPIApplicationScope_])
36224
+ async MJ_APIApplicationScopes_ScopeIDArray(@Root() mjapiscope_: MJAPIScope_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
36225
+ this.CheckUserReadPermissions('MJ: API Application Scopes', userPayload);
36226
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
36227
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36228
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIApplicationScopes] WHERE [ScopeID]='${mjapiscope_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Application Scopes', userPayload, EntityPermissionType.Read, 'AND');
36229
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
36230
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Application Scopes', rows, this.GetUserFromPayload(userPayload));
36231
+ return result;
36232
+ }
36233
+
36234
+ @FieldResolver(() => [MJAPIScope_])
36235
+ async MJ_APIScopes_ParentIDArray(@Root() mjapiscope_: MJAPIScope_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
36236
+ this.CheckUserReadPermissions('MJ: API Scopes', userPayload);
36237
+ const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
36238
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36239
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIScopes] WHERE [ParentID]='${mjapiscope_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Scopes', userPayload, EntityPermissionType.Read, 'AND');
36240
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
36241
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Scopes', rows, this.GetUserFromPayload(userPayload));
36242
+ return result;
36243
+ }
36244
+
35272
36245
  @Mutation(() => MJAPIScope_)
35273
36246
  async CreateMJAPIScope(
35274
36247
  @Arg('input', () => CreateMJAPIScopeInput) input: CreateMJAPIScopeInput,
@@ -59219,12 +60192,12 @@ export class MJUser_ {
59219
60192
  @Field(() => [MJDashboardPermission_])
59220
60193
  MJ_DashboardPermissions_SharedByUserIDArray: MJDashboardPermission_[]; // Link to MJ_DashboardPermissions
59221
60194
 
59222
- @Field(() => [MJUserNotificationPreference_])
59223
- MJ_UserNotificationPreferences_UserIDArray: MJUserNotificationPreference_[]; // Link to MJ_UserNotificationPreferences
59224
-
59225
60195
  @Field(() => [MJAPIKey_])
59226
60196
  MJ_APIKeys_UserIDArray: MJAPIKey_[]; // Link to MJ_APIKeys
59227
60197
 
60198
+ @Field(() => [MJUserNotificationPreference_])
60199
+ MJ_UserNotificationPreferences_UserIDArray: MJUserNotificationPreference_[]; // Link to MJ_UserNotificationPreferences
60200
+
59228
60201
  @Field(() => [MJResourcePermission_])
59229
60202
  ResourcePermissions_UserIDArray: MJResourcePermission_[]; // Link to ResourcePermissions
59230
60203
 
@@ -60036,25 +61009,25 @@ export class MJUserResolverBase extends ResolverBase {
60036
61009
  return result;
60037
61010
  }
60038
61011
 
60039
- @FieldResolver(() => [MJUserNotificationPreference_])
60040
- async MJ_UserNotificationPreferences_UserIDArray(@Root() mjuser_: MJUser_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
60041
- this.CheckUserReadPermissions('MJ: User Notification Preferences', userPayload);
61012
+ @FieldResolver(() => [MJAPIKey_])
61013
+ async MJ_APIKeys_UserIDArray(@Root() mjuser_: MJUser_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
61014
+ this.CheckUserReadPermissions('MJ: API Keys', userPayload);
60042
61015
  const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
60043
61016
  const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
60044
- const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwUserNotificationPreferences] WHERE [UserID]='${mjuser_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: User Notification Preferences', userPayload, EntityPermissionType.Read, 'AND');
61017
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeys] WHERE [UserID]='${mjuser_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Keys', userPayload, EntityPermissionType.Read, 'AND');
60045
61018
  const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
60046
- const result = await this.ArrayMapFieldNamesToCodeNames('MJ: User Notification Preferences', rows, this.GetUserFromPayload(userPayload));
61019
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Keys', rows, this.GetUserFromPayload(userPayload));
60047
61020
  return result;
60048
61021
  }
60049
61022
 
60050
- @FieldResolver(() => [MJAPIKey_])
60051
- async MJ_APIKeys_UserIDArray(@Root() mjuser_: MJUser_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
60052
- this.CheckUserReadPermissions('MJ: API Keys', userPayload);
61023
+ @FieldResolver(() => [MJUserNotificationPreference_])
61024
+ async MJ_UserNotificationPreferences_UserIDArray(@Root() mjuser_: MJUser_, @Ctx() { dataSources, userPayload, providers }: AppContext, @PubSub() pubSub: PubSubEngine) {
61025
+ this.CheckUserReadPermissions('MJ: User Notification Preferences', userPayload);
60053
61026
  const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true });
60054
61027
  const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
60055
- const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAPIKeys] WHERE [UserID]='${mjuser_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: API Keys', userPayload, EntityPermissionType.Read, 'AND');
61028
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwUserNotificationPreferences] WHERE [UserID]='${mjuser_.ID}' ` + this.getRowLevelSecurityWhereClause(provider, 'MJ: User Notification Preferences', userPayload, EntityPermissionType.Read, 'AND');
60056
61029
  const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
60057
- const result = await this.ArrayMapFieldNamesToCodeNames('MJ: API Keys', rows, this.GetUserFromPayload(userPayload));
61030
+ const result = await this.ArrayMapFieldNamesToCodeNames('MJ: User Notification Preferences', rows, this.GetUserFromPayload(userPayload));
60058
61031
  return result;
60059
61032
  }
60060
61033