@memberjunction/server 0.9.245 → 0.9.246

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.246",
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.67",
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.166",
28
+ "@memberjunction/data-context": "^0.9.53",
29
+ "@memberjunction/data-context-server": "^0.9.49",
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.11",
32
+ "@memberjunction/queue": "^0.9.188",
33
+ "@memberjunction/sqlserver-dataprovider": "^0.9.203",
34
+ "@memberjunction/skip-types": "^0.9.78",
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/23/2024, 4:22:49 PM
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
  //****************************************************************************