@memberjunction/server 0.9.128 → 0.9.141
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 +27 -0
- package/dist/apolloServer/TransactionPlugin.js +45 -45
- package/dist/apolloServer/TransactionPlugin.js.map +1 -1
- package/dist/apolloServer/index.js +26 -26
- package/dist/auth/exampleNewUserSubClass.js +53 -63
- package/dist/auth/exampleNewUserSubClass.js.map +1 -1
- package/dist/auth/index.js +110 -104
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/newUsers.js +65 -66
- package/dist/auth/newUsers.js.map +1 -1
- package/dist/cache.js +10 -10
- package/dist/config.js +62 -61
- package/dist/config.js.map +1 -1
- package/dist/context.js +101 -101
- package/dist/context.js.map +1 -1
- package/dist/directives/Public.js +33 -33
- package/dist/directives/Public.js.map +1 -1
- package/dist/directives/index.js +17 -17
- package/dist/entitySubclasses/userViewEntity.server.js +127 -127
- package/dist/entitySubclasses/userViewEntity.server.js.map +1 -1
- package/dist/generated/generated.js +20205 -19004
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/PushStatusResolver.js +58 -58
- package/dist/generic/PushStatusResolver.js.map +1 -1
- package/dist/generic/ResolverBase.js +231 -231
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.js +400 -400
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/index.js +131 -131
- package/dist/index.js.map +1 -1
- package/dist/orm.js +33 -33
- package/dist/orm.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +246 -246
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/dist/resolvers/ColorResolver.js +93 -93
- package/dist/resolvers/ColorResolver.js.map +1 -1
- package/dist/resolvers/DatasetResolver.js +167 -167
- package/dist/resolvers/DatasetResolver.js.map +1 -1
- package/dist/resolvers/EntityRecordNameResolver.js +111 -111
- package/dist/resolvers/EntityRecordNameResolver.js.map +1 -1
- package/dist/resolvers/EntityResolver.js +59 -59
- package/dist/resolvers/EntityResolver.js.map +1 -1
- package/dist/resolvers/MergeRecordsResolver.js +282 -282
- package/dist/resolvers/MergeRecordsResolver.js.map +1 -1
- package/dist/resolvers/QueryResolver.js +74 -0
- package/dist/resolvers/QueryResolver.js.map +1 -0
- package/dist/resolvers/ReportResolver.js +73 -73
- package/dist/resolvers/ReportResolver.js.map +1 -1
- package/dist/resolvers/UserFavoriteResolver.js +161 -161
- package/dist/resolvers/UserFavoriteResolver.js.map +1 -1
- package/dist/resolvers/UserResolver.js +69 -69
- package/dist/resolvers/UserResolver.js.map +1 -1
- package/dist/resolvers/UserViewResolver.js +101 -101
- package/dist/resolvers/UserViewResolver.js.map +1 -1
- package/dist/types.js +2 -2
- package/package.json +11 -11
- package/src/apolloServer/TransactionPlugin.ts +1 -1
- package/src/auth/exampleNewUserSubClass.ts +3 -1
- package/src/auth/index.ts +13 -4
- package/src/config.ts +1 -0
- package/src/generated/generated.ts +921 -2
- package/src/resolvers/AskSkipResolver.ts +1 -1
- package/src/resolvers/QueryResolver.ts +42 -0
- package/src/resolvers/ReportResolver.ts +0 -15
- package/tsconfig.json +2 -2
|
@@ -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:
|
|
5
|
+
* GENERATED: 2/3/2024, 4:49:15 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 } 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 } from '@memberjunction/core-entities';
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
//****************************************************************************
|
|
@@ -1266,6 +1266,9 @@ export class Role_ {
|
|
|
1266
1266
|
@Field(() => [AuthorizationRole_])
|
|
1267
1267
|
AuthorizationRolesArray: AuthorizationRole_[]; // Link to AuthorizationRoles
|
|
1268
1268
|
|
|
1269
|
+
@Field(() => [QueryPermission_])
|
|
1270
|
+
QueryPermissionsArray: QueryPermission_[]; // Link to QueryPermissions
|
|
1271
|
+
|
|
1269
1272
|
}
|
|
1270
1273
|
|
|
1271
1274
|
//****************************************************************************
|
|
@@ -1380,6 +1383,14 @@ export class RoleResolver extends ResolverBase {
|
|
|
1380
1383
|
const result = this.ArrayMapFieldNamesToCodeNames('Authorization Roles', await dataSource.query(sSQL));
|
|
1381
1384
|
return result;
|
|
1382
1385
|
}
|
|
1386
|
+
|
|
1387
|
+
@FieldResolver(() => [QueryPermission_])
|
|
1388
|
+
async QueryPermissionsArray(@Root() role_: Role_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
1389
|
+
this.CheckUserReadPermissions('Query Permissions', userPayload);
|
|
1390
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryPermissions] WHERE [RoleName]=${role_.ID} ` + this.getRowLevelSecurityWhereClause('Query Permissions', userPayload, EntityPermissionType.Read, 'AND');
|
|
1391
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Permissions', await dataSource.query(sSQL));
|
|
1392
|
+
return result;
|
|
1393
|
+
}
|
|
1383
1394
|
|
|
1384
1395
|
@Mutation(() => Role_)
|
|
1385
1396
|
async UpdateRole(
|
|
@@ -2841,6 +2852,9 @@ export class Entity_ {
|
|
|
2841
2852
|
@Field(() => [RecordMergeLog_])
|
|
2842
2853
|
RecordMergeLogsArray: RecordMergeLog_[]; // Link to RecordMergeLogs
|
|
2843
2854
|
|
|
2855
|
+
@Field(() => [QueryField_])
|
|
2856
|
+
QueryFieldsArray: QueryField_[]; // Link to QueryFields
|
|
2857
|
+
|
|
2844
2858
|
}
|
|
2845
2859
|
|
|
2846
2860
|
//****************************************************************************
|
|
@@ -3291,6 +3305,14 @@ export class EntityResolverBase extends ResolverBase {
|
|
|
3291
3305
|
const result = this.ArrayMapFieldNamesToCodeNames('Record Merge Logs', await dataSource.query(sSQL));
|
|
3292
3306
|
return result;
|
|
3293
3307
|
}
|
|
3308
|
+
|
|
3309
|
+
@FieldResolver(() => [QueryField_])
|
|
3310
|
+
async QueryFieldsArray(@Root() entity_: Entity_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
3311
|
+
this.CheckUserReadPermissions('Query Fields', userPayload);
|
|
3312
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryFields] WHERE [SourceEntityID]=${entity_.ID} ` + this.getRowLevelSecurityWhereClause('Query Fields', userPayload, EntityPermissionType.Read, 'AND');
|
|
3313
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Fields', await dataSource.query(sSQL));
|
|
3314
|
+
return result;
|
|
3315
|
+
}
|
|
3294
3316
|
|
|
3295
3317
|
@Mutation(() => Entity_)
|
|
3296
3318
|
async CreateEntity(
|
|
@@ -12300,6 +12322,9 @@ export class ConversationDetail_ {
|
|
|
12300
12322
|
@Field({nullable: true})
|
|
12301
12323
|
Error?: string;
|
|
12302
12324
|
|
|
12325
|
+
@Field(() => Boolean)
|
|
12326
|
+
HiddenToUser: boolean;
|
|
12327
|
+
|
|
12303
12328
|
@Field()
|
|
12304
12329
|
@MaxLength(8)
|
|
12305
12330
|
CreatedAt: Date;
|
|
@@ -12336,6 +12361,9 @@ export class CreateConversationDetailInput {
|
|
|
12336
12361
|
|
|
12337
12362
|
@Field({ nullable: true })
|
|
12338
12363
|
Error: string;
|
|
12364
|
+
|
|
12365
|
+
@Field(() => Boolean, )
|
|
12366
|
+
HiddenToUser: boolean;
|
|
12339
12367
|
}
|
|
12340
12368
|
|
|
12341
12369
|
|
|
@@ -12361,6 +12389,9 @@ export class UpdateConversationDetailInput {
|
|
|
12361
12389
|
|
|
12362
12390
|
@Field({ nullable: true })
|
|
12363
12391
|
Error: string;
|
|
12392
|
+
|
|
12393
|
+
@Field(() => Boolean, )
|
|
12394
|
+
HiddenToUser: boolean;
|
|
12364
12395
|
}
|
|
12365
12396
|
|
|
12366
12397
|
//****************************************************************************
|
|
@@ -12531,6 +12562,13 @@ export class Conversation_ {
|
|
|
12531
12562
|
@MaxLength(200)
|
|
12532
12563
|
Name?: string;
|
|
12533
12564
|
|
|
12565
|
+
@Field({nullable: true})
|
|
12566
|
+
Description?: string;
|
|
12567
|
+
|
|
12568
|
+
@Field()
|
|
12569
|
+
@MaxLength(100)
|
|
12570
|
+
Type: string;
|
|
12571
|
+
|
|
12534
12572
|
@Field()
|
|
12535
12573
|
@MaxLength(8)
|
|
12536
12574
|
CreatedAt: Date;
|
|
@@ -12564,6 +12602,12 @@ export class CreateConversationInput {
|
|
|
12564
12602
|
|
|
12565
12603
|
@Field({ nullable: true })
|
|
12566
12604
|
Name: string;
|
|
12605
|
+
|
|
12606
|
+
@Field({ nullable: true })
|
|
12607
|
+
Description: string;
|
|
12608
|
+
|
|
12609
|
+
@Field()
|
|
12610
|
+
Type: string;
|
|
12567
12611
|
}
|
|
12568
12612
|
|
|
12569
12613
|
|
|
@@ -12583,6 +12627,12 @@ export class UpdateConversationInput {
|
|
|
12583
12627
|
|
|
12584
12628
|
@Field({ nullable: true })
|
|
12585
12629
|
Name: string;
|
|
12630
|
+
|
|
12631
|
+
@Field({ nullable: true })
|
|
12632
|
+
Description: string;
|
|
12633
|
+
|
|
12634
|
+
@Field()
|
|
12635
|
+
Type: string;
|
|
12586
12636
|
}
|
|
12587
12637
|
|
|
12588
12638
|
//****************************************************************************
|
|
@@ -14009,4 +14059,873 @@ export class RecordMergeDeletionLogResolver extends ResolverBase {
|
|
|
14009
14059
|
const i = input, d = dataSource; // prevent error
|
|
14010
14060
|
}
|
|
14011
14061
|
|
|
14062
|
+
}
|
|
14063
|
+
|
|
14064
|
+
//****************************************************************************
|
|
14065
|
+
// ENTITY CLASS for Query Fields
|
|
14066
|
+
//****************************************************************************
|
|
14067
|
+
@ObjectType()
|
|
14068
|
+
export class QueryField_ {
|
|
14069
|
+
@Field(() => Int)
|
|
14070
|
+
ID: number;
|
|
14071
|
+
|
|
14072
|
+
@Field(() => Int)
|
|
14073
|
+
QueryID: number;
|
|
14074
|
+
|
|
14075
|
+
@Field()
|
|
14076
|
+
@MaxLength(510)
|
|
14077
|
+
Name: string;
|
|
14078
|
+
|
|
14079
|
+
@Field({nullable: true})
|
|
14080
|
+
Description?: string;
|
|
14081
|
+
|
|
14082
|
+
@Field(() => Int)
|
|
14083
|
+
Sequence: number;
|
|
14084
|
+
|
|
14085
|
+
@Field(() => Int, {nullable: true})
|
|
14086
|
+
SourceEntityID?: number;
|
|
14087
|
+
|
|
14088
|
+
@Field({nullable: true})
|
|
14089
|
+
@MaxLength(510)
|
|
14090
|
+
SourceFieldName?: string;
|
|
14091
|
+
|
|
14092
|
+
@Field(() => Boolean)
|
|
14093
|
+
IsComputed: boolean;
|
|
14094
|
+
|
|
14095
|
+
@Field({nullable: true})
|
|
14096
|
+
ComputationDescription?: string;
|
|
14097
|
+
|
|
14098
|
+
@Field(() => Boolean)
|
|
14099
|
+
IsSummary: boolean;
|
|
14100
|
+
|
|
14101
|
+
@Field({nullable: true})
|
|
14102
|
+
SummaryDescription?: string;
|
|
14103
|
+
|
|
14104
|
+
@Field()
|
|
14105
|
+
@MaxLength(8)
|
|
14106
|
+
CreatedAt: Date;
|
|
14107
|
+
|
|
14108
|
+
@Field()
|
|
14109
|
+
@MaxLength(8)
|
|
14110
|
+
UpdatedAt: Date;
|
|
14111
|
+
|
|
14112
|
+
@Field()
|
|
14113
|
+
@MaxLength(510)
|
|
14114
|
+
Query: string;
|
|
14115
|
+
|
|
14116
|
+
@Field({nullable: true})
|
|
14117
|
+
@MaxLength(510)
|
|
14118
|
+
SourceEntity?: string;
|
|
14119
|
+
|
|
14120
|
+
}
|
|
14121
|
+
|
|
14122
|
+
//****************************************************************************
|
|
14123
|
+
// INPUT TYPE for Query Fields
|
|
14124
|
+
//****************************************************************************
|
|
14125
|
+
@InputType()
|
|
14126
|
+
export class CreateQueryFieldInput {
|
|
14127
|
+
@Field(() => Int, )
|
|
14128
|
+
QueryID: number;
|
|
14129
|
+
|
|
14130
|
+
@Field()
|
|
14131
|
+
Name: string;
|
|
14132
|
+
|
|
14133
|
+
@Field({ nullable: true })
|
|
14134
|
+
Description: string;
|
|
14135
|
+
|
|
14136
|
+
@Field(() => Int, )
|
|
14137
|
+
Sequence: number;
|
|
14138
|
+
|
|
14139
|
+
@Field(() => Int, { nullable: true })
|
|
14140
|
+
SourceEntityID: number;
|
|
14141
|
+
|
|
14142
|
+
@Field({ nullable: true })
|
|
14143
|
+
SourceFieldName: string;
|
|
14144
|
+
|
|
14145
|
+
@Field(() => Boolean, )
|
|
14146
|
+
IsComputed: boolean;
|
|
14147
|
+
|
|
14148
|
+
@Field({ nullable: true })
|
|
14149
|
+
ComputationDescription: string;
|
|
14150
|
+
|
|
14151
|
+
@Field(() => Boolean, )
|
|
14152
|
+
IsSummary: boolean;
|
|
14153
|
+
|
|
14154
|
+
@Field({ nullable: true })
|
|
14155
|
+
SummaryDescription: string;
|
|
14156
|
+
}
|
|
14157
|
+
|
|
14158
|
+
|
|
14159
|
+
//****************************************************************************
|
|
14160
|
+
// INPUT TYPE for Query Fields
|
|
14161
|
+
//****************************************************************************
|
|
14162
|
+
@InputType()
|
|
14163
|
+
export class UpdateQueryFieldInput {
|
|
14164
|
+
@Field(() => Int, )
|
|
14165
|
+
ID: number;
|
|
14166
|
+
|
|
14167
|
+
@Field(() => Int, )
|
|
14168
|
+
QueryID: number;
|
|
14169
|
+
|
|
14170
|
+
@Field()
|
|
14171
|
+
Name: string;
|
|
14172
|
+
|
|
14173
|
+
@Field({ nullable: true })
|
|
14174
|
+
Description: string;
|
|
14175
|
+
|
|
14176
|
+
@Field(() => Int, )
|
|
14177
|
+
Sequence: number;
|
|
14178
|
+
|
|
14179
|
+
@Field(() => Int, { nullable: true })
|
|
14180
|
+
SourceEntityID: number;
|
|
14181
|
+
|
|
14182
|
+
@Field({ nullable: true })
|
|
14183
|
+
SourceFieldName: string;
|
|
14184
|
+
|
|
14185
|
+
@Field(() => Boolean, )
|
|
14186
|
+
IsComputed: boolean;
|
|
14187
|
+
|
|
14188
|
+
@Field({ nullable: true })
|
|
14189
|
+
ComputationDescription: string;
|
|
14190
|
+
|
|
14191
|
+
@Field(() => Boolean, )
|
|
14192
|
+
IsSummary: boolean;
|
|
14193
|
+
|
|
14194
|
+
@Field({ nullable: true })
|
|
14195
|
+
SummaryDescription: string;
|
|
14196
|
+
}
|
|
14197
|
+
|
|
14198
|
+
//****************************************************************************
|
|
14199
|
+
// RESOLVER for Query Fields
|
|
14200
|
+
//****************************************************************************
|
|
14201
|
+
@ObjectType()
|
|
14202
|
+
export class RunQueryFieldViewResult {
|
|
14203
|
+
@Field(() => [QueryField_])
|
|
14204
|
+
Results: QueryField_[];
|
|
14205
|
+
|
|
14206
|
+
@Field(() => Int, {nullable: true})
|
|
14207
|
+
UserViewRunID?: number;
|
|
14208
|
+
|
|
14209
|
+
@Field(() => Int, {nullable: true})
|
|
14210
|
+
RowCount: number;
|
|
14211
|
+
|
|
14212
|
+
@Field(() => Int, {nullable: true})
|
|
14213
|
+
TotalRowCount: number;
|
|
14214
|
+
|
|
14215
|
+
@Field(() => Int, {nullable: true})
|
|
14216
|
+
ExecutionTime: number;
|
|
14217
|
+
|
|
14218
|
+
@Field({nullable: true})
|
|
14219
|
+
ErrorMessage?: string;
|
|
14220
|
+
|
|
14221
|
+
@Field(() => Boolean, {nullable: false})
|
|
14222
|
+
Success: boolean;
|
|
14223
|
+
}
|
|
14224
|
+
|
|
14225
|
+
@Resolver(QueryField_)
|
|
14226
|
+
export class QueryFieldResolver extends ResolverBase {
|
|
14227
|
+
@Query(() => RunQueryFieldViewResult)
|
|
14228
|
+
async RunQueryFieldViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14229
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
14230
|
+
}
|
|
14231
|
+
|
|
14232
|
+
@Query(() => RunQueryFieldViewResult)
|
|
14233
|
+
async RunQueryFieldViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14234
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
14235
|
+
}
|
|
14236
|
+
|
|
14237
|
+
@Query(() => RunQueryFieldViewResult)
|
|
14238
|
+
async RunQueryFieldDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14239
|
+
input.EntityName = 'Query Fields';
|
|
14240
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
14241
|
+
}
|
|
14242
|
+
@Query(() => QueryField_, { nullable: true })
|
|
14243
|
+
async QueryField(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<QueryField_ | null> {
|
|
14244
|
+
this.CheckUserReadPermissions('Query Fields', userPayload);
|
|
14245
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryFields] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Query Fields', userPayload, EntityPermissionType.Read, 'AND');
|
|
14246
|
+
const result = this.MapFieldNamesToCodeNames('Query Fields', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
14247
|
+
return result;
|
|
14248
|
+
}
|
|
14249
|
+
|
|
14250
|
+
@Mutation(() => QueryField_)
|
|
14251
|
+
async CreateQueryField(
|
|
14252
|
+
@Arg('input', () => CreateQueryFieldInput) input: CreateQueryFieldInput,
|
|
14253
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14254
|
+
@PubSub() pubSub: PubSubEngine
|
|
14255
|
+
) {
|
|
14256
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14257
|
+
const entityObject = <QueryFieldEntity>await new Metadata().GetEntityObject('Query Fields', this.GetUserFromPayload(userPayload));
|
|
14258
|
+
await entityObject.NewRecord();
|
|
14259
|
+
entityObject.SetMany(input);
|
|
14260
|
+
if (await entityObject.Save()) {
|
|
14261
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
14262
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
14263
|
+
return entityObject.GetAll();
|
|
14264
|
+
}
|
|
14265
|
+
else
|
|
14266
|
+
// save failed, return null
|
|
14267
|
+
return null;
|
|
14268
|
+
}
|
|
14269
|
+
else
|
|
14270
|
+
return null;
|
|
14271
|
+
}
|
|
14272
|
+
|
|
14273
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
14274
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateQueryFieldInput): Promise<boolean> {
|
|
14275
|
+
return true;
|
|
14276
|
+
}
|
|
14277
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateQueryFieldInput) {
|
|
14278
|
+
}
|
|
14279
|
+
|
|
14280
|
+
@Mutation(() => QueryField_)
|
|
14281
|
+
async UpdateQueryField(
|
|
14282
|
+
@Arg('input', () => UpdateQueryFieldInput) input: UpdateQueryFieldInput,
|
|
14283
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14284
|
+
@PubSub() pubSub: PubSubEngine
|
|
14285
|
+
) {
|
|
14286
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14287
|
+
const entityObject = <QueryFieldEntity>await new Metadata().GetEntityObject('Query Fields', this.GetUserFromPayload(userPayload));
|
|
14288
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Query Fields
|
|
14289
|
+
|
|
14290
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
14291
|
+
// save worked, fire afterevent and return all the data
|
|
14292
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
14293
|
+
return entityObject.GetAll();
|
|
14294
|
+
}
|
|
14295
|
+
else
|
|
14296
|
+
return null; // save failed, return null
|
|
14297
|
+
}
|
|
14298
|
+
else
|
|
14299
|
+
return null;
|
|
14300
|
+
}
|
|
14301
|
+
|
|
14302
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
14303
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateQueryFieldInput): Promise<boolean> {
|
|
14304
|
+
const i = input, d = dataSource; // prevent error
|
|
14305
|
+
return true;
|
|
14306
|
+
}
|
|
14307
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateQueryFieldInput) {
|
|
14308
|
+
const i = input, d = dataSource; // prevent error
|
|
14309
|
+
}
|
|
14310
|
+
|
|
14311
|
+
}
|
|
14312
|
+
|
|
14313
|
+
//****************************************************************************
|
|
14314
|
+
// ENTITY CLASS for Query Categories
|
|
14315
|
+
//****************************************************************************
|
|
14316
|
+
@ObjectType()
|
|
14317
|
+
export class QueryCategory_ {
|
|
14318
|
+
@Field(() => Int)
|
|
14319
|
+
ID: number;
|
|
14320
|
+
|
|
14321
|
+
@Field()
|
|
14322
|
+
@MaxLength(100)
|
|
14323
|
+
Name: string;
|
|
14324
|
+
|
|
14325
|
+
@Field(() => Int, {nullable: true})
|
|
14326
|
+
ParentID?: number;
|
|
14327
|
+
|
|
14328
|
+
@Field({nullable: true})
|
|
14329
|
+
Description?: string;
|
|
14330
|
+
|
|
14331
|
+
@Field()
|
|
14332
|
+
@MaxLength(8)
|
|
14333
|
+
CreatedAt: Date;
|
|
14334
|
+
|
|
14335
|
+
@Field()
|
|
14336
|
+
@MaxLength(8)
|
|
14337
|
+
UpdatedAt: Date;
|
|
14338
|
+
|
|
14339
|
+
@Field({nullable: true})
|
|
14340
|
+
@MaxLength(100)
|
|
14341
|
+
Parent?: string;
|
|
14342
|
+
|
|
14343
|
+
@Field(() => [QueryCategory_])
|
|
14344
|
+
QueryCategoriesArray: QueryCategory_[]; // Link to QueryCategories
|
|
14345
|
+
|
|
14346
|
+
@Field(() => [Query_])
|
|
14347
|
+
QueriesArray: Query_[]; // Link to Queries
|
|
14348
|
+
|
|
14349
|
+
}
|
|
14350
|
+
|
|
14351
|
+
//****************************************************************************
|
|
14352
|
+
// INPUT TYPE for Query Categories
|
|
14353
|
+
//****************************************************************************
|
|
14354
|
+
@InputType()
|
|
14355
|
+
export class CreateQueryCategoryInput {
|
|
14356
|
+
@Field()
|
|
14357
|
+
Name: string;
|
|
14358
|
+
|
|
14359
|
+
@Field(() => Int, { nullable: true })
|
|
14360
|
+
ParentID: number;
|
|
14361
|
+
|
|
14362
|
+
@Field({ nullable: true })
|
|
14363
|
+
Description: string;
|
|
14364
|
+
}
|
|
14365
|
+
|
|
14366
|
+
|
|
14367
|
+
//****************************************************************************
|
|
14368
|
+
// INPUT TYPE for Query Categories
|
|
14369
|
+
//****************************************************************************
|
|
14370
|
+
@InputType()
|
|
14371
|
+
export class UpdateQueryCategoryInput {
|
|
14372
|
+
@Field(() => Int, )
|
|
14373
|
+
ID: number;
|
|
14374
|
+
|
|
14375
|
+
@Field()
|
|
14376
|
+
Name: string;
|
|
14377
|
+
|
|
14378
|
+
@Field(() => Int, { nullable: true })
|
|
14379
|
+
ParentID: number;
|
|
14380
|
+
|
|
14381
|
+
@Field({ nullable: true })
|
|
14382
|
+
Description: string;
|
|
14383
|
+
}
|
|
14384
|
+
|
|
14385
|
+
//****************************************************************************
|
|
14386
|
+
// RESOLVER for Query Categories
|
|
14387
|
+
//****************************************************************************
|
|
14388
|
+
@ObjectType()
|
|
14389
|
+
export class RunQueryCategoryViewResult {
|
|
14390
|
+
@Field(() => [QueryCategory_])
|
|
14391
|
+
Results: QueryCategory_[];
|
|
14392
|
+
|
|
14393
|
+
@Field(() => Int, {nullable: true})
|
|
14394
|
+
UserViewRunID?: number;
|
|
14395
|
+
|
|
14396
|
+
@Field(() => Int, {nullable: true})
|
|
14397
|
+
RowCount: number;
|
|
14398
|
+
|
|
14399
|
+
@Field(() => Int, {nullable: true})
|
|
14400
|
+
TotalRowCount: number;
|
|
14401
|
+
|
|
14402
|
+
@Field(() => Int, {nullable: true})
|
|
14403
|
+
ExecutionTime: number;
|
|
14404
|
+
|
|
14405
|
+
@Field({nullable: true})
|
|
14406
|
+
ErrorMessage?: string;
|
|
14407
|
+
|
|
14408
|
+
@Field(() => Boolean, {nullable: false})
|
|
14409
|
+
Success: boolean;
|
|
14410
|
+
}
|
|
14411
|
+
|
|
14412
|
+
@Resolver(QueryCategory_)
|
|
14413
|
+
export class QueryCategoryResolver extends ResolverBase {
|
|
14414
|
+
@Query(() => RunQueryCategoryViewResult)
|
|
14415
|
+
async RunQueryCategoryViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14416
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
14417
|
+
}
|
|
14418
|
+
|
|
14419
|
+
@Query(() => RunQueryCategoryViewResult)
|
|
14420
|
+
async RunQueryCategoryViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14421
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
14422
|
+
}
|
|
14423
|
+
|
|
14424
|
+
@Query(() => RunQueryCategoryViewResult)
|
|
14425
|
+
async RunQueryCategoryDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14426
|
+
input.EntityName = 'Query Categories';
|
|
14427
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
14428
|
+
}
|
|
14429
|
+
@Query(() => QueryCategory_, { nullable: true })
|
|
14430
|
+
async QueryCategory(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<QueryCategory_ | null> {
|
|
14431
|
+
this.CheckUserReadPermissions('Query Categories', userPayload);
|
|
14432
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryCategories] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Query Categories', userPayload, EntityPermissionType.Read, 'AND');
|
|
14433
|
+
const result = this.MapFieldNamesToCodeNames('Query Categories', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
14434
|
+
return result;
|
|
14435
|
+
}
|
|
14436
|
+
|
|
14437
|
+
@FieldResolver(() => [QueryCategory_])
|
|
14438
|
+
async QueryCategoriesArray(@Root() querycategory_: QueryCategory_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14439
|
+
this.CheckUserReadPermissions('Query Categories', userPayload);
|
|
14440
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryCategories] WHERE [ParentID]=${querycategory_.ID} ` + this.getRowLevelSecurityWhereClause('Query Categories', userPayload, EntityPermissionType.Read, 'AND');
|
|
14441
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Categories', await dataSource.query(sSQL));
|
|
14442
|
+
return result;
|
|
14443
|
+
}
|
|
14444
|
+
|
|
14445
|
+
@FieldResolver(() => [Query_])
|
|
14446
|
+
async QueriesArray(@Root() querycategory_: QueryCategory_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14447
|
+
this.CheckUserReadPermissions('Queries', userPayload);
|
|
14448
|
+
const sSQL = `SELECT * FROM [admin].[vwQueries] WHERE [CategoryID]=${querycategory_.ID} ` + this.getRowLevelSecurityWhereClause('Queries', userPayload, EntityPermissionType.Read, 'AND');
|
|
14449
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Queries', await dataSource.query(sSQL));
|
|
14450
|
+
return result;
|
|
14451
|
+
}
|
|
14452
|
+
|
|
14453
|
+
@Mutation(() => QueryCategory_)
|
|
14454
|
+
async CreateQueryCategory(
|
|
14455
|
+
@Arg('input', () => CreateQueryCategoryInput) input: CreateQueryCategoryInput,
|
|
14456
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14457
|
+
@PubSub() pubSub: PubSubEngine
|
|
14458
|
+
) {
|
|
14459
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14460
|
+
const entityObject = <QueryCategoryEntity>await new Metadata().GetEntityObject('Query Categories', this.GetUserFromPayload(userPayload));
|
|
14461
|
+
await entityObject.NewRecord();
|
|
14462
|
+
entityObject.SetMany(input);
|
|
14463
|
+
if (await entityObject.Save()) {
|
|
14464
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
14465
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
14466
|
+
return entityObject.GetAll();
|
|
14467
|
+
}
|
|
14468
|
+
else
|
|
14469
|
+
// save failed, return null
|
|
14470
|
+
return null;
|
|
14471
|
+
}
|
|
14472
|
+
else
|
|
14473
|
+
return null;
|
|
14474
|
+
}
|
|
14475
|
+
|
|
14476
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
14477
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateQueryCategoryInput): Promise<boolean> {
|
|
14478
|
+
return true;
|
|
14479
|
+
}
|
|
14480
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateQueryCategoryInput) {
|
|
14481
|
+
}
|
|
14482
|
+
|
|
14483
|
+
@Mutation(() => QueryCategory_)
|
|
14484
|
+
async UpdateQueryCategory(
|
|
14485
|
+
@Arg('input', () => UpdateQueryCategoryInput) input: UpdateQueryCategoryInput,
|
|
14486
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14487
|
+
@PubSub() pubSub: PubSubEngine
|
|
14488
|
+
) {
|
|
14489
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14490
|
+
const entityObject = <QueryCategoryEntity>await new Metadata().GetEntityObject('Query Categories', this.GetUserFromPayload(userPayload));
|
|
14491
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Query Categories
|
|
14492
|
+
|
|
14493
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
14494
|
+
// save worked, fire afterevent and return all the data
|
|
14495
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
14496
|
+
return entityObject.GetAll();
|
|
14497
|
+
}
|
|
14498
|
+
else
|
|
14499
|
+
return null; // save failed, return null
|
|
14500
|
+
}
|
|
14501
|
+
else
|
|
14502
|
+
return null;
|
|
14503
|
+
}
|
|
14504
|
+
|
|
14505
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
14506
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateQueryCategoryInput): Promise<boolean> {
|
|
14507
|
+
const i = input, d = dataSource; // prevent error
|
|
14508
|
+
return true;
|
|
14509
|
+
}
|
|
14510
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateQueryCategoryInput) {
|
|
14511
|
+
const i = input, d = dataSource; // prevent error
|
|
14512
|
+
}
|
|
14513
|
+
|
|
14514
|
+
}
|
|
14515
|
+
|
|
14516
|
+
//****************************************************************************
|
|
14517
|
+
// ENTITY CLASS for Queries
|
|
14518
|
+
//****************************************************************************
|
|
14519
|
+
@ObjectType()
|
|
14520
|
+
export class Query_ {
|
|
14521
|
+
@Field(() => Int)
|
|
14522
|
+
ID: number;
|
|
14523
|
+
|
|
14524
|
+
@Field()
|
|
14525
|
+
@MaxLength(510)
|
|
14526
|
+
Name: string;
|
|
14527
|
+
|
|
14528
|
+
@Field({nullable: true})
|
|
14529
|
+
Description?: string;
|
|
14530
|
+
|
|
14531
|
+
@Field(() => Int)
|
|
14532
|
+
CategoryID: number;
|
|
14533
|
+
|
|
14534
|
+
@Field({nullable: true})
|
|
14535
|
+
SQL?: string;
|
|
14536
|
+
|
|
14537
|
+
@Field({nullable: true})
|
|
14538
|
+
OriginalSQL?: string;
|
|
14539
|
+
|
|
14540
|
+
@Field({nullable: true})
|
|
14541
|
+
Feedback?: string;
|
|
14542
|
+
|
|
14543
|
+
@Field()
|
|
14544
|
+
@MaxLength(30)
|
|
14545
|
+
Status: string;
|
|
14546
|
+
|
|
14547
|
+
@Field(() => Int, {nullable: true})
|
|
14548
|
+
QualityRank?: number;
|
|
14549
|
+
|
|
14550
|
+
@Field()
|
|
14551
|
+
@MaxLength(8)
|
|
14552
|
+
CreatedAt: Date;
|
|
14553
|
+
|
|
14554
|
+
@Field()
|
|
14555
|
+
@MaxLength(8)
|
|
14556
|
+
UpdatedAt: Date;
|
|
14557
|
+
|
|
14558
|
+
@Field()
|
|
14559
|
+
@MaxLength(100)
|
|
14560
|
+
Category: string;
|
|
14561
|
+
|
|
14562
|
+
@Field(() => [QueryField_])
|
|
14563
|
+
QueryFieldsArray: QueryField_[]; // Link to QueryFields
|
|
14564
|
+
|
|
14565
|
+
@Field(() => [QueryPermission_])
|
|
14566
|
+
QueryPermissionsArray: QueryPermission_[]; // Link to QueryPermissions
|
|
14567
|
+
|
|
14568
|
+
}
|
|
14569
|
+
|
|
14570
|
+
//****************************************************************************
|
|
14571
|
+
// INPUT TYPE for Queries
|
|
14572
|
+
//****************************************************************************
|
|
14573
|
+
@InputType()
|
|
14574
|
+
export class CreateQueryInput {
|
|
14575
|
+
@Field()
|
|
14576
|
+
Name: string;
|
|
14577
|
+
|
|
14578
|
+
@Field({ nullable: true })
|
|
14579
|
+
Description: string;
|
|
14580
|
+
|
|
14581
|
+
@Field(() => Int, )
|
|
14582
|
+
CategoryID: number;
|
|
14583
|
+
|
|
14584
|
+
@Field({ nullable: true })
|
|
14585
|
+
SQL: string;
|
|
14586
|
+
|
|
14587
|
+
@Field({ nullable: true })
|
|
14588
|
+
OriginalSQL: string;
|
|
14589
|
+
|
|
14590
|
+
@Field({ nullable: true })
|
|
14591
|
+
Feedback: string;
|
|
14592
|
+
|
|
14593
|
+
@Field()
|
|
14594
|
+
Status: string;
|
|
14595
|
+
|
|
14596
|
+
@Field(() => Int, { nullable: true })
|
|
14597
|
+
QualityRank: number;
|
|
14598
|
+
}
|
|
14599
|
+
|
|
14600
|
+
|
|
14601
|
+
//****************************************************************************
|
|
14602
|
+
// INPUT TYPE for Queries
|
|
14603
|
+
//****************************************************************************
|
|
14604
|
+
@InputType()
|
|
14605
|
+
export class UpdateQueryInput {
|
|
14606
|
+
@Field(() => Int, )
|
|
14607
|
+
ID: number;
|
|
14608
|
+
|
|
14609
|
+
@Field()
|
|
14610
|
+
Name: string;
|
|
14611
|
+
|
|
14612
|
+
@Field({ nullable: true })
|
|
14613
|
+
Description: string;
|
|
14614
|
+
|
|
14615
|
+
@Field(() => Int, )
|
|
14616
|
+
CategoryID: number;
|
|
14617
|
+
|
|
14618
|
+
@Field({ nullable: true })
|
|
14619
|
+
SQL: string;
|
|
14620
|
+
|
|
14621
|
+
@Field({ nullable: true })
|
|
14622
|
+
OriginalSQL: string;
|
|
14623
|
+
|
|
14624
|
+
@Field({ nullable: true })
|
|
14625
|
+
Feedback: string;
|
|
14626
|
+
|
|
14627
|
+
@Field()
|
|
14628
|
+
Status: string;
|
|
14629
|
+
|
|
14630
|
+
@Field(() => Int, { nullable: true })
|
|
14631
|
+
QualityRank: number;
|
|
14632
|
+
}
|
|
14633
|
+
|
|
14634
|
+
//****************************************************************************
|
|
14635
|
+
// RESOLVER for Queries
|
|
14636
|
+
//****************************************************************************
|
|
14637
|
+
@ObjectType()
|
|
14638
|
+
export class RunQueryViewResult {
|
|
14639
|
+
@Field(() => [Query_])
|
|
14640
|
+
Results: Query_[];
|
|
14641
|
+
|
|
14642
|
+
@Field(() => Int, {nullable: true})
|
|
14643
|
+
UserViewRunID?: number;
|
|
14644
|
+
|
|
14645
|
+
@Field(() => Int, {nullable: true})
|
|
14646
|
+
RowCount: number;
|
|
14647
|
+
|
|
14648
|
+
@Field(() => Int, {nullable: true})
|
|
14649
|
+
TotalRowCount: number;
|
|
14650
|
+
|
|
14651
|
+
@Field(() => Int, {nullable: true})
|
|
14652
|
+
ExecutionTime: number;
|
|
14653
|
+
|
|
14654
|
+
@Field({nullable: true})
|
|
14655
|
+
ErrorMessage?: string;
|
|
14656
|
+
|
|
14657
|
+
@Field(() => Boolean, {nullable: false})
|
|
14658
|
+
Success: boolean;
|
|
14659
|
+
}
|
|
14660
|
+
|
|
14661
|
+
@Resolver(Query_)
|
|
14662
|
+
export class QueryResolver extends ResolverBase {
|
|
14663
|
+
@Query(() => RunQueryViewResult)
|
|
14664
|
+
async RunQueryViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14665
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
14666
|
+
}
|
|
14667
|
+
|
|
14668
|
+
@Query(() => RunQueryViewResult)
|
|
14669
|
+
async RunQueryViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14670
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
14671
|
+
}
|
|
14672
|
+
|
|
14673
|
+
@Query(() => RunQueryViewResult)
|
|
14674
|
+
async RunQueryDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14675
|
+
input.EntityName = 'Queries';
|
|
14676
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
14677
|
+
}
|
|
14678
|
+
@Query(() => Query_, { nullable: true })
|
|
14679
|
+
async Query(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<Query_ | null> {
|
|
14680
|
+
this.CheckUserReadPermissions('Queries', userPayload);
|
|
14681
|
+
const sSQL = `SELECT * FROM [admin].[vwQueries] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Queries', userPayload, EntityPermissionType.Read, 'AND');
|
|
14682
|
+
const result = this.MapFieldNamesToCodeNames('Queries', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
14683
|
+
return result;
|
|
14684
|
+
}
|
|
14685
|
+
|
|
14686
|
+
@FieldResolver(() => [QueryField_])
|
|
14687
|
+
async QueryFieldsArray(@Root() query_: Query_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14688
|
+
this.CheckUserReadPermissions('Query Fields', userPayload);
|
|
14689
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryFields] WHERE [QueryID]=${query_.ID} ` + this.getRowLevelSecurityWhereClause('Query Fields', userPayload, EntityPermissionType.Read, 'AND');
|
|
14690
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Fields', await dataSource.query(sSQL));
|
|
14691
|
+
return result;
|
|
14692
|
+
}
|
|
14693
|
+
|
|
14694
|
+
@FieldResolver(() => [QueryPermission_])
|
|
14695
|
+
async QueryPermissionsArray(@Root() query_: Query_, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14696
|
+
this.CheckUserReadPermissions('Query Permissions', userPayload);
|
|
14697
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryPermissions] WHERE [QueryID]=${query_.ID} ` + this.getRowLevelSecurityWhereClause('Query Permissions', userPayload, EntityPermissionType.Read, 'AND');
|
|
14698
|
+
const result = this.ArrayMapFieldNamesToCodeNames('Query Permissions', await dataSource.query(sSQL));
|
|
14699
|
+
return result;
|
|
14700
|
+
}
|
|
14701
|
+
|
|
14702
|
+
@Mutation(() => Query_)
|
|
14703
|
+
async CreateQuery(
|
|
14704
|
+
@Arg('input', () => CreateQueryInput) input: CreateQueryInput,
|
|
14705
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14706
|
+
@PubSub() pubSub: PubSubEngine
|
|
14707
|
+
) {
|
|
14708
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14709
|
+
const entityObject = <QueryEntity>await new Metadata().GetEntityObject('Queries', this.GetUserFromPayload(userPayload));
|
|
14710
|
+
await entityObject.NewRecord();
|
|
14711
|
+
entityObject.SetMany(input);
|
|
14712
|
+
if (await entityObject.Save()) {
|
|
14713
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
14714
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
14715
|
+
return entityObject.GetAll();
|
|
14716
|
+
}
|
|
14717
|
+
else
|
|
14718
|
+
// save failed, return null
|
|
14719
|
+
return null;
|
|
14720
|
+
}
|
|
14721
|
+
else
|
|
14722
|
+
return null;
|
|
14723
|
+
}
|
|
14724
|
+
|
|
14725
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
14726
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateQueryInput): Promise<boolean> {
|
|
14727
|
+
return true;
|
|
14728
|
+
}
|
|
14729
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateQueryInput) {
|
|
14730
|
+
}
|
|
14731
|
+
|
|
14732
|
+
@Mutation(() => Query_)
|
|
14733
|
+
async UpdateQuery(
|
|
14734
|
+
@Arg('input', () => UpdateQueryInput) input: UpdateQueryInput,
|
|
14735
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14736
|
+
@PubSub() pubSub: PubSubEngine
|
|
14737
|
+
) {
|
|
14738
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14739
|
+
const entityObject = <QueryEntity>await new Metadata().GetEntityObject('Queries', this.GetUserFromPayload(userPayload));
|
|
14740
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Queries
|
|
14741
|
+
|
|
14742
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
14743
|
+
// save worked, fire afterevent and return all the data
|
|
14744
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
14745
|
+
return entityObject.GetAll();
|
|
14746
|
+
}
|
|
14747
|
+
else
|
|
14748
|
+
return null; // save failed, return null
|
|
14749
|
+
}
|
|
14750
|
+
else
|
|
14751
|
+
return null;
|
|
14752
|
+
}
|
|
14753
|
+
|
|
14754
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
14755
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateQueryInput): Promise<boolean> {
|
|
14756
|
+
const i = input, d = dataSource; // prevent error
|
|
14757
|
+
return true;
|
|
14758
|
+
}
|
|
14759
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateQueryInput) {
|
|
14760
|
+
const i = input, d = dataSource; // prevent error
|
|
14761
|
+
}
|
|
14762
|
+
|
|
14763
|
+
}
|
|
14764
|
+
|
|
14765
|
+
//****************************************************************************
|
|
14766
|
+
// ENTITY CLASS for Query Permissions
|
|
14767
|
+
//****************************************************************************
|
|
14768
|
+
@ObjectType()
|
|
14769
|
+
export class QueryPermission_ {
|
|
14770
|
+
@Field(() => Int)
|
|
14771
|
+
ID: number;
|
|
14772
|
+
|
|
14773
|
+
@Field(() => Int)
|
|
14774
|
+
QueryID: number;
|
|
14775
|
+
|
|
14776
|
+
@Field()
|
|
14777
|
+
@MaxLength(100)
|
|
14778
|
+
RoleName: string;
|
|
14779
|
+
|
|
14780
|
+
@Field()
|
|
14781
|
+
@MaxLength(8)
|
|
14782
|
+
CreatedAt: Date;
|
|
14783
|
+
|
|
14784
|
+
@Field()
|
|
14785
|
+
@MaxLength(8)
|
|
14786
|
+
UpdatedAt: Date;
|
|
14787
|
+
|
|
14788
|
+
}
|
|
14789
|
+
|
|
14790
|
+
//****************************************************************************
|
|
14791
|
+
// INPUT TYPE for Query Permissions
|
|
14792
|
+
//****************************************************************************
|
|
14793
|
+
@InputType()
|
|
14794
|
+
export class CreateQueryPermissionInput {
|
|
14795
|
+
@Field(() => Int, )
|
|
14796
|
+
QueryID: number;
|
|
14797
|
+
|
|
14798
|
+
@Field()
|
|
14799
|
+
RoleName: string;
|
|
14800
|
+
}
|
|
14801
|
+
|
|
14802
|
+
|
|
14803
|
+
//****************************************************************************
|
|
14804
|
+
// INPUT TYPE for Query Permissions
|
|
14805
|
+
//****************************************************************************
|
|
14806
|
+
@InputType()
|
|
14807
|
+
export class UpdateQueryPermissionInput {
|
|
14808
|
+
@Field(() => Int, )
|
|
14809
|
+
ID: number;
|
|
14810
|
+
|
|
14811
|
+
@Field(() => Int, )
|
|
14812
|
+
QueryID: number;
|
|
14813
|
+
|
|
14814
|
+
@Field()
|
|
14815
|
+
RoleName: string;
|
|
14816
|
+
}
|
|
14817
|
+
|
|
14818
|
+
//****************************************************************************
|
|
14819
|
+
// RESOLVER for Query Permissions
|
|
14820
|
+
//****************************************************************************
|
|
14821
|
+
@ObjectType()
|
|
14822
|
+
export class RunQueryPermissionViewResult {
|
|
14823
|
+
@Field(() => [QueryPermission_])
|
|
14824
|
+
Results: QueryPermission_[];
|
|
14825
|
+
|
|
14826
|
+
@Field(() => Int, {nullable: true})
|
|
14827
|
+
UserViewRunID?: number;
|
|
14828
|
+
|
|
14829
|
+
@Field(() => Int, {nullable: true})
|
|
14830
|
+
RowCount: number;
|
|
14831
|
+
|
|
14832
|
+
@Field(() => Int, {nullable: true})
|
|
14833
|
+
TotalRowCount: number;
|
|
14834
|
+
|
|
14835
|
+
@Field(() => Int, {nullable: true})
|
|
14836
|
+
ExecutionTime: number;
|
|
14837
|
+
|
|
14838
|
+
@Field({nullable: true})
|
|
14839
|
+
ErrorMessage?: string;
|
|
14840
|
+
|
|
14841
|
+
@Field(() => Boolean, {nullable: false})
|
|
14842
|
+
Success: boolean;
|
|
14843
|
+
}
|
|
14844
|
+
|
|
14845
|
+
@Resolver(QueryPermission_)
|
|
14846
|
+
export class QueryPermissionResolver extends ResolverBase {
|
|
14847
|
+
@Query(() => RunQueryPermissionViewResult)
|
|
14848
|
+
async RunQueryPermissionViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14849
|
+
return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
|
|
14850
|
+
}
|
|
14851
|
+
|
|
14852
|
+
@Query(() => RunQueryPermissionViewResult)
|
|
14853
|
+
async RunQueryPermissionViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14854
|
+
return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
|
|
14855
|
+
}
|
|
14856
|
+
|
|
14857
|
+
@Query(() => RunQueryPermissionViewResult)
|
|
14858
|
+
async RunQueryPermissionDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
14859
|
+
input.EntityName = 'Query Permissions';
|
|
14860
|
+
return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
|
|
14861
|
+
}
|
|
14862
|
+
@Query(() => QueryPermission_, { nullable: true })
|
|
14863
|
+
async QueryPermission(@Arg('ID', () => Int) ID: Number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<QueryPermission_ | null> {
|
|
14864
|
+
this.CheckUserReadPermissions('Query Permissions', userPayload);
|
|
14865
|
+
const sSQL = `SELECT * FROM [admin].[vwQueryPermissions] WHERE [ID]=${ID} ` + this.getRowLevelSecurityWhereClause('Query Permissions', userPayload, EntityPermissionType.Read, 'AND');
|
|
14866
|
+
const result = this.MapFieldNamesToCodeNames('Query Permissions', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
|
|
14867
|
+
return result;
|
|
14868
|
+
}
|
|
14869
|
+
|
|
14870
|
+
@Mutation(() => QueryPermission_)
|
|
14871
|
+
async CreateQueryPermission(
|
|
14872
|
+
@Arg('input', () => CreateQueryPermissionInput) input: CreateQueryPermissionInput,
|
|
14873
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14874
|
+
@PubSub() pubSub: PubSubEngine
|
|
14875
|
+
) {
|
|
14876
|
+
if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14877
|
+
const entityObject = <QueryPermissionEntity>await new Metadata().GetEntityObject('Query Permissions', this.GetUserFromPayload(userPayload));
|
|
14878
|
+
await entityObject.NewRecord();
|
|
14879
|
+
entityObject.SetMany(input);
|
|
14880
|
+
if (await entityObject.Save()) {
|
|
14881
|
+
// save worked, fire the AfterCreate event and then return all the data
|
|
14882
|
+
await this.AfterCreate(dataSource, input); // fire event
|
|
14883
|
+
return entityObject.GetAll();
|
|
14884
|
+
}
|
|
14885
|
+
else
|
|
14886
|
+
// save failed, return null
|
|
14887
|
+
return null;
|
|
14888
|
+
}
|
|
14889
|
+
else
|
|
14890
|
+
return null;
|
|
14891
|
+
}
|
|
14892
|
+
|
|
14893
|
+
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
14894
|
+
protected async BeforeCreate(dataSource: DataSource, input: CreateQueryPermissionInput): Promise<boolean> {
|
|
14895
|
+
return true;
|
|
14896
|
+
}
|
|
14897
|
+
protected async AfterCreate(dataSource: DataSource, input: CreateQueryPermissionInput) {
|
|
14898
|
+
}
|
|
14899
|
+
|
|
14900
|
+
@Mutation(() => QueryPermission_)
|
|
14901
|
+
async UpdateQueryPermission(
|
|
14902
|
+
@Arg('input', () => UpdateQueryPermissionInput) input: UpdateQueryPermissionInput,
|
|
14903
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
14904
|
+
@PubSub() pubSub: PubSubEngine
|
|
14905
|
+
) {
|
|
14906
|
+
if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
|
|
14907
|
+
const entityObject = <QueryPermissionEntity>await new Metadata().GetEntityObject('Query Permissions', this.GetUserFromPayload(userPayload));
|
|
14908
|
+
entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Query Permissions
|
|
14909
|
+
|
|
14910
|
+
if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
|
|
14911
|
+
// save worked, fire afterevent and return all the data
|
|
14912
|
+
await this.AfterUpdate(dataSource, input); // fire event
|
|
14913
|
+
return entityObject.GetAll();
|
|
14914
|
+
}
|
|
14915
|
+
else
|
|
14916
|
+
return null; // save failed, return null
|
|
14917
|
+
}
|
|
14918
|
+
else
|
|
14919
|
+
return null;
|
|
14920
|
+
}
|
|
14921
|
+
|
|
14922
|
+
// Before/After UPDATE Event Hooks for Sub-Classes to Override
|
|
14923
|
+
protected async BeforeUpdate(dataSource: DataSource, input: UpdateQueryPermissionInput): Promise<boolean> {
|
|
14924
|
+
const i = input, d = dataSource; // prevent error
|
|
14925
|
+
return true;
|
|
14926
|
+
}
|
|
14927
|
+
protected async AfterUpdate(dataSource: DataSource, input: UpdateQueryPermissionInput) {
|
|
14928
|
+
const i = input, d = dataSource; // prevent error
|
|
14929
|
+
}
|
|
14930
|
+
|
|
14012
14931
|
}
|