@memberjunction/server 0.9.163 → 0.9.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.log.json +6 -0
- package/dist/generated/generated.js +560 -1
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +89 -37
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/package.json +6 -6
- package/src/generated/generated.ts +433 -2
- package/src/resolvers/AskSkipResolver.ts +125 -48
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ALL ENTITIES - TypeGraphQL Type Class Definition - AUTO GENERATED FILE
|
|
3
3
|
* Generated Entities and Resolvers for Server
|
|
4
4
|
*
|
|
5
|
-
* GENERATED: 2/
|
|
5
|
+
* GENERATED: 2/13/2024, 5:19:55 PM
|
|
6
6
|
*
|
|
7
7
|
* >>> DO NOT MODIFY THIS FILE!!!!!!!!!!!!
|
|
8
8
|
* >>> YOUR CHANGES WILL BE OVERWRITTEN
|
|
@@ -17,7 +17,7 @@ import { AppContext } from '@memberjunction/server';
|
|
|
17
17
|
import { MaxLength } from 'class-validator';
|
|
18
18
|
import { DataSource } from 'typeorm';
|
|
19
19
|
|
|
20
|
-
import { 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, ResourceFolderEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity } from '@memberjunction/core-entities';
|
|
20
|
+
import { 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, ResourceFolderEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity, DataContextItemEntity, DataContextEntity } from '@memberjunction/core-entities';
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
//****************************************************************************
|
|
@@ -3559,6 +3559,9 @@ export class User_ {
|
|
|
3559
3559
|
@Field(() => [RecordMergeLog_])
|
|
3560
3560
|
RecordMergeLogsArray: RecordMergeLog_[]; // Link to RecordMergeLogs
|
|
3561
3561
|
|
|
3562
|
+
@Field(() => [DataContext_])
|
|
3563
|
+
DataContextsArray: DataContext_[]; // Link to DataContexts
|
|
3564
|
+
|
|
3562
3565
|
}
|
|
3563
3566
|
|
|
3564
3567
|
//****************************************************************************
|
|
@@ -3846,6 +3849,14 @@ export class UserResolverBase extends ResolverBase {
|
|
|
3846
3849
|
const result = this.ArrayMapFieldNamesToCodeNames('Record Merge Logs', await dataSource.query(sSQL));
|
|
3847
3850
|
return result;
|
|
3848
3851
|
}
|
|
3852
|
+
|
|
3853
|
+
@FieldResolver(() => [DataContext_])
|
|
3854
|
+
async DataContextsArray(@Root() user_: User_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
3855
|
+
this.CheckUserReadPermissions('Data Contexts', userPayload);
|
|
3856
|
+
const sSQL = `SELECT * FROM [admin].[vwDataContexts] WHERE [UserID]=${user_.ID} ` + this.getRowLevelSecurityWhereClause('Data Contexts', userPayload, EntityPermissionType.Read, 'AND');
|
|
3857
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Data Contexts', await dataSource.query(sSQL));
|
|
3858
|
+
return result;
|
|
3859
|
+
}
|
|
3849
3860
|
|
|
3850
3861
|
@Mutation(() => User_)
|
|
3851
3862
|
async CreateUser(
|
|
@@ -12608,6 +12619,9 @@ export class Conversation_ {
|
|
|
12608
12619
|
@Field(() => Int, {nullable: true})
|
|
12609
12620
|
LinkedRecordID?: number;
|
|
12610
12621
|
|
|
12622
|
+
@Field(() => Int, {nullable: true})
|
|
12623
|
+
DataContextID?: number;
|
|
12624
|
+
|
|
12611
12625
|
@Field()
|
|
12612
12626
|
@MaxLength(8)
|
|
12613
12627
|
CreatedAt: Date;
|
|
@@ -12657,6 +12671,9 @@ export class CreateConversationInput {
|
|
|
12657
12671
|
|
|
12658
12672
|
@Field(() => Int, { nullable: true })
|
|
12659
12673
|
LinkedRecordID: number;
|
|
12674
|
+
|
|
12675
|
+
@Field(() => Int, { nullable: true })
|
|
12676
|
+
DataContextID: number;
|
|
12660
12677
|
}
|
|
12661
12678
|
|
|
12662
12679
|
|
|
@@ -12688,6 +12705,9 @@ export class UpdateConversationInput {
|
|
|
12688
12705
|
|
|
12689
12706
|
@Field(() => Int, { nullable: true })
|
|
12690
12707
|
LinkedRecordID: number;
|
|
12708
|
+
|
|
12709
|
+
@Field(() => Int, { nullable: true })
|
|
12710
|
+
DataContextID: number;
|
|
12691
12711
|
}
|
|
12692
12712
|
|
|
12693
12713
|
//****************************************************************************
|
|
@@ -16177,4 +16197,415 @@ export class EntityDocumentResolver extends ResolverBase {
|
|
|
16177
16197
|
const i = input, d = dataSource; // prevent error
|
|
16178
16198
|
}
|
|
16179
16199
|
|
|
16200
|
+
}
|
|
16201
|
+
|
|
16202
|
+
//****************************************************************************
|
|
16203
|
+
// ENTITY CLASS for Data Context Items
|
|
16204
|
+
//****************************************************************************
|
|
16205
|
+
@ObjectType()
|
|
16206
|
+
export class DataContextItem_ {
|
|
16207
|
+
@Field(() => Int)
|
|
16208
|
+
ID: number;
|
|
16209
|
+
|
|
16210
|
+
@Field(() => Int)
|
|
16211
|
+
DataContextID: number;
|
|
16212
|
+
|
|
16213
|
+
@Field()
|
|
16214
|
+
@MaxLength(100)
|
|
16215
|
+
Type: string;
|
|
16216
|
+
|
|
16217
|
+
@Field(() => Int)
|
|
16218
|
+
RecordID: number;
|
|
16219
|
+
|
|
16220
|
+
@Field({nullable: true})
|
|
16221
|
+
SQL?: string;
|
|
16222
|
+
|
|
16223
|
+
@Field({nullable: true})
|
|
16224
|
+
DataJSON?: string;
|
|
16225
|
+
|
|
16226
|
+
@Field({nullable: true})
|
|
16227
|
+
@MaxLength(8)
|
|
16228
|
+
LastRefreshedAt?: Date;
|
|
16229
|
+
|
|
16230
|
+
@Field()
|
|
16231
|
+
@MaxLength(8)
|
|
16232
|
+
CreatedAt: Date;
|
|
16233
|
+
|
|
16234
|
+
@Field()
|
|
16235
|
+
@MaxLength(8)
|
|
16236
|
+
UpdatedAt: Date;
|
|
16237
|
+
|
|
16238
|
+
@Field()
|
|
16239
|
+
@MaxLength(510)
|
|
16240
|
+
DataContext: string;
|
|
16241
|
+
|
|
16242
|
+
}
|
|
16243
|
+
|
|
16244
|
+
//****************************************************************************
|
|
16245
|
+
// INPUT TYPE for Data Context Items
|
|
16246
|
+
//****************************************************************************
|
|
16247
|
+
@InputType()
|
|
16248
|
+
export class CreateDataContextItemInput {
|
|
16249
|
+
@Field(() => Int, )
|
|
16250
|
+
DataContextID: number;
|
|
16251
|
+
|
|
16252
|
+
@Field()
|
|
16253
|
+
Type: string;
|
|
16254
|
+
|
|
16255
|
+
@Field(() => Int, )
|
|
16256
|
+
RecordID: number;
|
|
16257
|
+
|
|
16258
|
+
@Field({ nullable: true })
|
|
16259
|
+
SQL: string;
|
|
16260
|
+
|
|
16261
|
+
@Field({ nullable: true })
|
|
16262
|
+
DataJSON: string;
|
|
16263
|
+
|
|
16264
|
+
@Field({ nullable: true })
|
|
16265
|
+
LastRefreshedAt: Date;
|
|
16266
|
+
}
|
|
16267
|
+
|
|
16268
|
+
|
|
16269
|
+
//****************************************************************************
|
|
16270
|
+
// INPUT TYPE for Data Context Items
|
|
16271
|
+
//****************************************************************************
|
|
16272
|
+
@InputType()
|
|
16273
|
+
export class UpdateDataContextItemInput {
|
|
16274
|
+
@Field(() => Int, )
|
|
16275
|
+
ID: number;
|
|
16276
|
+
|
|
16277
|
+
@Field(() => Int, )
|
|
16278
|
+
DataContextID: number;
|
|
16279
|
+
|
|
16280
|
+
@Field()
|
|
16281
|
+
Type: string;
|
|
16282
|
+
|
|
16283
|
+
@Field(() => Int, )
|
|
16284
|
+
RecordID: number;
|
|
16285
|
+
|
|
16286
|
+
@Field({ nullable: true })
|
|
16287
|
+
SQL: string;
|
|
16288
|
+
|
|
16289
|
+
@Field({ nullable: true })
|
|
16290
|
+
DataJSON: string;
|
|
16291
|
+
|
|
16292
|
+
@Field({ nullable: true })
|
|
16293
|
+
LastRefreshedAt: Date;
|
|
16294
|
+
}
|
|
16295
|
+
|
|
16296
|
+
//****************************************************************************
|
|
16297
|
+
// RESOLVER for Data Context Items
|
|
16298
|
+
//****************************************************************************
|
|
16299
|
+
@ObjectType()
|
|
16300
|
+
export class RunDataContextItemViewResult {
|
|
16301
|
+
@Field(() => [DataContextItem_])
|
|
16302
|
+
Results: DataContextItem_[];
|
|
16303
|
+
|
|
16304
|
+
@Field(() => Int, {nullable: true})
|
|
16305
|
+
UserViewRunID?: number;
|
|
16306
|
+
|
|
16307
|
+
@Field(() => Int, {nullable: true})
|
|
16308
|
+
RowCount: number;
|
|
16309
|
+
|
|
16310
|
+
@Field(() => Int, {nullable: true})
|
|
16311
|
+
TotalRowCount: number;
|
|
16312
|
+
|
|
16313
|
+
@Field(() => Int, {nullable: true})
|
|
16314
|
+
ExecutionTime: number;
|
|
16315
|
+
|
|
16316
|
+
@Field({nullable: true})
|
|
16317
|
+
ErrorMessage?: string;
|
|
16318
|
+
|
|
16319
|
+
@Field(() => Boolean, {nullable: false})
|
|
16320
|
+
Success: boolean;
|
|
16321
|
+
}
|
|
16322
|
+
|
|
16323
|
+
@Resolver(DataContextItem_)
|
|
16324
|
+
export class DataContextItemResolver extends ResolverBase {
|
|
16325
|
+
@Query(() => RunDataContextItemViewResult)
|
|
16326
|
+
async RunDataContextItemViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16327
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
16328
|
+
}
|
|
16329
|
+
|
|
16330
|
+
@Query(() => RunDataContextItemViewResult)
|
|
16331
|
+
async RunDataContextItemViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16332
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
16333
|
+
}
|
|
16334
|
+
|
|
16335
|
+
@Query(() => RunDataContextItemViewResult)
|
|
16336
|
+
async RunDataContextItemDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16337
|
+
input.EntityName = 'Data Context Items';
|
|
16338
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
16339
|
+
}
|
|
16340
|
+
@Query(() => DataContextItem_, { nullable: true })
|
|
16341
|
+
async DataContextItem(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<DataContextItem_ | null> {
|
|
16342
|
+
this.CheckUserReadPermissions('Data Context Items', userPayload);
|
|
16343
|
+
const sSQL = `SELECT * FROM [admin].[vwDataContextItems] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Data Context Items', userPayload, EntityPermissionType.Read, 'AND');
|
|
16344
|
+
const result = this.MapFieldNamesToCodeNames('Data Context Items', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
16345
|
+
return result;
|
|
16346
|
+
}
|
|
16347
|
+
|
|
16348
|
+
@Mutation(() => DataContextItem_)
|
|
16349
|
+
async CreateDataContextItem(
|
|
16350
|
+
@Arg('input', () => CreateDataContextItemInput) input: CreateDataContextItemInput,
|
|
16351
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
16352
|
+
@PubSub() pubSub: PubSubEngine
|
|
16353
|
+
) {
|
|
16354
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
16355
|
+
const entityObject = <DataContextItemEntity>await new Metadata().GetEntityObject('Data Context Items', this.GetUserFromPayload(userPayload));
|
|
16356
|
+
await entityObject.NewRecord();
|
|
16357
|
+
entityObject.SetMany(input);
|
|
16358
|
+
if (await entityObject.Save()) {
|
|
16359
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
16360
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
16361
|
+
return entityObject.GetAll();
|
|
16362
|
+
}
|
|
16363
|
+
else
|
|
16364
|
+
// save failed, return null
|
|
16365
|
+
return null;
|
|
16366
|
+
}
|
|
16367
|
+
else
|
|
16368
|
+
return null;
|
|
16369
|
+
}
|
|
16370
|
+
|
|
16371
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
16372
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateDataContextItemInput): Promise<boolean> {
|
|
16373
|
+
return true;
|
|
16374
|
+
}
|
|
16375
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateDataContextItemInput) {
|
|
16376
|
+
}
|
|
16377
|
+
|
|
16378
|
+
@Mutation(() => DataContextItem_)
|
|
16379
|
+
async UpdateDataContextItem(
|
|
16380
|
+
@Arg('input', () => UpdateDataContextItemInput) input: UpdateDataContextItemInput,
|
|
16381
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
16382
|
+
@PubSub() pubSub: PubSubEngine
|
|
16383
|
+
) {
|
|
16384
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
16385
|
+
const entityObject = <DataContextItemEntity>await new Metadata().GetEntityObject('Data Context Items', this.GetUserFromPayload(userPayload));
|
|
16386
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Data Context Items
|
|
16387
|
+
|
|
16388
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
16389
|
+
// save worked, fire afterevent and return all the data
|
|
16390
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
16391
|
+
return entityObject.GetAll();
|
|
16392
|
+
}
|
|
16393
|
+
else
|
|
16394
|
+
return null; // save failed, return null
|
|
16395
|
+
}
|
|
16396
|
+
else
|
|
16397
|
+
return null;
|
|
16398
|
+
}
|
|
16399
|
+
|
|
16400
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
16401
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateDataContextItemInput): Promise<boolean> {
|
|
16402
|
+
const i = input, d = dataSource; // prevent error
|
|
16403
|
+
return true;
|
|
16404
|
+
}
|
|
16405
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateDataContextItemInput) {
|
|
16406
|
+
const i = input, d = dataSource; // prevent error
|
|
16407
|
+
}
|
|
16408
|
+
|
|
16409
|
+
}
|
|
16410
|
+
|
|
16411
|
+
//****************************************************************************
|
|
16412
|
+
// ENTITY CLASS for Data Contexts
|
|
16413
|
+
//****************************************************************************
|
|
16414
|
+
@ObjectType()
|
|
16415
|
+
export class DataContext_ {
|
|
16416
|
+
@Field(() => Int)
|
|
16417
|
+
ID: number;
|
|
16418
|
+
|
|
16419
|
+
@Field()
|
|
16420
|
+
@MaxLength(510)
|
|
16421
|
+
Name: string;
|
|
16422
|
+
|
|
16423
|
+
@Field(() => Int)
|
|
16424
|
+
UserID: number;
|
|
16425
|
+
|
|
16426
|
+
@Field({nullable: true})
|
|
16427
|
+
Description?: string;
|
|
16428
|
+
|
|
16429
|
+
@Field({nullable: true})
|
|
16430
|
+
@MaxLength(8)
|
|
16431
|
+
LastRefreshedAt?: Date;
|
|
16432
|
+
|
|
16433
|
+
@Field()
|
|
16434
|
+
@MaxLength(8)
|
|
16435
|
+
CreatedAt: Date;
|
|
16436
|
+
|
|
16437
|
+
@Field()
|
|
16438
|
+
@MaxLength(8)
|
|
16439
|
+
UpdatedAt: Date;
|
|
16440
|
+
|
|
16441
|
+
@Field()
|
|
16442
|
+
@MaxLength(200)
|
|
16443
|
+
User: string;
|
|
16444
|
+
|
|
16445
|
+
@Field(() => [DataContextItem_])
|
|
16446
|
+
DataContextItemsArray: DataContextItem_[]; // Link to DataContextItems
|
|
16447
|
+
|
|
16448
|
+
}
|
|
16449
|
+
|
|
16450
|
+
//****************************************************************************
|
|
16451
|
+
// INPUT TYPE for Data Contexts
|
|
16452
|
+
//****************************************************************************
|
|
16453
|
+
@InputType()
|
|
16454
|
+
export class CreateDataContextInput {
|
|
16455
|
+
@Field()
|
|
16456
|
+
Name: string;
|
|
16457
|
+
|
|
16458
|
+
@Field(() => Int, )
|
|
16459
|
+
UserID: number;
|
|
16460
|
+
|
|
16461
|
+
@Field({ nullable: true })
|
|
16462
|
+
Description: string;
|
|
16463
|
+
|
|
16464
|
+
@Field({ nullable: true })
|
|
16465
|
+
LastRefreshedAt: Date;
|
|
16466
|
+
}
|
|
16467
|
+
|
|
16468
|
+
|
|
16469
|
+
//****************************************************************************
|
|
16470
|
+
// INPUT TYPE for Data Contexts
|
|
16471
|
+
//****************************************************************************
|
|
16472
|
+
@InputType()
|
|
16473
|
+
export class UpdateDataContextInput {
|
|
16474
|
+
@Field(() => Int, )
|
|
16475
|
+
ID: number;
|
|
16476
|
+
|
|
16477
|
+
@Field()
|
|
16478
|
+
Name: string;
|
|
16479
|
+
|
|
16480
|
+
@Field(() => Int, )
|
|
16481
|
+
UserID: number;
|
|
16482
|
+
|
|
16483
|
+
@Field({ nullable: true })
|
|
16484
|
+
Description: string;
|
|
16485
|
+
|
|
16486
|
+
@Field({ nullable: true })
|
|
16487
|
+
LastRefreshedAt: Date;
|
|
16488
|
+
}
|
|
16489
|
+
|
|
16490
|
+
//****************************************************************************
|
|
16491
|
+
// RESOLVER for Data Contexts
|
|
16492
|
+
//****************************************************************************
|
|
16493
|
+
@ObjectType()
|
|
16494
|
+
export class RunDataContextViewResult {
|
|
16495
|
+
@Field(() => [DataContext_])
|
|
16496
|
+
Results: DataContext_[];
|
|
16497
|
+
|
|
16498
|
+
@Field(() => Int, {nullable: true})
|
|
16499
|
+
UserViewRunID?: number;
|
|
16500
|
+
|
|
16501
|
+
@Field(() => Int, {nullable: true})
|
|
16502
|
+
RowCount: number;
|
|
16503
|
+
|
|
16504
|
+
@Field(() => Int, {nullable: true})
|
|
16505
|
+
TotalRowCount: number;
|
|
16506
|
+
|
|
16507
|
+
@Field(() => Int, {nullable: true})
|
|
16508
|
+
ExecutionTime: number;
|
|
16509
|
+
|
|
16510
|
+
@Field({nullable: true})
|
|
16511
|
+
ErrorMessage?: string;
|
|
16512
|
+
|
|
16513
|
+
@Field(() => Boolean, {nullable: false})
|
|
16514
|
+
Success: boolean;
|
|
16515
|
+
}
|
|
16516
|
+
|
|
16517
|
+
@Resolver(DataContext_)
|
|
16518
|
+
export class DataContextResolver extends ResolverBase {
|
|
16519
|
+
@Query(() => RunDataContextViewResult)
|
|
16520
|
+
async RunDataContextViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16521
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
16522
|
+
}
|
|
16523
|
+
|
|
16524
|
+
@Query(() => RunDataContextViewResult)
|
|
16525
|
+
async RunDataContextViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16526
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
16527
|
+
}
|
|
16528
|
+
|
|
16529
|
+
@Query(() => RunDataContextViewResult)
|
|
16530
|
+
async RunDataContextDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16531
|
+
input.EntityName = 'Data Contexts';
|
|
16532
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
16533
|
+
}
|
|
16534
|
+
@Query(() => DataContext_, { nullable: true })
|
|
16535
|
+
async DataContext(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<DataContext_ | null> {
|
|
16536
|
+
this.CheckUserReadPermissions('Data Contexts', userPayload);
|
|
16537
|
+
const sSQL = `SELECT * FROM [admin].[vwDataContexts] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Data Contexts', userPayload, EntityPermissionType.Read, 'AND');
|
|
16538
|
+
const result = this.MapFieldNamesToCodeNames('Data Contexts', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
16539
|
+
return result;
|
|
16540
|
+
}
|
|
16541
|
+
|
|
16542
|
+
@FieldResolver(() => [DataContextItem_])
|
|
16543
|
+
async DataContextItemsArray(@Root() datacontext_: DataContext_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
16544
|
+
this.CheckUserReadPermissions('Data Context Items', userPayload);
|
|
16545
|
+
const sSQL = `SELECT * FROM [admin].[vwDataContextItems] WHERE [DataContextID]=${datacontext_.ID} ` + this.getRowLevelSecurityWhereClause('Data Context Items', userPayload, EntityPermissionType.Read, 'AND');
|
|
16546
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Data Context Items', await dataSource.query(sSQL));
|
|
16547
|
+
return result;
|
|
16548
|
+
}
|
|
16549
|
+
|
|
16550
|
+
@Mutation(() => DataContext_)
|
|
16551
|
+
async CreateDataContext(
|
|
16552
|
+
@Arg('input', () => CreateDataContextInput) input: CreateDataContextInput,
|
|
16553
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
16554
|
+
@PubSub() pubSub: PubSubEngine
|
|
16555
|
+
) {
|
|
16556
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
16557
|
+
const entityObject = <DataContextEntity>await new Metadata().GetEntityObject('Data Contexts', this.GetUserFromPayload(userPayload));
|
|
16558
|
+
await entityObject.NewRecord();
|
|
16559
|
+
entityObject.SetMany(input);
|
|
16560
|
+
if (await entityObject.Save()) {
|
|
16561
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
16562
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
16563
|
+
return entityObject.GetAll();
|
|
16564
|
+
}
|
|
16565
|
+
else
|
|
16566
|
+
// save failed, return null
|
|
16567
|
+
return null;
|
|
16568
|
+
}
|
|
16569
|
+
else
|
|
16570
|
+
return null;
|
|
16571
|
+
}
|
|
16572
|
+
|
|
16573
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
16574
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateDataContextInput): Promise<boolean> {
|
|
16575
|
+
return true;
|
|
16576
|
+
}
|
|
16577
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateDataContextInput) {
|
|
16578
|
+
}
|
|
16579
|
+
|
|
16580
|
+
@Mutation(() => DataContext_)
|
|
16581
|
+
async UpdateDataContext(
|
|
16582
|
+
@Arg('input', () => UpdateDataContextInput) input: UpdateDataContextInput,
|
|
16583
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
16584
|
+
@PubSub() pubSub: PubSubEngine
|
|
16585
|
+
) {
|
|
16586
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
16587
|
+
const entityObject = <DataContextEntity>await new Metadata().GetEntityObject('Data Contexts', this.GetUserFromPayload(userPayload));
|
|
16588
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Data Contexts
|
|
16589
|
+
|
|
16590
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
16591
|
+
// save worked, fire afterevent and return all the data
|
|
16592
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
16593
|
+
return entityObject.GetAll();
|
|
16594
|
+
}
|
|
16595
|
+
else
|
|
16596
|
+
return null; // save failed, return null
|
|
16597
|
+
}
|
|
16598
|
+
else
|
|
16599
|
+
return null;
|
|
16600
|
+
}
|
|
16601
|
+
|
|
16602
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
16603
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateDataContextInput): Promise<boolean> {
|
|
16604
|
+
const i = input, d = dataSource; // prevent error
|
|
16605
|
+
return true;
|
|
16606
|
+
}
|
|
16607
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateDataContextInput) {
|
|
16608
|
+
const i = input, d = dataSource; // prevent error
|
|
16609
|
+
}
|
|
16610
|
+
|
|
16180
16611
|
}
|