@memberjunction/server 0.9.245 → 0.9.247

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/server",
3
- "version": "0.9.245",
3
+ "version": "0.9.247",
4
4
  "description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
@@ -22,16 +22,16 @@
22
22
  "@apollo/server": "^4.9.1",
23
23
  "@graphql-tools/utils": "^10.0.1",
24
24
  "@memberjunction/ai": "^0.9.163",
25
- "@memberjunction/aiengine": "^0.9.66",
25
+ "@memberjunction/aiengine": "^0.9.68",
26
26
  "@memberjunction/core": "^0.9.177",
27
- "@memberjunction/core-entities": "^0.9.165",
28
- "@memberjunction/data-context": "^0.9.52",
29
- "@memberjunction/data-context-server": "^0.9.48",
27
+ "@memberjunction/core-entities": "^0.9.167",
28
+ "@memberjunction/data-context": "^0.9.54",
29
+ "@memberjunction/data-context-server": "^0.9.50",
30
30
  "@memberjunction/global": "^0.9.156",
31
- "@memberjunction/storage": "^0.9.10",
32
- "@memberjunction/queue": "^0.9.187",
33
- "@memberjunction/sqlserver-dataprovider": "^0.9.202",
34
- "@memberjunction/skip-types": "^0.9.77",
31
+ "@memberjunction/storage": "^0.9.12",
32
+ "@memberjunction/queue": "^0.9.189",
33
+ "@memberjunction/sqlserver-dataprovider": "^0.9.204",
34
+ "@memberjunction/skip-types": "^0.9.79",
35
35
  "@types/cors": "^2.8.13",
36
36
  "@types/jsonwebtoken": "^8.5.9",
37
37
  "@types/node": "^18.11.14",
@@ -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: 3/23/2024, 10:41:24 AM
5
+ * GENERATED: 3/24/2024, 11:43:36 AM
6
6
  *
7
7
  * >>> DO NOT MODIFY THIS FILE!!!!!!!!!!!!
8
8
  * >>> YOUR CHANGES WILL BE OVERWRITTEN
@@ -1273,6 +1273,25 @@ export class Role_ {
1273
1273
 
1274
1274
  }
1275
1275
 
1276
+ //****************************************************************************
1277
+ // INPUT TYPE for Roles
1278
+ //****************************************************************************
1279
+ @InputType()
1280
+ export class CreateRoleInput {
1281
+ @Field()
1282
+ Name: string;
1283
+
1284
+ @Field({ nullable: true })
1285
+ Description: string;
1286
+
1287
+ @Field({ nullable: true })
1288
+ DirectoryID: string;
1289
+
1290
+ @Field({ nullable: true })
1291
+ SQLName: string;
1292
+ }
1293
+
1294
+
1276
1295
  //****************************************************************************
1277
1296
  // INPUT TYPE for Roles
1278
1297
  //****************************************************************************
@@ -1394,6 +1413,36 @@ export class RoleResolver extends ResolverBase {
1394
1413
  return result;
1395
1414
  }
1396
1415
 
1416
+ @Mutation(() => Role_)
1417
+ async CreateRole(
1418
+ @Arg('input', () => CreateRoleInput) input: CreateRoleInput,
1419
+ @Ctx() { dataSource, userPayload }: AppContext,
1420
+ @PubSub() pubSub: PubSubEngine
1421
+ ) {
1422
+ if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
1423
+ const entityObject = <RoleEntity>await new Metadata().GetEntityObject('Roles', this.GetUserFromPayload(userPayload));
1424
+ await entityObject.NewRecord();
1425
+ entityObject.SetMany(input);
1426
+ if (await entityObject.Save()) {
1427
+ // save worked, fire the AfterCreate event and then return all the data
1428
+ await this.AfterCreate(dataSource, input); // fire event
1429
+ return entityObject.GetAll();
1430
+ }
1431
+ else
1432
+ // save failed, return null
1433
+ return null;
1434
+ }
1435
+ else
1436
+ return null;
1437
+ }
1438
+
1439
+ // Before/After CREATE Event Hooks for Sub-Classes to Override
1440
+ protected async BeforeCreate(dataSource: DataSource, input: CreateRoleInput): Promise<boolean> {
1441
+ return true;
1442
+ }
1443
+ protected async AfterCreate(dataSource: DataSource, input: CreateRoleInput) {
1444
+ }
1445
+
1397
1446
  @Mutation(() => Role_)
1398
1447
  async UpdateRole(
1399
1448
  @Arg('input', () => UpdateRoleInput) input: UpdateRoleInput,
@@ -1425,6 +1474,32 @@ export class RoleResolver extends ResolverBase {
1425
1474
  const i = input, d = dataSource; // prevent error
1426
1475
  }
1427
1476
 
1477
+ @Mutation(() => Role_)
1478
+ async DeleteRole(@Arg('ID', () => Int) ID: number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1479
+ if (await this.BeforeDelete(dataSource, ID)) { // fire event and proceed if it wasn't cancelled
1480
+ const entityObject = <RoleEntity>await new Metadata().GetEntityObject('Roles', this.GetUserFromPayload(userPayload));
1481
+ await entityObject.Load(ID);
1482
+ const returnValue = entityObject.GetAll(); // grab the values before we delete so we can return last state before delete if we are successful.
1483
+ if (await entityObject.Delete()) {
1484
+ await this.AfterDelete(dataSource, ID); // fire event
1485
+ return returnValue;
1486
+ }
1487
+ else
1488
+ return null; // delete failed, this will cause an exception
1489
+ }
1490
+ else
1491
+ return null; // BeforeDelete canceled the operation, this will cause an exception
1492
+ }
1493
+
1494
+ // Before/After UPDATE Event Hooks for Sub-Classes to Override
1495
+ protected async BeforeDelete(dataSource: DataSource, ID: number): Promise<boolean> {
1496
+ const i = ID, d = dataSource; // prevent error;
1497
+ return true;
1498
+ }
1499
+ protected async AfterDelete(dataSource: DataSource, ID: number) {
1500
+ const i = ID, d = dataSource; // prevent error
1501
+ }
1502
+
1428
1503
  }
1429
1504
 
1430
1505
  //****************************************************************************
@@ -5456,6 +5531,19 @@ export class Application_ {
5456
5531
 
5457
5532
  }
5458
5533
 
5534
+ //****************************************************************************
5535
+ // INPUT TYPE for Applications
5536
+ //****************************************************************************
5537
+ @InputType()
5538
+ export class CreateApplicationInput {
5539
+ @Field()
5540
+ Name: string;
5541
+
5542
+ @Field({ nullable: true })
5543
+ Description: string;
5544
+ }
5545
+
5546
+
5459
5547
  //****************************************************************************
5460
5548
  // INPUT TYPE for Applications
5461
5549
  //****************************************************************************
@@ -5547,6 +5635,36 @@ export class ApplicationResolver extends ResolverBase {
5547
5635
  return result;
5548
5636
  }
5549
5637
 
5638
+ @Mutation(() => Application_)
5639
+ async CreateApplication(
5640
+ @Arg('input', () => CreateApplicationInput) input: CreateApplicationInput,
5641
+ @Ctx() { dataSource, userPayload }: AppContext,
5642
+ @PubSub() pubSub: PubSubEngine
5643
+ ) {
5644
+ if (await this.BeforeCreate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
5645
+ const entityObject = <ApplicationEntity>await new Metadata().GetEntityObject('Applications', this.GetUserFromPayload(userPayload));
5646
+ await entityObject.NewRecord();
5647
+ entityObject.SetMany(input);
5648
+ if (await entityObject.Save()) {
5649
+ // save worked, fire the AfterCreate event and then return all the data
5650
+ await this.AfterCreate(dataSource, input); // fire event
5651
+ return entityObject.GetAll();
5652
+ }
5653
+ else
5654
+ // save failed, return null
5655
+ return null;
5656
+ }
5657
+ else
5658
+ return null;
5659
+ }
5660
+
5661
+ // Before/After CREATE Event Hooks for Sub-Classes to Override
5662
+ protected async BeforeCreate(dataSource: DataSource, input: CreateApplicationInput): Promise<boolean> {
5663
+ return true;
5664
+ }
5665
+ protected async AfterCreate(dataSource: DataSource, input: CreateApplicationInput) {
5666
+ }
5667
+
5550
5668
  @Mutation(() => Application_)
5551
5669
  async UpdateApplication(
5552
5670
  @Arg('input', () => UpdateApplicationInput) input: UpdateApplicationInput,
@@ -5555,9 +5673,9 @@ export class ApplicationResolver extends ResolverBase {
5555
5673
  ) {
5556
5674
  if (await this.BeforeUpdate(dataSource, input)) { // fire event and proceed if it wasn't cancelled
5557
5675
  const entityObject = <ApplicationEntity>await new Metadata().GetEntityObject('Applications', this.GetUserFromPayload(userPayload));
5558
- entityObject.LoadFromData(input) // using the input instead of loading from DB because TrackChanges is turned off for Applications
5559
-
5560
- if (await entityObject.Save({ IgnoreDirtyState: true /*flag used because of LoadFromData() call above*/ })) {
5676
+ await entityObject.Load(input.ID) // Track Changes is turned on, so we need to get the latest data from DB first before we save
5677
+ entityObject.SetMany(input);
5678
+ if (await entityObject.Save()) {
5561
5679
  // save worked, fire afterevent and return all the data
5562
5680
  await this.AfterUpdate(dataSource, input); // fire event
5563
5681
  return entityObject.GetAll();
@@ -5578,6 +5696,32 @@ export class ApplicationResolver extends ResolverBase {
5578
5696
  const i = input, d = dataSource; // prevent error
5579
5697
  }
5580
5698
 
5699
+ @Mutation(() => Application_)
5700
+ async DeleteApplication(@Arg('ID', () => Int) ID: number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
5701
+ if (await this.BeforeDelete(dataSource, ID)) { // fire event and proceed if it wasn't cancelled
5702
+ const entityObject = <ApplicationEntity>await new Metadata().GetEntityObject('Applications', this.GetUserFromPayload(userPayload));
5703
+ await entityObject.Load(ID);
5704
+ const returnValue = entityObject.GetAll(); // grab the values before we delete so we can return last state before delete if we are successful.
5705
+ if (await entityObject.Delete()) {
5706
+ await this.AfterDelete(dataSource, ID); // fire event
5707
+ return returnValue;
5708
+ }
5709
+ else
5710
+ return null; // delete failed, this will cause an exception
5711
+ }
5712
+ else
5713
+ return null; // BeforeDelete canceled the operation, this will cause an exception
5714
+ }
5715
+
5716
+ // Before/After UPDATE Event Hooks for Sub-Classes to Override
5717
+ protected async BeforeDelete(dataSource: DataSource, ID: number): Promise<boolean> {
5718
+ const i = ID, d = dataSource; // prevent error;
5719
+ return true;
5720
+ }
5721
+ protected async AfterDelete(dataSource: DataSource, ID: number) {
5722
+ const i = ID, d = dataSource; // prevent error
5723
+ }
5724
+
5581
5725
  }
5582
5726
 
5583
5727
  //****************************************************************************